How can I show a "please wait" message while submitting (logging in) - modal-dialog

I use an to show a message while running some code via a JsonRpcService. Works like a charm.
Now, I would like show a similar message saying "Please wait..." when the user submits a page. In this particular case it is logging in - where I need to read a lot of data to show the user. I submit the login info in a custom control when the user presses the icon (=button):
<xp:image url="/arrowGrey.png" id="submitButton" styleClass="submitButton" alt="Login" title="Login">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:Logon.submit()}]]></xp:this.action>
<xp:this.onStart><![CDATA[console.log('Start login');
setTimeout(function () {
XSP.openDialog('#{id:working}');
}, 300);]]></xp:this.onStart>
</xp:eventHandler>
</xp:image>
Logon is a managed bean. However, I never see the dialog box... - nor the "Start login" message?
The definition of the is:
<xe:dialog id="working" styleClass="inProgress">
<xp:div>
<xp:text escape="true" id="computedField1" tagName="h2" value="Logging in. Please wait..."></xp:text>
</xp:div>
</xe:dialog>
Any ideas as to how to obtain this?
The obvious next challenge is to close the dialog should the Logon.submit() fail validation and keep the user on the current page... :-)

If you are doing a Full refresh then the standby widget will not work. it only works on partial refreshes because a full refresh will reload everything on the page. But the standby widget is using a standard Dojo function that you could use.
Or what I usually do when I have some of code that needs to be executed. I send the users to a "please wait XPage" with an animated gif.
The trick is that the code can't start executing before the page and the gif is loaded so I add the code to a hidden button and in the onload event I click this button using client side JS that executed the backend code.
And when I'm done processing, I send them to the right page using context.reloadPage
This works very well.

