struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abhijeet Mahalkar" <>
Subject Re: Generate a Drop-Down ???
Date Tue, 18 Nov 2003 08:19:20 GMT
rather than putting it into session keep it in pageContext object ...
pageContext.setAttribute("produtoView", formatosArquivos);

this works definitely...
rest is ok..

hope this may help you...


----- Original Message -----
From: "Bryan Hanks" <>
To: <>
Sent: Tuesday, November 18, 2003 10:31 AM
Subject: RE: Generate a Drop-Down ???

There's a very easy way to generate a drop-down. From your example, I'm not
sure what ProdutoView does, so I'm going to assume you want to only create a
drop-down of "CSV" and "XML".

Forgive me for starting over, but there is a very easy way to do what you
want, but you must modify you ArrayList a bit.

In the action:

ArrayList formatosArquivos = new ArrayList();
formatosArquivos.add( new org.apache.struts.util.LabelValueBean( "CSV", "20"
) );
formatosArquivos.add( new org.apache.struts.util.LabelValueBean( "XML", "40"
) );
session.setAttribute("produtoView", formatosArquivos);


In the JSP:

  <html:select property="product_value" >
    <html:options collection="produtoView" property="value"
labelProperty="label" />



Org.apache.struts.util.LabelValueBean takes two arguments: label, value.
These are assigned as "label" and "value", respectively (obvious, no?).
When the JSP runs html:options, it creates a drop-down with labels
labelProperty (="label") and corresponding values property (="value"). The
selected value is returned in the html:select property (="product_value").

In this example, if the user selects "CSV", then product_value=20.

See also:


-----Original Message-----
From: Mauricio T. Ferraz []
Sent: Friday, November 14, 2003 5:23 PM
To: Struts Users Mailing List
Subject: Generate a Drop-Down ???

I put the bean on the method execute on myAction

ArrayList formatosArquivos = new ArrayList();




ProdutoView produto = new ProdutoView();


So, How I generate a drop-down list on the next Jsp page???

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message