Hi,
I *guess* that the html:xxxx tags require a form bean (please correct me if
this is wrong) so they won't work with dynamically created page elements
like input text fields.
I did the following and it works, got the idea from Scott Walter (thanks) -
see http://www.mail-archive.com/struts-user@jakarta.apache.org/msg06972.html
There may be a better solution to this, if there is, I would like to know.
Background: "dbconnection" is a bean I use to keep the session's database
connection, and other objects. wpLaborEntries is a vector holding objects of
type WpLabor.
In my jsp page I create input text fields like this:
<FORM METHOD="POST" ACTION="UpdateWoplan.do">
<% int i=0; %>
<input type="submit" value="Update_Fields">
<table border="1" cellpadding="0" cellspacing="0" align="center">
<logic:iterate name="dbconnection" property="wpLaborEntries"
id="wpl" type="com.tz.maximo.woplan.WpLabor" >
<tr>
<td><INPUT TYPE="text" NAME="<%="craft"+i%>" size="5"
value="<bean:write name="wpl" property="craftqty"/>"></td>
<td><INPUT TYPE="text" NAME="<%="lhrs"+i%>" size="5"
value="<bean:write name="wpl" property="laborhrs"/>"></td>
<td><INPUT TYPE="text" NAME="<%="w1"+i%>" size="5"
value="<bean:write name="wpl" property="wpl1"/>"></td>
<td><INPUT TYPE="text" NAME="<%="w2"+i%>" size="5"
value="<bean:write name="wpl" property="wpl2"/>"></td>
</tr>
<% i++; %>
</logic:iterate>
</table>
</FORM>
So, the key point is, giving a "consistent" name for each input text field.
And, in my action class, I get the values like this:
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
HttpSession session = request.getSession();
OracleConnBean
dbconn=(OracleConnBean)session.getAttribute("dbconnection");
for(int i=0;i<dbconn.getWpLaborEntries().size();i++){
WpLabor wplx=(WpLabor)dbconn.getWpLaborEntries().get(i);
if(request.getParameter("craft"+i)!=null)
wplx.craftqty=request.getParameter("craft"+i);
if(request.getParameter("lhrs"+i)!=null)
wplx.laborhrs=request.getParameter("lhrs"+i);
if(request.getParameter("w1"+i)!=null)
wplx.wpl1=request.getParameter("w1"+i);
if(request.getParameter("w2"+i)!=null)
wplx.wpl2=request.getParameter("w2"+i);
}
dbconn.updateValues();
if (dbconn.successfulQuery=="true") {
return mapping.findForward("success");
}
else {
return mapping.findForward("failure");
}
}
Hope this helps (and it is clear!)...
Turgay.
>From: Richard Murray Subject: How do you use indexed properties with
>html:input? Date: Tue, 08 May 2001 08:44:41 -0700
--------------------------------------------------------------------------------
>Hi,
>I've got the following property:
> String[] data.
>I want to iterate the array and display each String in a text input >field
>in
>a table. I can get the data to display using iterate and a bean:write >tag
>as
>follows:
><struts_logic:iterate id="element" name="testGrid" property="data" >
> <td><struts_bean:write name="element" /></td>
></struts_logic:iterate>
>I can't get it working with a text input field ( html:text ). I've >tried
>the following and get javax.servlet.jsp.JspException: No getter method >for
>property element of bean org.apache.struts.taglib.html.BEAN
>I want to use property="data", but how can I can specify which element >of
>the array to output and save on an update?
><struts_logic:iterate id="element" name="testGrid" property="data" >
> <td><struts_html:text property="element" /></td>
></struts_logic:iterate>
>Hope someone can help.
>Richard.
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.