• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Saikat Podder
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1211
IntelliJ IDE Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use
 
Saikat Podder
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Sonny,
It worked wonderfully
But apparently the same expression does not work for all types of attributes.
 
bilbono notry
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nobody ?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic