Alternative to Siebel's BrowserScript function ShowModalDialog() to work on Chrome - siebel

What is the alternative to Siebel's BrowserScript function ShowModalDialog() to launch a HTML page from Siebel on Chrome? The method is deprecated on Chrome, FireFox. It works on IE, but Chrome users get an error message.
My code:
function Applet_PreInvokeMethod (name, inputPropSet)
{
//other code
var ShowModalOptions = "dialogHeight:150px;dialogLeft:120px;dialogWidth:450px;scrollbars:no";
var sFileSelected = theApplication().ShowModalDialog("FilePicker.htm", "", ShowModalOptions);
//other code
}

We're having similar issue. In High Interactivity (only in Internet Explorer) it works fine. However, we are supporting other browsers in OpenUI where this problem emerges.
Briefly, we tackle the problem like this:
we distinguish if we are in OpenUI or High Interactivity
if it's High Interactivity (therefore it runs Internet Explorer) -> everything stays as before
if it's OpenUI -> we use our custom dialog in jquery in Presentation Model
In applet method we keep everything as before if the it's not OpenUI:
function Applet_PreInvokeMethod (name, inputPropSet)
{
//other code
if (!IsOpenUI) {
var ShowModalOptions = "dialogHeight:150px;dialogLeft:120px;dialogWidth:450px;scrollbars:no";
var sFileSelected = theApplication().ShowModalDialog("FilePicker.htm", "", ShowModalOptions);
//other code
}
}
Then, we introduce Presentation Model in OpenUI for the particular applet:
presentation model for the applet {
...
function PreInvokeMethod(methodName, psInputArgs, lp, returnStructure) {
try {
if (methodName == "MethodName") {
// show jquery dialog having similar to FilePicker.htm
...
// other code
}
}
}
...
}
You will need to duplicate code (for HI and OpenUI), you will need to keep your FilePicker.htm and u will need to make similar dialog for OpenUI.

Related

How to create WizardFormPage dynamically in Sitecore?

We are using the WizardForm xml control for implementing some sort of backend sitecore wizard. We want to add the controls to the pages (or even create new custom pages) on the fly, dynamically depending on the selection done in the previous page.
What I've already done: we called a parent control of the page control on the page (in ActivePageChanging event) and tried to add a new object of type "WizardDialogBaseXmlControl" there. But no new pages are displayed in the frontend. I still see the same number of pages in the browser's dev. tools that I added at design time in xml. I tried "SheerResponse.Redraw()", but that didn't help either.
My next attempt was to create some pages in the xml file at design time and just populate them with controls, but that doesn't work after the wizard has already loaded. Something like "ControlName.Controls.Add(new ControlName())" only works if it is called in the overridden method "OnLoad()".
This code doesn't work:
protected override bool ActivePageChanging(string page, ref string newpage)
{
if (newpage.Equals(Consts.PrototypeDetailsPageId))
{
if (IsFormItemSelected(out var formItem))
{
PrototypeDetailsPanel0.Controls.Add(new Literal("some text"));
}
else
{
SheerResponse.Alert("You must select a form item");
return false;
}
}
return base.ActivePageChanging(page, ref newpage);
}
How can I create a working wizard that adds pages and controls at runtime when they depend on changes on previous pages of the same wizard?
Sitecore WizardForm relies on the newpage parameter to process navigation between steps. So you can prepare alternative versions of wizard steps in advance and set one of them as newpage depending on values entered in the previous step. For example, this is how your code can look like:
protected override bool ActivePageChanging(string page, ref string newpage)
{
if (newpage.Equals(Consts.PrototypeDetailsPageId))
{
if (IsFormItemSelected(out var formItem))
{
newpage = "WizardPageWithAdditionalFields";
}
else
{
SheerResponse.Alert("You must select a form item");
return false;
}
}
return base.ActivePageChanging(page, ref newpage);
}
I also found it useful that wizard forms can be easily created with Interactive Dialogs from PowerShell Extensions.
Just as an alternative solution, here is an example of how you can display multiple dialogs to navigate users through a number of steps:
--Prepare step 1
$options = #{
"A"="a"
"B"="b"
}
$props = #{
Parameters = #(
#{Name="selectedOption"; Title="Choose an option"; Options=$options}
)
Title = "Step 1"
}
--Display step 1
$result = Read-Variable #props
if($result -ne "ok") { exit }
--Step 2
if($selectedOption -eq "Expected value") {
--Perform additional logic, for example modify #props to include additional steps
$props = #{
...
}
}
--Display step 2
$result = Read-Variable #props

