You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeremy Prellwitz <je...@prellwitz.com> on 2002/05/16 18:48:15 UTC
Help!: Dynamic Property Name and JavaScript values
Does anyone know how to include dynamic values for the
name/value pairs inside struts tags?
e.g.
<html:checkbox onclick="monitorCheckBoxes(this.form,<%= i %
>,2)" name="prodActForm" property="property(<%= "c_" + i
= "_2")" />
I am trying to dynamically generate rows of checkboxes
similar to below:
-- --
| | | |
-- --
-- --
| | | |
-- --
-- --
| | | |
-- --
-- --
| | | |
-- --
I have a form bean with a setProperty(String, String) and a
getProperty(String).
I want to dynamically generate the names of the checkboxes so
that the end result is:
formBean.setProperty("c_0_1",<value>);
formBean.setProperty("c_0_2",<value>);
formBean.setProperty("c_1_1",<value>);
formBean.setProperty("c_1_2",<value>);
formBean.setProperty("c_2_1",<value>);
formBean.setProperty("c_2_2",<value>);
formBean.setProperty("c_3_1",<value>);
formBean.setProperty("c_3_2",<value>);
where <value> is the value of the checkbox from the form. Of
course, it would only be called if the checkbox had a value.
But my problem is i can't get the HTML to display correctly.
This for example comes out as:
<html:checkbox onclick="monitorCheckBoxes(this.form,<%= i %
>,2)" name="prodActForm" property="property(xyx)" />
<input type="checkbox" name="property(xyz)" value="on"
onclick="monitorCheckBoxes(this.form,<%= i %>,2)">
As you can see it actuall prints the string: "<%= i %>"
versus the value of "i" that i want.
Can anyone help?
Thanks kindly!
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Help!: Dynamic Property Name and JavaScript values
Posted by Michael Marrotte <ma...@nicusa.com>.
Since Struts tags can't be nested. Nest Struts "dynamic" <bean:write>'s
inside plain HTML tags.
<input type="checkbox" name="prodActForm_<bean:write name="yourName"
property="yourProperty"/>">
I have successfully tackeled this problem from a few different angles...
Let me know if this helps, or not...
Michael Marrotte
-----Original Message-----
From: Jeremy Prellwitz [mailto:jeremy@prellwitz.com]
Sent: Thursday, May 16, 2002 12:48 PM
To: struts-user@jakarta.apache.org
Subject: Help!: Dynamic Property Name and JavaScript values
Does anyone know how to include dynamic values for the
name/value pairs inside struts tags?
e.g.
<html:checkbox onclick="monitorCheckBoxes(this.form,<%= i %
>,2)" name="prodActForm" property="property(<%= "c_" + i
= "_2")" />
I am trying to dynamically generate rows of checkboxes
similar to below:
-- --
| | | |
-- --
-- --
| | | |
-- --
-- --
| | | |
-- --
-- --
| | | |
-- --
I have a form bean with a setProperty(String, String) and a
getProperty(String).
I want to dynamically generate the names of the checkboxes so
that the end result is:
formBean.setProperty("c_0_1",<value>);
formBean.setProperty("c_0_2",<value>);
formBean.setProperty("c_1_1",<value>);
formBean.setProperty("c_1_2",<value>);
formBean.setProperty("c_2_1",<value>);
formBean.setProperty("c_2_2",<value>);
formBean.setProperty("c_3_1",<value>);
formBean.setProperty("c_3_2",<value>);
where <value> is the value of the checkbox from the form. Of
course, it would only be called if the checkbox had a value.
But my problem is i can't get the HTML to display correctly.
This for example comes out as:
<html:checkbox onclick="monitorCheckBoxes(this.form,<%= i %
>,2)" name="prodActForm" property="property(xyx)" />
<input type="checkbox" name="property(xyz)" value="on"
onclick="monitorCheckBoxes(this.form,<%= i %>,2)">
As you can see it actuall prints the string: "<%= i %>"
versus the value of "i" that i want.
Can anyone help?
Thanks kindly!
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>