You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Madala, Srinivasa" <Sr...@blr.hpsglobal.com> on 2003/09/16 07:37:58 UTC
Handling of n number of text boxes at runtime
Hi folks,
I am having trouble with my JSP page.The jsp is designed in such a
way that it can generate n number of text boxes at runtime.So I can't have
either ActionForm or DynaActionForm which are predefined based on a list of
properties enumerated in either the Form bean or the Struts configuration
file and they utilize the properties at the initialization time.I got to
collect input values from all these n text boxes when I submit the page.Does
anyone have a clue how to handle this in Struts?Can anyone help me??
Thanks in advance,
Srinivas
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Handling of n number of text boxes at runtime
Posted by Jason Lea <ja...@kumachan.net.nz>.
Madala, Srinivasa wrote:
> Hi folks,
> I am having trouble with my JSP page.The jsp is designed in such a
> way that it can generate n number of text boxes at runtime.So I can't have
> either ActionForm or DynaActionForm which are predefined based on a list of
> properties enumerated in either the Form bean or the Struts configuration
> file and they utilize the properties at the initialization time.I got to
> collect input values from all these n text boxes when I submit the page.Does
> anyone have a clue how to handle this in Struts?Can anyone help me??
>
> Thanks in advance,
> Srinivas
You can use a map-backed ActionForm eg
public class MyForm extends ActionForm {
protected Map map=new HashMap();
public Object getValue(String key) {
return map.get(key);
}
public void setValue(String key, Object value) {
map.put(key, value);
}
}
As for the JSP page you need to specify the property values like so:
<html:text property="value(key)" />
So if you wanted 3 fields called name, description and quantity you
would use
<html:text property="value(name)" />
<html:text property="value(description)" />
<html:text property="value(quantity)" />
or create some fields in a loop using JSTL and Struts-EL tags
<c:forEach var=”i” begin=”100” end=”110”>
<html:text property="value(${i})" />
</c:forEach>
--
Jason Lea
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org