Fredrik Norling created the very cool "Standby Custom Control" (http://openntf.org/XSnippets.nsf/snippet.xsp?id=standby-dialog-custom-control). It doesn't show a message but a spinning wait icon on every partial refresh that might endure longer as 200ms (you can tweak this down or up if you want to).

Related

WWW::Selenium to capture component refresh

I am writing a perl script using WWW::Selenium module to automate a website.
I am not at all a web development guy and have no idea about web technologies.
Let me try to explain the issue in layman terms.
I am dealing with a webpage, which has an order form with a button.
When I click the button, there is no page submit, but the button label changes.
Say for eg, the button goes through these changes when clicked multiple times.
Get Quote --> Order --> Confirm Order
Each time I click the button, there is no page refresh, but the button label keeps changing as above.
The id of the button is the same throughout, only the class changes.
How can I do this in WWW::Selenium?
Presently I am using wait_for_page_to_load(5000) after each click.
But the click is not having any effect on the label and I get error that timed out after 5000s.
Should I be using some other function to wait?
You could do something like this
$sel->wait_for_text_present_ok("Your text","time to wait","The message to display if this fails");
and an example below-
$sel->wait_for_text_present_ok("Order Confirmed","9000","The order was successfully placed");
Seems like you could use
$class = $sel->get_attribute($attribute_locator)
where the $attribute_locator is the button#class with button being the element locator that you clicked. Check if $class is the class you expect.

lift disabling back button actions

I'm creating a transaction related site using lift. In here, there's a requirement to show a success page after the user action.
when i make action happen and press the browser's back button. it again goes to the previous page(before transaction page) making the transaction doable again. I need to limit this behavior. Is there any way of limiting the access to previous page by browser back button in lift.
There is no way to reliably stop the user from returning to the URL, but you can stop them from invoking the action more than once. Take a look at S.oneShot. From the Scala Doc:
All functions created inside the oneShot scope will only be called
once and their results will be cached and served again if the same
function is invoked
If you wrap the function that occurs when the button is pressed, even if the user does return to the page and click the button a second time, the body of the function shouldn't be invoked again.

nyroModal v2: How to validate form opened in iframe?

I'm trying to figure out how to validate a form opened using nyroModal.
The page is being opened as below on click of a button:
$(function() {
$('.btnedit').click(function() {
$.nmManual('form_page.php);
});
});
On the form that opens up, I have a few fields that are mandatory and a cancel & submit button.
<a class="nyroModalClose button" href="#" id="btn_submit">Submit</a>
On clicking of the submit button, I want to make sure the mandatory fields have value. If no, an error message should be displayed & the modal window should not close.
I'm trying to use the jquery validation plugin, but without success. The modal window always closes irrespective of the validation scripts.
I haven't found much info regarding form validation in a modal window. Is this not a preferred approach?
Thanks in advance.
I'm not able to help you about the jquery validation plugin in a modal window, but I know that using the instruction $.nmManual in that way, the form will not be placed inside the iframe tag, and if I remember correctly the content of new page will be added without header and body tags, so in a word incorrectly. I guess this can produce no validation.
To successfully open an iframe you need to use filters as described here:
Open iframe manually in nyroModal?
I hope this can help you.

Unable to locate WindowID

I am currently testing a web app using selenium rc with eclipse. I've been having issues with a single pop up window which appears when a submit button is clicked. The confirmation window appears with a single 'ok' option.
I've also tried 'chooseOKonnextConfirmation' in conjunction with .getConfirmation but eclipse tells me no confirmation exists. I've tried inspecting the window itself with firebug but have been unable to get any results.
I also tried with "selenium.selectWindow(getAllWindowIDs ()[1]);" but selenium not recognizing "getAllWindowIDs".
Could somebody please tell me how I can retrieve the windowID and the associated API commands I need to implement to get rid of this problem?
from your description, i understand that you have an ALERT window being appeared after clicking SUBMIT button but not the CONFIRMATION window.
if my understanding is correct
( you said single OK button - ALERT window appears with single OK button - CONFIRMATION window appears with OK and CANCEL buttons - there is another window javascript can generate which is CONFIRMATION.it appears with TEXT field and OK and CANCEL buttons )
so you must use accordingly.
here is what you should use
if(selenium.isAlertPresent()) {
String message = selenium.getAlert();
}
this will consume you Alert window and you can check the message displayed on Alert window if you want.
if this is not please post write your comment
It's selenium.getAllWindowIds(); note the capitalisation. Don't forget to make sure the popup has already appeared (e.g. selenium.waitForPopUp()).
Yes sudarsan is correct if you have an alert.
If you have an popup window not an alert with OK button then you have to click OK when popup appears.
If you are unable to locate the button use firebug to locate the element.

How can I block until the user hits the hits "close" on FB.Connect.logout?

I have some HTML that looks like this:
<a onclick="FB.Connect.logout(function() { window.location = '/'; });">
link text
</a>
logout brings up a modal that tells the user he's logging out of Facebook and has "close" button on the bottom right. Unfortunately, the browser proceeds to '/' per the callback function. How can I stop that from happening so that the user has enough time to read what's in the dialog?
Also, the close button seems kind of useless since it gets blown away once the callback gets called, so I feel like I'm missing something there...
PS: This seems like a long shot, but I'd like the user to be able to stop the log out process if having to log out of fb changes his mind. Is there a way to do that?
Have you tried the pound sign? # This tells the browser to redirect to an in page anchor..and doesn't generally redirect anywhere. This might work for you!
If you're performing an action rather than going to a location, I'd recommend using a <button> element.
With Prototype:
<button id="button-logout" value="Logout" />
function finishLogout(isLoggedOut){
if (isLoggedOut) {
location.href = "/goodbye";
}
}
function beginLogout(){
//preparation if necessary.
FB.Connect.logout(finishLogout);
}
$('button-logout').observe('click', beginLogout);
It's always better to have your events in the javascript rather than inside your tag's onclick. And, although I did make two seperate functions, it's easier to revise and reuse them later, and you can always minify them if you're looking to optimize.