• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts2: pass static collection parameter

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just use an empty list via OGNL.
 
vik ar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anyone out there knowledgeable on this matter?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic