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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Populating a Dropdown Box" Watch "Populating a Dropdown Box" New topic
Author

Populating a Dropdown Box

Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 88
Hi,

I need to populate a dropdown box in details.jsp from the Details.java action

Details.java has a getter and setter for List areaCodeList
which is used like so in my details.jsp like so
<s:select list="areaCodeList" name="myObj.areacode" label="Area Code" />

Alls fine. But here is where the fun begins

My struts.xml is forwarding on to tiles like so...




My tiles definition is


Since I am forwarding onto a tiles:admin.detail,
detail.jsp dropdown box will not populate as Detail.java action isnt called

Now a way round this would be to change

to

This will call the action

But what happens here is that the details.java execute method returns "SUCCESS" which in turn will forward onto tiles:admin.map

Quite simply
How can I call
tiles:admin.details
and populate the dropdown box in details.jsp at the same time

Is there a way of calling the action and force it to the INPUT result???

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please see UseCodeTags, it really does make things easier to read and figure out.

The canonical Struts 2 mechanism for things like property initialization is to implement the Preparable interface. This works in concert with the "prepare" interceptor and allows us to put repeated initialization code in a single location.

Hope this helps,
Dave
Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 88
Hi David,

Thanks for the very quick reply. I reformatted the original post so its easier on the eye.
I already attempted this. But the problem lies in the struts.xml forwarding....

Assume the below


LoginDetails execute method returns "SUCCESS"
This means the details.action is called

Now when called the associated Java class (the action class) Details.java runs execute() and returns "SUCCESS" , tiles:admin.map is displayed
Instead I want tiles:admin.details to display.

I could set


but does this not mean im stuck in a continous loop.
When a action returns "SUCCESS" I want to forward on to the next step.

details.jsp taht is part of tiles:admin.details
like

so each jsp has a form with the action being the related action in struts.xml
This is so I can do validation on the form.

Does this make my problem clear?

Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 88
basically an action is forwarding onto an action which is forwarding onto another action immediately
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't really know what you're asking.

Any action method can return any string: if you want the input and success results to point to the same thing that's fine.
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
Hi Ally

I think I understand what your issue is, except I don't know anything about tiles. Let me see if I comprehend correctly about what your issue is here

You're trying to go from LoginDetails -> Details (action level) but your Details is returning "SUCCESS" instead of "INPUT"
and from your struts.xml, you want to get to tiles:admin.details (I am assuming tiles is another technology that S2 use for View besides JSP)

So I think in order for anyone else to help you with your problem, you shoud post your Details.java code. Without knowing the logic flow in your action, we never knew why the execute() only return "SUCCESS" instead of "INPUT"

hope this make sense
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Populating a Dropdown Box
 
Similar Threads
Tiles problem in rendering
How to configure tiles with JSF+Struts2 Integration ?
Tiles with runtime attributes - response already commited
Struts1.3 tiles problem
No result defined for action