Attachments moved away from Item after validation and before submit process in Apex

I have multiple File Browser Item fields on one page of Application in Oracle Apex.
What happens: When I miss any Item for which validation error fires, I want to hold that file to the browser but I usually loose it if I get that validation error. Is there a solution for the same like other Items fields hold previous value except File Browser Item field. Please see below ss:
Anshul,
APEX 4.2 is very old and no longer supported. A later (or preferably latest) version of APEX will behave differently as Dan explained above.
Can you import your application into apex.oracle.com (which is running APEX 20.1) and you will probably see better results. Based on this you can hopefully use it as justification to upgrade your environment.
Regards,
David
Go to your page-level attributes and a function like the following in the Function and Global Variable Declaration:
function validateItems(request) {
var $file1 = $('#P68_FILE_1');
var $file2 = $('#P68_FILE_2');
var errorsFound = false;
if ($file1.val() === '') {
errorsFound = true;
// Show item in error state
}
if ($file2.val() === '') {
errorsFound = true;
// Show item in error state
}
if (!errorsFound) {
// I think doSubmit was the name of the function back then. If not, try apex.submit
doSubmit(request);
} else {
// Show error message at top of page, I'll use a generic alert for now
alert('You must select a file for each file selector.');
}
}
Then, right-click the Create button and select Create a Dynamic Action. Set the name of the Dynamic Action to Create button clicked.
For the Action, set Type to Execute JavaScript Code. Enter the following JS in code:
validateItems('CREATE');
Finally, ensure that Fire on Initialization is disabled.
Repeat the process for the Save button, but change the request value passed to validateItems to SAVE.

Posting with UIActivityViewController, but avoiding cropping?

