Opened new document in xpinc. How to close window or redirect to parent document? - xpages

I'm XPage-ing a form in a big classic notes application, and I'm struggling to find a way to end the interaction with the form that presents a good UI. Here's my scenario:
1) Parent document (classic notes) is opened from a view
2) Button on parent document opens child document in XPiNC using notes:/// link.
3) Cancel button on child document XPage......
I've tried the following approaches:
a) Use window.close()
I've done lots of googling on this one, and various approaches don't seem to work for me. window.close() is supposed to work if you call it from a window that was opened with window.open, so I tried window.open("closeMe.xsp", "_self") to see if this would give me a window that could be closed by an xpage with window.close() in the onClientLoad client side event. No luck there. The following questions make suggestions but don't provide a solution (apart from a third party product)
How do I close my window in Xpage?
How to close xpages in notes client? I use CSJS window.close but it's not working
b) Redirect to parent document
My next idea was to redirect to the parent document - it's already open in the Notes client. However, I found that when I redirect (using facesContext.getExternalContext().redirect("Notes:///url" ) it does indeed jump to the parent document, but it leaves a blank window open in the tab where the XPage was.
My next try was to close the parent in the original calling LotusScript, then redirect to the parent in the cancel button. This works too - you get to the parent document, but then if you press the escape key or close the tab with the parent document, it leaves you with an empty window again.
Any ideas? I like the idea of being able to return to the newly-opened parent document because I could expect an embedded view to be refreshed with my new child document, but at the moment I'll take anything that works. :)
Cheers,
Brendan

You are stuck between a rock and a hard place. XPiNC and classic Notes don't mix that easily. But there is hope. Head over to the Composite Application Wiki. There you will find that you can open a composite instead of a document which allows you to have tabs and stuff inside a composite.
It is also the way a classic application and a XPages (publish/subscribe using the property broker) can exchange data. Make sure you read the comments too. Karsten has good further links.
I don't have a working example for what you exactly want to do, but Composite feels like the best bet you have.

I found a partial solution, Java is your friend. It works in a button should work in a link too. The only problem is when called from an event like onClose the current xpage looses focus and the current pages stays open. I tried to emulate send keys and it presses the ESC key. It works fine from a button in.
Button on CLick event
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:var robot:java.awt.Robot= new java.awt.Robot;var event:java.awt.event.KeyEvent=java.awt.event.KeyEvent;
robot.keyPress(event.VK_ESCAPE);
robot.keyRelease(event.VK_ESCAPE);
enter code here}]]>
</xp:eventHandler>
</xp:button>

Related

XPages: Show busy dialog when tabPanel clicked on?

I'm using an XPages Tabbed Panel for the first time. It's generally working well, but I have a lengthy process that runs the first time one tab is clicked on, so I would like to display a client-side busy dialog that we routinely use when it's switched to. I've tried to attach some client-side JS to the associated tabPanel's event handler (with submit="true"), but that doesn't seem to work. It executes the client-side JS, but doesn't switch tabs anymore. (I am returning true in the client-side event handler.) Is there another approach that might work? FYI, I was assuming that I could call view.postScript(...) at the end of my lengthy code in order to remove the busy dialog.
As usual with my questions, I can't post code to demonstrate this, sorry.
Thanks,
Reid
I use this post: http://xpagesera.blogspot.com/2012/05/add-ajax-loading-control-in-xpages-for.html
to great effect for this. Here is the text of the post:
Add AJAX “Loading..” control in XPages for Partial Updates
This is a two step process:
Add following Dojo modules to your XPage. 
<xp:this.resources>
<xp:dojoModule name="extlib.dijit.ExtLib"></xp:dojoModule>
<xp:dojoModule name="extlib.dijit.Loading"></xp:dojoModule>
</xp:this.resources>
 
Add following lines to the EventHandler of your button/link which is going to be used for Partial Update: 
<xp:this.onStart><![CDATA[XSP.startAjaxLoading()]]></xp:this.onStart>
That’s all ! 
A similar “Please wait..” dialog will appear and will display the page again once the Partial Update is complete..

Chrome Extension, trigger click on the icon

I searched on Google and StackOverflow, and I was not able to find a solution to my problem (to my greatest surprise).
I'm looking to display the popup, exactly like when the user click on the icon of my extension, but via javascript.
The idea behind it is simple : On a specific page, I inject a button and add an event listener on it ("click"). When the user click on that button, I'd like to display the tooltip, simple as that :)
... but I can not find anything related to it. Any idea ?
Thank you in advance.
Opening the popup is impossible without user interaction. For good reason too, remember that no one likes popups that open themselves. What you can do is inject your popup onto the site the user is at, through a content script.
https://developer.chrome.com/extensions/content_scripts
As per your description,
On a specific page, I inject a button and add an event listener on it ("click"). When the user click on that button, I'd like to display the tooltip, simple as that :)
I think what you need is just chrome.pageAction, it's similar to browserAction, while represents actions that can be taken on the current page, but aren't applicable to all pages.

Session Expiration Warning

