struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abhijeet Mahalkar" <Abhijeet.Mahal...@indussoft.com>
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...

regards
abhijeet




----- Original Message -----
From: "Bryan Hanks" <bryan33@houston.rr.com>
To: <struts-user@jakarta.apache.org>
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" />
  </html:select>

---

Explanation:

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: http://masterdev.dyndns.dk/dev/6.htm

Cheers,
Bryan

-----Original Message-----
From: Mauricio T. Ferraz [mailto:mauricio.tavares@cilix.com.br]
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();

formatosArquivos.add("CSV");

formatosArquivos.add("XML");

formatosArquivos.add("Algorithmics");

ProdutoView produto = new ProdutoView();
produto.setFormatosArquivos(formatosArquivos);

session.setAttribute("produtoView",produto);


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




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



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


Mime
View raw message