File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes struts2: pass static collection parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2: pass static collection parameter" Watch "struts2: pass static collection parameter" New topic
Author

struts2: pass static collection parameter

vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
Hi

I know the following is possible


But what I want to do is pass a empty collection to a select box without having to go through an action class. I have the following code and in MyActionClass all I am doing is setting an empty collection (areas)

struts.xml

jsp page

If I can pass an empty collection parameter then I can avoid having MyActionClass? (The select does eventually get populated via javascript according to client interaction with the html...)

thanks

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Just use an empty list via OGNL.
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
i have two select boxes. when an option in the first one is selected the areas select is updated. when the client hits the submit button validation takes place and if that validation fails it will redirect to the page and should display the areas which were present prior to hitting submit
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
Anyone out there knowledgeable on this matter?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If the appropriate lists are re-populated then there shouldn't be an issue.
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
If I specify

<s:select name="name" list="{}" />

everytime the page is displayed it will display an empty dropdown???
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You said you were populating it with JavaScript: you can't have it both ways.
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
In my last post I was doing what you suggested "Just use an empty list via OGNL" which is not what I want. What I want was clearly specified in my first post. Is anyone else able to provide a code example. cheers
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

In your first post you wrote:But what I want to do is pass a empty collection to a select box without having to go through an action class

But now you're saying you *sometimes* want to pass an empty collection, and sometimes you don't.

That's different.
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
What I require was clearly specified in my first two posts. Those who understand the requirements if you are able to assist with the issue it would be much appreciated. cheers
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

You can either specify an immediate list, or you can load the appropriate list via an action property. The bottom line is that you can't do both; you need to decide which you're going to do. Assuming I don't understand your problem is unlikely to lead to a solution.
vik ar
Ranch Hand

Joined: Jul 31, 2009
Posts: 104
In that case on the intitial load of the page I will have to continue to pass an empty collection via a action class. thanks for the assistance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts2: pass static collection parameter
 
Similar Threads
Using redirect-action
I want to pass the parameter to the same action after submit
struts 2 passing parameter to interceptor
struts 2 passing parameter to interceptor
Struts2- How to pass dynamic parameters from one Action class to another Action class