I have an XPages app that is supposed to save the main doc (and do a couple of other things) when the user clicks a button on the dialog box. The dialog box is presented by a CSJS function which runs according to a setInterval command. The dialog box and all the programming that present it are on a Custom Control. I have no problem displaying the dialog box, but have been unable to come up with a way to save the underlying document. I have other dialog boxes on their respective XPages, and saving the doc with a click (and some SSJS) works fine, but the same process doesn't seem to work if the dialog box is on a CC. I have searched all over the web, including StackOverflow, and haven't been able to find just what I need. Any ideas as to what I am missing?
Here's the code from one of my more recent attempts:
<xp:button value="Continue" id="button1">
<xp:eventHandler event="onclick" submit="false" id="eventHandler1">
<xp:this.script>
<![CDATA[
if (intvlID2) {
clearInterval(intvlID2);
}
var b18 = dojo.query('[id$="button18"]')[0];
if (b18) {
b18.click();
} else {
location.reload(true);
}
XSP.closeDialog('#{id:WarningDialog}');
]]>
</xp:this.script>
</xp:eventHandler>
</xp:button>
As you can see, it clears the interval first, then looks for a button on the underlying form. I've been able to verify that it does, in fact, find the button, but nothing happens with the click() command. The button it finds includes this save command that doesn't appear to execute:
document1.getDocument(true).save();
The button works perfectly when clicked by mouse or tapped by finger, but not when 'clicked' programmatically by another button on a CC.
The currentDocument global variable can be used to access the nearest dominoDocument datasource. Alternatively, the Extension Library dialog box has an additional parameter when closing the dialog box, the id of the refresh area. Maybe you can use that to trigger a save, something like setting a requestScope variable on close, and in the refresh area having code that does a save if the requestScope variable is set and, after save, clearing the requestScope variable?

xpages how to force a partial refresh afterPageLoad

I asked this question a couple months ago, but there has been no response so I thought I would try again. I have a block of SSJS that manipulates a number of values. There are some computed fields that are impacted by these changes and they do not display correctly. I have a refresh button on the XPage and it does a partial refresh after which everything works fine. I need to somehow trigger a partial refresh on the a specific item (a panel in this case) as the last step in the afterPageLoad in the SSJS.
Any ideas?
Thanks
Refreshing Panels from SSJS without a button, link or something like that is a bit tricky.
But i think your problem is more located in the order in wich you are trying to compute your fields what about triggering your Code in a erlier event before those Fields are rendered, to avoid displaying the wrong values in the first place, maby post some example Code.
If you only want to refresh a the panel again after the page has bean loaded try this in the onClientLoad ClientEvent this could also fix it:
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script><![CDATA[dojo.ready(function(){
XSP.partialRefreshGet('#{id:yourPanel}',{})
});]]></xp:this.script>
</xp:eventHandler>

jQuery Mobile - Dialogs without changing hash

I have a search dialog that I am popping up and filling with jquery templates. After they make a selection I set a value on the current page. As such I don't need hashTags or anything like that, I just need a pop-up dialog that I can open and close programatically. I am currently opening the dialog with
$.mobile.changePage(dialog, { transition: "slide", changeHash: false });
and closing it with
dialog.dialog('close');
However, in certain cases (when the page is navigated to), closing the dialog refreshes the current page.
Is there a better way to interact with this?
Update:
I think I figured out what is going on. So for some reason, jquery mobile usually keeps 2 pages loaded on the DOM - one of which is invisible, you can verify this by running $('[data-role=page]') in the console. One page is the page you're on, the other is the page that you initially navigated to. Not quite sure why they choose to do that, but there you have it.
So they treat dialogs as a page navigation with a different transition even if the dialog is already in the DOM. Therefore, if you go directly to the page and then trigger a dialog, modifying the current page and closing it works fine - because the original page is always loaded in the DOM. However if you go to another page, than navigate to the page that triggers the dialog, and THEN trigger the dialog it destroys the current page so that the pages in the DOM are the initial one and the dialog. In that case it reloads that dialog-launching page entirely and you never get a chance to make any modifications.
Jeez. How do I interact with the jqm dialog widget directly?
You can try two other things. Both should work:
1 set DomChache
How about overriding JQM to keep the page your are firing the dialog from in the DOM? The docs say you can set data-dom-chache and override cleaning the page from the DOM.
If it only happens when you load this page in via AJAX (vs. loading it directly) you could make DOM-keeping dependend on your trigger page having data-page-external, assign DOM-chache="true" only when the dialog is openend and remove it again once the dialog is closed.
2 override JQM
I had the same problem you described and got it to work like this (requires hacking into JQM though...):
// inside transitionPages function
if ( !$(toPage).jqmData('internal-page')
{fromPage.data( "page" )._trigger( "hide", null, { nextPage: toPage } );}
}
My problem was that pagechanging to certain pages (same as dialog) caused the preceding page (where the dialog fired from) to be removed from the DOM, so I had a blank screen (when trying to go back). I added data-internal-page="true" to the pages, which should keep the preceding page intact and added the if-clause in JQM.
So now pageHide (and DOMcleanup) only fires, if I'm not going to a page labelled with data-internal-page="true"
Cheers!
I think I was having a similar problem. What I wanted to do was based on certain parameters, pop a dialog window on load (with that content on the same page), which they can close and view the page that loaded.
I could get it to pop on load using load, or the pageshow events, but when I clicked close that sent you back to the previous page in history, instead of just closing the dialog.
//target your 1st page content, here its id=success
//the modal content is in a page id=dialog and data-role="dialog"
$('#success').live('pageshow',function(){
window.setTimeout(function(){
$.mobile.changePage('#dialog','pop',false,false);
},1);
}
Its a hack, and just allows the page load to beat the dialog so it gets stuck in history. Then the default dialog close behavior for the dialog works as expected. Talk about a PITA, if they took a little more for the JQuery UI dialog it would have made things a ton easier.
And regarding your question: Have you looked at Jquery Mobile Actionsheet plugin
If you don't really require a page to be loaded, that should be ok.
Also helpful could be Cagintranet iPad popover, although you have to tweak the design to be fullscreen on mobile devices. If you require CSS/Jquery to do that let me know (I'm using this in a JQM plugin I'm writing)
Hope that helps.

Resources