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

Struts2 key attribute

MaheshS Kumbhar
Ranch Hand

Joined: Sep 24, 2009
Posts: 188
I am a new learner to struts2
I read on struts2 apache site that
To enable the struts2 key attribute to find the properties file, the display of the view page must be the result of executing a Struts 2 Action class.

If the page with key attribute is not the result of execution of struts2 action, then there is one trick given on the site to make this work.
Suppose there is one register.jsp page with the form asking user information and there is use of struts2 key attribute on this page.
and in order to make the key attribute from this page to work it has to be the result of execution of struts2 action.
So instead of using the standard url from index.jsp to go to this register.jsp
We can do it in following way so that register.jsp is the result of execution of struts2 action.

But what i think is, if we do this second way, register.jsp page will work fine but just to make it work we will end up in executing the execute method and other logic written in
as part of execution of action class because after clicking to above link, it will cause to execute the registerInput action. If the action class is written in such a way that it will work on some user submitted form data, then in this case there will not be such form data as we have executed the action in other way and not as part of submission of form

so how to cope with this situation?

I am slow but sure
I agree. Here's the link:
subject: Struts2 key attribute
It's not a secret anymore!