Say you construct an image that is fullscreen on different devices. You then use UIActivityViewController to post to - for example - Instagram in the normal way.
The user clicks your share button, it brings up the usual iOS-sharing-thingy,
and you can post to Instagram (assuming the user's an Instagram user of course). No worries.
But typically the image is cropped on Instagram - you lose a little of the top and bottom.
Is there actually any solution for this?
Note that indeed - say you open the normal Photos app on the iPhone, and "share" and post on Instagram ... you lose a little of the top and bottom!
When the user does click the Instagram icon on this ...
in fact is there a way for me then to go back, be aware of the user's choice, and make the image the appropriate size?
Is there perhaps a way to pass a selection of images (various sizes) to the UIActivityViewController?
What's the deal on this, it seems like a basic failing?
Note - I'm fully aware that BEFORE going to the iOS-share-thingy, I could ask the user myself "What size image would you like me to make?"
Note - I'm aware that it's in some cases possible to post "directly" to say Instagram inside the app, without using Apple's share system; that's lame though.
To save anyone typing, here's some clean code to bring up the iOS-share system...
#IBAction func userClickedOurShareButton()
{
let s:[AnyObject] = [buildImage()]
let ac = CleanerActivity(activityItems:s, applicationActivities:nil)
ac.popoverPresentationController?.sourceView = view
// needed so that iPads won't crash. sarcasm: thanks Apple
ac.excludedActivityTypes = [UIActivityType.assignToContact,
UIActivityType.saveToCameraRoll,
UIActivityType.addToReadingList,
UIActivityType.copyToPasteboard ]
// consider UIActivityTypeMessage also
if #available(iOS 9.0, *) {
ac.excludedActivityTypes?.append(UIActivityType.openInIBooks)
} else {
// Fallback on earlier versions
}
self.present(ac, animated:false, completion:nil)
}
class CleanerActivity: UIActivityViewController {
func _shouldExcludeActivityType(_ activity: UIActivity) -> Bool {
let activityTypesToExclude = [
"com.apple.reminders.RemindersEditorExtension",
"com.apple.mobilenotes.SharingExtension",
"com.google.Drive.ShareExtension",
"com.apple.mobileslideshow.StreamShareService"
]
if let actType = activity.activityType {
if activityTypesToExclude.contains(actType.rawValue) {
return true
}
else if super.excludedActivityTypes != nil {
return super.excludedActivityTypes!.contains(actType)
}
}
return false
}
Disclaimer: this solution involves hard-coding Instagram's extension identifier into your app, which may or may not make it through app review, and may break in the future. Try at your own risk!
Apple provides a mechanism for this called UIActivityItemProvider. Instead of passing an image to your UIActivityViewController, you can pass subclass of UIActivityItemProvider that overrides itemForActivityType to return an appropriate image based on the activity type chosen by the user.
Apple provides constants for many common activity types, but Instagram isn't yet included. You can identify Instagram by checking if the activity type's raw value is com.burbn.instagram.shareextension. This would break if Instagram changed the ID of their extension.
Here's an UIActivityItemProvider that provides different images to Instagram:
class DynamicImageProvider: UIActivityItemProvider {
let instagramImage: UIImage
let defaultImage: UIImage
init(instagramImage: UIImage, defaultImage: UIImage) {
self.instagramImage = instagramImage
self.defaultImage = defaultImage
super.init(placeholderItem: defaultImage)
}
override func activityViewController(_ activityViewController: UIActivityViewController,
itemForActivityType activityType: UIActivityType) -> Any? {
if activityType.rawValue == "com.burbn.instagram.shareextension" {
return instagramImage
}
else {
return defaultImage
}
}
}
Then change the first two lines of your IBAction:
let imageProvider = DynamicImageProvider(instagramImage:buildInstagramImage(), defaultImage:buildImage())
let ac = CleanerActivity(activityItems:[imageProvider], applicationActivities:nil)

data-dialog created dynamically

I'm using polymer 1.0.
I'm trying to open a with on a clic on an element created dynamically with template repeat.
Here is the code :
<paper-button
data-dialog="modal"
on-click="dialogClick">
Click
</paper-button>
and the script (from doc) :
dialogClick: function(e) {
var button = e.target;
while (!button.hasAttribute('data-dialog') && button !== document.body) {
button = button.parentElement;
}
if (!button.hasAttribute('data-dialog')) {
return;
}
var id = button.getAttribute('data-dialog');
var dialog = document.getElementById(id);
alert(dialog);
if (dialog) {
dialog.open();
}
}
This work only if the value of data-dialog is simple text. If I want to change it by data-dialog="{{item.dialogName}}" for instance, it doesn't work. It is not found by the while loop and exit with the if. in the source code of the page, there is no data-dialog in the paper-button.
Any idea ?
I've ran into a similar problem when using data attributes on custom elements. You might want to subscribe to this polymer issue.
As a workaround, place the data attribute in a standard element that is a parent of the button and search for that one instead.
Also, you might want to consider using var button = Polymer.dom(e).localTarget instead of directly accessing e.target, since the later will give you an element deeper in the dom tree under shady dom.

How do I utilize the save event in a Sitecore custom Item Editor?

I am creating a custom item editor, and am using the following blog post as a reference for responding to the "save" event in the Content Editor, so that I do not need to create a second, confusing Save button for my users.
http://www.markvanaalst.com/sitecore/creating-a-item-editor/
I am able to save my values to the item, but the values in the normal Content tab are also being saved, overriding my values. I have confirmed this via Firebug. Is there a way to prevent this, or to ensure my save is always after the default save?
I have this in as a support ticket and on SDN as well, but wondering what the SO community can come up with.
Thanks!
Took a shot at an iframe-based solution, which uses an IFrame field to read and save the values being entered in my item editor. It needs to be cleaned up a bit, and feels like an interface hack, but it seems to be working at the moment.
In my item editor:
jQuery(function () {
var parentScForm = window.parent.scForm;
parentScForm.myItemEditor = window;
});
function myGetValue(field) {
var values = [];
jQuery('#myForm input[#name="' + field + '"]:checked').each(function () {
values.push(jQuery(this).val());
});
var value = values.join('|');
return value;
}
In my Iframe field:
function scGetFrameValue() {
var parentScForm = window.parent.scForm;
if (typeof (parentScForm.myItemEditor) != "undefined") {
if (typeof (parentScForm.myItemEditor.myGetValue) != "undefined") {
return parentScForm.myItemEditor.myGetValue("myLists");
}
}
return null;
}
In theory, I could have multiple fields on the item which are "delegated" to the item editor in this way -- working with the content editor save rather than trying to fight against it. I'm a little uneasy about "hitchhiking" onto the scForm to communicate between my pages -- might consult with our resident Javascript hacker on a better method.
Any comments on the solution?
EDIT: Blogged more about this solution