Calling CSJS from within SSJS in XPages - javascript

I'm currently working on rewriting a function from a LotusScript script library in JavaScript. The LotusScript function contains both front end and back end elements -
input boxes are used to gather information from the user - so I'm wondering how best to do this. Is it possible to call a modal dialog window using csjs from within ssjs?

Here are the SSJS and CSJS commands to show/hide the dialog:
SSJS:
var comp = getComponent("serverSideId");
//To Open the dialog
comp.show();
//To close the dialog
comp.hide();
CSJS
//To Open the dialog
XSP.openDialog("#{id:serverSideId}");
//To close the dialog
XSP.closeDialog("#{id:serverSideId}");
And just for fun, SSJS that executes CSJS:
//To Open the dialog
facesContext.getViewRoot().postScript("XSP.openDialog('#{id:serverSideId}')");
//To Close the dialog
facesContext.getViewRoot().postScript("XSP.closeDialog('#{id:serverSideId}')");

Yes, have a look at the xe:dialog control. You can show and hide that dialog using SSJS.

have you tried this?
view.postScript("XSP.openDialog('#{id:dialog1}');");

Related

How to hide custom Onsen dialog

I have a custom Onsen Dialog with two buttons, and these buttons have onclick code in their html. I create this dialog using a template, and later when I try to hide this dialog with method like this
var dialog = document.getElementById("dialogSearchFriend");
dialog.hide();
I get an error "hide() is not a function".
I debugged this, and the dialog variable seems to be a template, rather than a dialog.
How can I solve this?
window.onload=function(){
$("#dialogSearchFriend").fadeOut();
}

Making jquery Dialog working between two pages

I have a dialog setup as follow
$("#myDialog").dialog({
autoOpen: true,
close: function(event, ui) {
$("#myDialog-content").html("");
$(this).dialog("destroy");
}
});
$("#myDialog").css("min-height","");
$("#myDialog-content").html("Loading...");
$.ajax({
...
success: function(response) {
$("#myDialog-content").html(response);
}
});
This working fine I load and close dialog in same page but not able to make it work properly where I move between pages.
Here is a my page flow
From source page(say PageA) I make AJAX call to load the page containing dialog div(say PageB).
Link on this page call above method to display dialog. (For first time it runs OK).
When I click close button. Dialog close and with firebug I can still see dialog div at the end with UI classes but in hidden state.
If I go back to source page (Page A) and reload the PageB.In firebug I can see two div - one originally from JSP and second one from step 3.
Now if I click button to load dialog box - It used hidden to populate new data and never use new div created by jquery. So I just have blank dialog box.
I am not sure if this is jquery Dialog issue or my page flow. One possible solution I though of is use remove in close function to remove dialog div completely but it puts burden to create this div everytime page PageB is loaded. Is there any other way or any thing I am doing wrong in this scenario?
If i understood correctly the situation, You have 2 options:
If you somehow cleaning the content of "Page B", remove the modal
then.
If you do not have the cleaning mechanism like that, just
.remove() content of modal on close
Sidenote: i would advise not to use jquery for .css and .html('Loading...'). Also, it is good to cache jquery elements in variables e.g var dialog = $("#myDialog");

Confirmation Box with ok as hyperlink

Here is my problem: chrome does not allow new tab to be opened without involvement of user action( it opens a new window instead which I do not want), so to tackle that I want the new page to be opened when user clicks ok in confirm box.
unfortunately, bool= window.confirm('sure?') does not count as user action, so I need a simple code, which would look like normal confirmation box, but instead of ok button, there would be an anchor whose url i can set dynamically.
P.S : I believe it can be done using JQuery-UI, but I want to do it just using javascript and JQuery, this is targeting chrome browser only( that's my only silver lining).
Try to use a modal It looks like a Confirm box but is created by you and you can style it.
var r = confirm("Press a button!");
if (r == true) {
window.open("your url","_blank");
}
if i got what you actually need, You can use simple js.

How to open custom view in same window in sugarcrm..like quick compose email view in leads module of SugarCRM

I have made a email functionality in a custom view using JavaScript. The problem is on clicking the send email button in list view it goes to this window and previous window is gone. I want my custom view for emailing to popup just like the default quick response email, that pops up when we click Email button in quick action menu in leads module in SugarCRM. Can anybody suggest how it could be done.
Open the Popup in a new window with a defined size using javascript
function popup (url) {
foo = window.open(url, "Popup", "width=400,height=300,resizable=yes");
foo.focus();
return false;
}
or take a look at JQuery Dialog

Pass a value to a popup

Here I am facing a problem, I will explain:
I set up a calendar on my website, when I click on an event to this calendar I open a popup until the hopefully it works correctly, I would like to change the content of my popup by inserting values my event.
eventClick: function(calEvent, jsEvent, view) {
z=open('popup.html','','width=400,height=200,toolbar=no,scrollbars=no,resizable=yes,location=0,directories=no,menubar=no,status=no');
z.document.getElementById('test').append(toto);
},
Above me the code that opens my popup correctly I created a new file by "popup.html.
The last line does not work against ...
z.document.getElementById('test').append(toto);
I have an element with the id "test" in the HTML file of my popup. I also tried to generate the popum the fly from my script, I get this solution in a properly transmit information I want displayed in the popup io unfortunately I do not find a solution to the stylized popup window
w=open("",'popup','width=400,height=200,toolbar=no,scrollbars=no,resizable=yes');
w.document.write("<TITLE>"+document.forms[0].elements["titre"].value+"</TITLE>");
w.document.write("<BODY> Hello"+document.forms[0].elements["nom"].value+"<BR><BR>");
w.document.write("this popup work");
w.document.write("</BODY>");
w.document.close();
Do you have a solution to my / my problem?
Thank you in advance,
Good afternoon,
cordially
Do you really want a new window? Or do you only want a modal, like the jQuery.UI dialog?
In order to use the latter you usually prepare a <div>, e.g.
var myDialog = $("#toto");
myDialog.dialog({ autoOpen: false });
and use myDialog.dialog('open') to open it. Note that this will remove #toto from its parent. If you don't wish this behavior try var myDialog = $("#toto").clone().
You can then style the new dialog with the jQuery css methods.

Categories