• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confirmation page

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
seshagiri veerla
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic