aspose file tools*
The moose likes Struts and the fly likes Confirmation page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Confirmation page" Watch "Confirmation page" New topic
Author

Confirmation page

seshagiri veerla
Greenhorn

Joined: Mar 15, 2008
Posts: 16
Hello everyone,

I have a form (in request scope) with submit and cancel
buttons and after pushing either of them I should display
a confirmation dialog ("Are you sure?") and depending on user's
choice I have to perform the actual action 'submit' or 'cancel'
if user clicks 'yes' and have to return to the same page with
form if user clicks 'no'. The need of this confirmation routine
is questionable but this is not the point in this case, the point
is how to preserve everything you have in your request while
making this trip.

I tried to do this in my action which calls confirmation
page and confirmation page itself (as scriplet):

java.util.Enumeration enum = request.getAttributeNames();

while (enum.hasMoreElements()) {
String atName = (String) enum.nextElement();
request.setAttribute(atName, request.getAttribute(atName));
}

But this didn't help because if I click 'no' button (a link
technically speaking, which leads me to the jsp page with form)
I get an error 'No bean found under attribute key userForm'

I would appreciate any suggestion related to this problem.

Thank you for your time.
Seshagiri
Santoshkumar Jeevan Pawar
Greenhorn

Joined: Aug 19, 2006
Posts: 27
Why dont you just use javascript for that,why you want to go on server side for this.
you can write function liki yhis and call it,thats it.Or you want anything else???

function deleteConfirm(operation) {

var answer = confirm("Are you sure,you want to disable f")
if (answer){
var href ="<%=request.getContextPath()%>/dg.do?operation="+operationghfh
document.location.href = href;
}

}
seshagiri veerla
Greenhorn

Joined: Mar 15, 2008
Posts: 16
I am new to Struts and I am struggling on what would
be the best way to do the following:

on several pages, the user can perform actions which
need to be confirmed before being actually performed
(e.g., exiting the application or logging off). The
confirmation page is the same regardless of the calling
point, but if the user cancels, I need to go back to
the previous page. I am not sure how to pass the return
url to the confirmation page, and how to make this
page generic (template tag, read value from session)...
or
I have a form (in request scope) with submit and cancel
buttons and after pushing either of them I should display
a confirmation dialog ("Are you sure?") and depending on user's
choice I have to perform the actual action 'submit' or 'cancel'
if user clicks 'yes' and have to return to the same page with
form if user clicks 'no'. The need of this confirmation routine
is questionable but this is not the point in this case, the point
is how to preserve everything you have in your request while
making this trip.

would anyone have an idea?

Thanks for your help,

Seshagiri
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
You can have a global forward that points to this specific page. In your form, add a string property that will hold the action path. Let the submit button in your form submit to the action that the form property holds.


Visit my blog: http://jnassef.blogspot.com/
seshagiri veerla
Greenhorn

Joined: Mar 15, 2008
Posts: 16
I implementing project with struts 2.x. In this project not used global forward.So i could not do confirmation page. Please give with properly solution with code. actually what is necessary confirmation page


Please reply with code also.

Thanks
Seshagiri
Santoshkumar Jeevan Pawar
Greenhorn

Joined: Aug 19, 2006
Posts: 27
If you want to implement on server side, send one more paramater as operation ,and in your execute action check with if("".equals(operation)) like this and if cancel you can actinMapping.find Forward to same action forward.

And send whatever data with request.setAttribute before you return from execute.
Kazeem Akinrinde
Greenhorn

Joined: Aug 24, 2002
Posts: 21
With struts 2, the solution looks a bit straight forward, you have access to global results definition. But the simplest solution i will advice is to configure:
[code]
<result>/WEB-INF/pages/confirmation.jsp </result>
[code]
for all those places where you need it.It is not much of a work especially if you are still new to struts 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confirmation page
 
Similar Threads
My First Struts App
How to stop user entering a record twice?
How to submit struts form based on user confirmation through javascript
JSP throwing null pointer exception the first time I run it
Do we always need form element to invoke action class?