struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adolfo Miguelez" <pell...@hotmail.com>
Subject Re: referencing bean properties in jsps
Date Fri, 16 Aug 2002 11:57:59 GMT

Community prefers ArrayList rather than Vectors since ArrayList methods are 
not synchronized and Vector methods do. Depends on your necessities but 
mostly ArrayList are enough for read only data.

IF you have an ArrayList of beans in your action, you can send it to your 
JSP by:

request.setAttribute("DataList", your_array_list);

or

request.getSession(false).setAttribute("DataList", your_array_list);

and after do the mapping in the Action by:

return mapping.findForward("your_JSP");


In the JSP you can sweep your collection with a logic:iterate tag as:

<logic:iterate name="DataList" id="RowData">
....

      <bean:write name="RowData" property="a_property_of_your_bean"/>

....

</logic:iterate>

With <bean:write> you get the value of properties for each bean, which is 
defined as a local variable inside the logic:iterate (each bean in the 
collection is called RowData in this example).

Hope it helps,

Adolfo

>From: "Fabian Sommer" <fasommer@web.de>
>Reply-To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
>To: <struts-user@jakarta.apache.org>
>Subject: referencing bean properties in jsps
>Date: Fri, 16 Aug 2002 13:44:23 +0200
>
>Hi folks!
>I got problem, I don't really know if it's due to misunderstanding jee
>or anything else.
>
>I got a data-storage-bean, where I've put some data by adding little
>java beans to a vector and presenting this vector to that bean.
>Now I want to retrieve that vector from that bean to fill some table
>rows in a jsp.
>How do get that?
>I try to use the same bean for storing some form data on the same jsp.
>Here some code I use: (I use strutsh as prefix for struts-html.tld)
>
><table border="0">
><strutsh:form action="/rawmat_enter.do" method="POST">
><tr>
><th align="center">ID</th>
><th align="center">Name</th>
><th align="center">Short</th>
></tr>
>HERE I want to put some data rows filled up with data stored in the
>raw-Vector. It's the same form-bean as used in this little code-package.
><%
>	Vector raw = RawMat_Tab.getRawVector();   <-- the getter-method
>of my
>bean for that vector
>%>
><tr>
><td><strutsh:text property="rawname" size="16" maxlength="18"/></td>
><td><strutsh:text property="rawshort" size="4" maxlength="4"/></td>
><td><strutsh:submit /></td>
></tr>
></strutsh:form>
></table>
>
>Any Ideas? Or is it not jee-compliant to use a vector to store data in a
>bean?
>Any help or comment would be fine. Thx!
>Fabian
>
>
>--
>To unsubscribe, e-mail:   
><mailto:struts-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: 
><mailto:struts-user-help@jakarta.apache.org>




<HTML>
      <HEAD>
             <TITLE>Adolfo's signature</TITLE>
      </HEAD>
      <BODY>
             <center><b><em>Adolfo Rodriguez Miguelez</em><b></center>

      </BODY>
      </HTML>





_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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


Mime
View raw message