This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes How to show composite string for listValue attribute in select tag in Struts2 without using iterator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to show composite string for listValue attribute in select tag in Struts2 without using iterator" Watch "How to show composite string for listValue attribute in select tag in Struts2 without using iterator" New topic
Author

How to show composite string for listValue attribute in select tag in Struts2 without using iterator

Saikat Podder
Greenhorn

Joined: Jan 09, 2009
Posts: 5
Hello Friends,
I am new to Struts 2 & I need your little help to clear a confusion,
I want to display a Dropdown menu for Plans/Packages from a list of Plan object(List<Plan>). The plan class has fields like id, name, price etc.
so the code for the dropdown menu would be:



But this only shows only the name of the plan(like "basic", "intermediate" etc.) in the menu, & I want to show some additional info besides the name like "basic : 5$/month", "intermediate : 10$/month" etc.) for that I need to use the price field of the Plan class also in the listValue expression.

I have tried several expressions like listValue="name : price $/month" or listValue="%{name} %{price} $/month" but none of the works.

So for now the only thing working for me is the normal html tag within an iterator.

So is it really not possibly to display composite string as the value of listValue attribute of the select tag? or am I missing something?

Thanks in advance
Saikat
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Use


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Saikat Podder
Greenhorn

Joined: Jan 09, 2009
Posts: 5
Thank you Sonny,
It worked wonderfully
But apparently the same expression does not work for all types of attributes.
bilbono notry
Greenhorn

Joined: Oct 28, 2009
Posts: 3
Hello,

I have a more complex problem on the same topic.
I would like to do the

stuff, but 'name' would be dynamically generated to include country code.

Someone know how I can do that ?

I tried



but it does not work, just print nameEN several times in the select

Thanks
bilbono notry
Greenhorn

Joined: Oct 28, 2009
Posts: 3
Nobody ?
 
Consider Paul's rocket mass heater.
 
subject: How to show composite string for listValue attribute in select tag in Struts2 without using iterator
 
Similar Threads
iterator and <s:radio /> question
<s:select how to fill with key and value
<s:select in <s:iterate tag displaying with comma seperated value
Using Struts 2 Select Tag for dynamic values
Struts 2 Aggregated Lists and Select Boxes