This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes html:options multiple labelProperty question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:options multiple labelProperty question" Watch "html:options multiple labelProperty question" New topic

html:options multiple labelProperty question

Lisa Carter

Joined: May 29, 2003
Posts: 25
I have a bean in the request that contians several properties. I want to display all of the values in the labelProperties attribute. ie instead of just showing the First Name in the labelProperty attribute, I'd like to conatenate the values of the row in the bean ie Last Name,FirstName,SSN etc. Is this possible?
Ben Rainville

Joined: Dec 22, 2004
Posts: 8
Not easily, as far as I know. There are two things you could do, however:

1. Write a scriptlet that defines a string as the concatenation of all the things you want (first name, last name, ssn, etc) and use that string as the labelProperty.

2 (Better, in my opinion). Modify your bean so that there is a getLabel() method that returns firstName + lastName + ssn etc. and use labelProperty="label" in the tag.

Hope that helps.
Lisa Carter

Joined: May 29, 2003
Posts: 25
thanks, I just got a chance to read your response. I did the later and it worked beautifully.
subject: html:options multiple labelProperty question
Similar Threads
html:options throws an exception, help please!
Struts:FormBean issue with html:select tag
Problem with html:select
JasperException: Cannot find bean under name contractors
html:options throws error due to labelProperty attribute