This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts2: pass static collection parameter

 
vik ar
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use an empty list via OGNL.
 
vik ar
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone out there knowledgeable on this matter?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the appropriate lists are re-populated then there shouldn't be an issue.
 
vik ar
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I specify

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

everytime the page is displayed it will display an empty dropdown???
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said you were populating it with JavaScript: you can't have it both ways.
 
vik ar
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...

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
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic