Struts 2: redirect-action ? From on page to another and back again - redirect

i have a jsp page that has a submit button. This button is linked with another jsp page.
So lets assume my stuts file looks like this:
B.jsp
So now the submit button being on page "A.jsp" will take me to B.jsp. This works. The problem is that i want to do the following:
press on the submit button on page A.jsp , go to B.jsp where i will press again a button and go back to A.jsp . The problem is that to page B.jsp go many pages, so B.jsp has to know when pressing the submit button to which page will take me back , in this case A.jsp again.
So in a few words, B.jsp has to know from which page i came from so that i can go back again by pressing a submit button (this could be a parameter that would be sent back to A.jsp again, but does not really matter at the current point)
A.jsp -> B.jsp -> A.jsp
C.jsp -> B.jsp -> C.jsp

I guess your B.jsp is some sort of general result page, which displays a message and invites the user to return to the previous page -before the submission. If you dont want to read the browser history with javascript (I woudn't) the standard approach is to pass the "returnUrl" as a property of your Action. This seems straighforward to me.

Related

showForm, Command Action, and going-back

Going "back" from a form doesn't take me to the previous form but back to the main form. What am I doing wrong? Here's more detail:
I have a Command that takes you from the main form of my app to a "human setup" form. From that form if you click on a certain multibutton I go to another form (MaintenanceLevel) like this:
protected void onHumanSetup_MultiButtonMaintenanceAction(Component c, ActionEvent event) {
// Invoke the next level of form
showForm("MaintenanceLevel", null);
}
In the "MaintenanceLevel" form I have an Action set to Back, but when I click the menu bar to go back I end up back on the main-form and not the "human setup" where I want to be.
Edit:
Things have got a little worse!! Now when I go back in to view the Commands for my MaintenanceLevel form it's empty: it's forgetting the command I've entered :(
Here is my command setting for MaintenanceLevel form:
You don't need to define a back command. Remove it. Codename One automatically creates back commands for you.
The usage for this option is when you create a Button and place it within the form, then you want it to behave as a back button effectively (e.g. cancel button).

Get previous page in UIWebView hierarchy

I need to be able to figure out what is the previous page in a UIWebView hierarchy so that I can disable the back button on certain instances. So, to clarify:
User is on page A - clicks on link
User is now on page B - clicks on link
User is now on page C - clicks on the **back** button
User is now on page B
I need to be able to know that "previous" page from page B is page A. The method I'm using right now unfortunately only figures out the previous page the user was in in general. So in the situation above, it thinks the previous navigated page is page C.
Any help would be appreciated! :)
Each time the user clicks on a link and a new page loads, your web view delegate gets a message. So "write down" that information each time! Now you know what "back" means.
Also, you can talk JavaScript to the UIWebView. JavaScript gives you a history object. A lot of the key functionality in UIWebView is through JavaScript! Apple hasn't bothered to duplicate it in Objective-C properties, because, well, why bother?
years later....
In researching this same scenario, I came up with a nice solution.
Inside webViewDidFinishLoad, check for the property "canGoBack" and hide or unhide your back button accordingly. Thought this was too cool not to share. :)
if (self.webView.canGoBack)
{
self.backButton.hidden = NO;
}
else
{
self.backButton.hidden = YES;
}

mimic pressing a button on a webpage in the backgroud, for triggering an action

Pretend you have a button on an iOS GUI. Pressing this button should now trigger a button on a webpage (which triggers an action). While doing this, the webpage should not be visible. How can I do that?
My guess is, that I read and parse the webpage, and if I've found the button action, I would trigger it somehow. Since I'm not a web programmer, I wonder how to proceed or read on for such a task.
I need this task, because there is no JSON or XML webservice on the page that would make life easier.
Many thanks for any input
Okay, let's say you've already loaded your webpage in an off-screen (or hidden) UIWebView, and the submit button on that webpage looked a bit like the following in code:
<form id="my_submit_button" etc... >
Just call the following:
NSString* javascript = #"document.forms['my_submit_button'].submit();";
[myUIWebView stringByEvaluatingJavaScriptFromString: javascript];
Hope this helps!

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.

Onclick open new window and reload previous page

I trying to have a new window pop up to checkout at Paypal, OK. Problem is that if user goes back to add or take away items and click "checkout" again, the pop up does not work. The only solution I can think of is when customer submits form to check out, the action opens up a new window and reloads the page they were just on. Can this be done or is there another way?
checkoutPayment: ' {payment}',
paypal: '<form target="_blank" id="rcCartForm" action="https://www.paypal.com/cgi-bin/webscr;" method="post">' +