This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes retrieve value of a field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "retrieve value of a field" Watch "retrieve value of a field" New topic
Author

retrieve value of a field

Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
Hi,

I am using DynaActionForm. I am creating a bean of size 10 an iterating it over in my jsp to create 10 text fields. My bean contains 4 fields.

So basically there are 4 columns(Prod Desc, Nett Price, Quantity and UOM) in a row and there are 10 such rows. UOM is one such column which is a drop down.

What i want is: If the user selects any value from the UOM drop down then all the 10 UOM text fields should be filled with the value selected.

struts-config :
<form-bean name="purchaseOrderBeanForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="lines" type="ActionForm.AddPOBean[]" size="10" />
<form-property name="selected" type="java.lang.String" />
<form-property name="arrCustID" type="java.util.ArrayList" />
<form-property name="UOM" type="java.lang.String" />
<form-property name="POB2B" type="java.lang.String" />
<form-property name="POTX" type="java.lang.String" />
<form-property name="PONO" type="java.lang.String" />
</form-bean>

my jsp:

<tr>
<td >S/No.</td>
<td > Product Description</td>
<td >Nett Price (Without Tax)</td>
<td>Quantity</td>
<td>  UOM </td>
<td><html:select property="UOM" onchange="changeValue(this.value);">
<htmlption value="nos."></htmlption>
<htmlption value="kg"></htmlption>
</html:select>
</td>
</tr>
<% int i = 1; %>
<logic:iterate id="lines" name="purchaseOrderBeanForm" property="lines">
<tr>
<td><%=i %></td>
<td ><html:text indexed="true" name="lines" property="POD"/></td>
<td ><html:text indexed="true" name="lines" property="PON"/></td>
<td><html:text indexed="true" name="lines" property="POQ" size="6"/></td>
<td></td>
<td><html:text indexed="true" name="lines" property="UOM1" size="4" value="nos."/></td>
</tr>
<% i++; %>
</logic:iterate>


my function:
function changeValue(value)
{
var weight = value;
alert(weight);
alert(document.purchaseOrderBeanForm.lines[0].UOM1.value);

}

I am not getting the 2nd alert


Thanks.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

So this is a JavaScript, not Struts, question?

JavaScript debugging is usually pretty easy using Firebug.
Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
David Newton wrote:So this is a JavaScript, not Struts, question?

JavaScript debugging is usually pretty easy using Firebug.


Hi,
You can say a mix of both. Since it involves dyna action form i thought to put it in struts.

Firebug? whats this? I am using eclipse.

Can you help me out please

Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

LMGTFY
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: retrieve value of a field