aspose file tools*
The moose likes Struts and the fly likes struts-2 value stack issue... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts-2 value stack issue..." Watch "struts-2 value stack issue..." New topic
Author

struts-2 value stack issue...

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I have a jsp and action class for it...

inside that i need to populate drop down list which is present in a bean...

The list is a hashmap...



Since I am staying in a different action class how should I include that bean so that I could get that list!

should I put a s:form tag before this to include that bean or can I write a function name in value parameter and return the values.Does this work?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

I couldn't understand your question properly, but why are you using iterator to generate option elements. You can use the select tag of struts to generate a drop down box. If you want the whole list to be available on the next page, then you'll need to put the list as an attribute in session scope or regenerate the list in the next action...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I meant...



I have a bean which contains values in a hash map...

How to populate ?? The value name should be the name of the hash map, but it will look for the hashmap in the action corresponding to this jsp whereas the map is in some other class... how to link that bean inside this jsp so that it can locate the required hashmap??
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

I'm still finding a hard time understanding what you mean, maybe I'm not feeling well .

Anyways, first of all if you use the s:select tag, then you can render the select tag with multiple options directly.

Now what I understand from your statement is that the HashMap which contains the values with which the drop down is to be populated is in an action other than the action which called this JSP. If that is the case, you can call the other action from your JSP using s:action tag. That will put that action on the value stack and thus you'll be able to access the HashMap from it. If I understood it wrong, then please tell me...
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Yes you got it mate and your doing great and that's what i want,but (silly though) where should i write that s:action tag??

can i just simply put it in the body tag??
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

Pradeep Adibatla wrote:where should i write that s:action tag?? can i just simply put it in the body tag??

You need to put the s:action tag in your JSP anywhere before the select tag i.e. before you need the HashMap in your JSP...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts-2 value stack issue...