File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Calling Action on Pageload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Calling Action on Pageload" Watch "Calling Action on Pageload" New topic

Calling Action on Pageload

Ankit Khandelwal

Joined: Feb 21, 2012
Posts: 13
Hi All

I have a create page and i what i am trying to achieve is , when a user will submit the form , s/he will navigate to the next page where s/he can see the updated data as a List.

Using Struts 2 , Add jsp >> calling an action >> calling method save >> if result success >> navigate to another page >> View List

Where do i mention an action which will call ViewDetails method and on successful return of that method what would i mention in result tag .... i mean will i mention the same page >> ViewDetail.jsp

Please help.

Yogesh Lonkar
Ranch Hand

Joined: Jul 17, 2012
Posts: 94

AFTER the data is saved successfully you can specify in struts.xml to go other action if success like this

note that you need to populate saved data from resource in execute() or which ever method you want in YourDisplayAction class and then access that data in display.jsp

Learning some thing New Every Day
Ankit Khandelwal

Joined: Feb 21, 2012
Posts: 13
Thanks a lot Yogesh

I really like the way you answered my question, it shows that you have good hands on Struts 2

Please keep in touch because i am developing an application and i might face problems in future like this.

Thanks a lot once again for your help.
I agree. Here's the link:
subject: Calling Action on Pageload
It's not a secret anymore!