You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Mauricio T. Ferraz" <ma...@cilix.com.br> on 2003/11/15 00:23:19 UTC

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???



Re: Generate a Drop-Down ???

Posted by "Mauricio T. Ferraz" <ma...@cilix.com.br>.
I Can“t put script in my code, I have find another way to do it.



----- Original Message -----
From: "Rob van Oostrum" <li...@springwellfarms.ca>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, November 14, 2003 9:28 PM
Subject: RE: Generate a Drop-Down ???


> ehm ...
>
>
> [dropdown list html]
>
> <%
> ProdutoView view = (ProdutoView) session.getAttribute("produtoView");
> ArrayList list = view.getFormatosArquivos();
>
> java.util.Iterator iterator = list.iterator();
> while( iterator.hasNext() ) {
> String format = (String) iterator.next();
> %>
> [list item html]<%= format %>
> <%
> }
> %>
>
> > -----Original Message-----
> > From: Mauricio T. Ferraz [mailto:mauricio.tavares@cilix.com.br]
> > Sent: November 14, 2003 6: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


RE: Generate a Drop-Down ???

Posted by Rob van Oostrum <li...@springwellfarms.ca>.
ehm ...


[dropdown list html]

<%
	ProdutoView view = (ProdutoView) session.getAttribute("produtoView");
	ArrayList list = view.getFormatosArquivos();
	
	java.util.Iterator iterator = list.iterator();
	while( iterator.hasNext() ) {
		String format = (String) iterator.next();
%>
	[list item html]<%= format %>
<%
	}
%>

> -----Original Message-----
> From: Mauricio T. Ferraz [mailto:mauricio.tavares@cilix.com.br]
> Sent: November 14, 2003 6: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


Re: Generate a Drop-Down ???

Posted by Abhijeet Mahalkar <Ab...@indussoft.com>.
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" <br...@houston.rr.com>
To: <st...@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


RE: Generate a Drop-Down ???

Posted by Bryan Hanks <br...@houston.rr.com>.
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