You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by di...@jpmorgan.com on 2006/03/01 22:26:06 UTC

How to display combination of two columns in label of html:option

In my jsp I am using users ArrayList which is collection of User bean on 
server side.
My drop down list works fine as under when I use only one display userNameShort in my example.


                <html:select property="userIdNew">
                        <option value="-1">Choose User...</option>
                        <html:options collection="users" property="userId" 
labelProperty="userNameShort" />\
            </html:select>

Now I want to combine two attributes concatenation in label for e.g. 
userId+"("+userNameShort"+")"

how would I do that ?

Thanks..





This communication is for informational purposes only. It is not intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All market prices,
data and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein 
do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries 
and affiliates.

Re: How to display combination of two columns in label of html:option

Posted by Michael Jouravlev <jm...@gmail.com>.
On 3/1/06, digant.k.joshi@jpmorgan.com <di...@jpmorgan.com> wrote:
> In my jsp I am using users ArrayList which is collection of User bean on
> server side.
> My drop down list works fine as under when I use only one display
> userNameShort in my example.
>
> <html:select property="userIdNew">
>   <option value="-1">Choose User...</option>
>   <html:options collection="users"
>                 property="userId"
>                 labelProperty="userNameShort" />
> </html:select>
>
> Now I want to combine two attributes concatenation in label for e.g.
> userId+"("+userNameShort"+")"
>
> how would I do that ?

Create a read-only property in the User bean that returns
userId+"("+userNameShort"+")". For example:

public class User ... {
  ...
  public String getUserIdAndName() {
    return userId+"("+userNameShort"+")";
  }
}

<html:select property="userIdNew">
  <option value="-1">Choose User...</option>
  <html:options collection="users"
                property="userId"
                labelProperty="userIdAndName" />
</html:select>

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How to display combination of two columns in label of html:option

Posted by Rick Reumann <ri...@gmail.com>.
I don't use the html:options tag but standard jstl with html:option....

<html:select property="userIdNew">
<option value="-1">Choose User...</option>
<c:forEach items="${users}" var="user">
    <html:option value="${user.userId}">
        <c:out value="${user.userId}"/>(<c:out value="${user.userNameShort
}"/>)
    </html:option>
</c:forEach>
</html:select>


On 3/1/06, digant.k.joshi@jpmorgan.com <di...@jpmorgan.com> wrote:
>
> In my jsp I am using users ArrayList which is collection of User bean on
> server side.
> My drop down list works fine as under when I use only one display
> userNameShort in my example.
>
>
>                <html:select property="userIdNew">
>                        <option value="-1">Choose User...</option>
>                        <html:options collection="users" property="userId"
> labelProperty="userNameShort" />\
>            </html:select>
>
> Now I want to combine two attributes concatenation in label for e.g.
> userId+"("+userNameShort"+")"
>
> how would I do that ?
>
> Thanks..
>
>
>
>
>
> This communication is for informational purposes only. It is not intended
> as an offer or solicitation for the purchase or sale of any financial
> instrument or as an official confirmation of any transaction. All market
> prices,
> data and other information are not warranted as to completeness or
> accuracy and
> are subject to change without notice. Any comments or statements made
> herein
> do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
> and affiliates.
>



--
Rick