T
trracz
I have struts producing a page containing the contents of a TreeMap,
but when the page is submitted, the setter method I need to be called
is not called. Here is the class structure I am using. I will only
include what is necessary so I can keep this as brief as possible. If
more information is needed, I will gladly provide it.
public class TankChart
{
private String name;
private ArrayList incrementList; //contains Increment objects
//getter and setter methods for both of these.
}
public class Increment
{
private String incrementUnit;
private String volume;
//getter and setter methods for both of these.
}
public class TankChartBean
{
private TankChart tankChart;
private String selectedVolume;
//getter and setter methods for both of these.
}
My ActionForm class is as follows:
public class StickReadingForm extends ValidatorActionForm
{
private TreeMap tankChartList;
private String volumeValue;
public ActionErrors validate(ActionMapping actionMapping,
HttpServletRequest httpServletRequest)
{
//validate
}
public void reest(ActionMapping actionMapping, HttpServletRequest
httpServletRequest)
{
//populate the tankChartList TreeMap with TankChartBean objects.
}
//getter and setter methods for tankChartList and volumeValue
}
In my strut-config.xml file:
<form-bean name="stickReadingForm"
type="com.ecrsoft.plugins.ofs.administration.controller.form.StickReadingForm">
<form-property name="tankChartList"
type="java.util.TreeMap"/>
<form-proeprty name="volumeValue" type="java.util.TreeMap"/</form-bean>
And finally, the portion of my jsp page. I'm going to leave out the
table tags I'm using to organize the page. I'll just put the struts
tags.
<logic:iterate name="stickReadingForm" property="tankChartList"
id="charts" type="java.util.Map.Entry">
<bean:write name="charts" property="key"/>
<bean:write name="charts" property="value.tankChart.name"/>
<html:select name="stickReadingForm" property="volumeValue"
indexed="true" onchange="updateVolume(this)">
<bean:define name="charts"
property="value.tankChart.incrementList" id="incrementCollection"/>
<htmlptions collection="incrementCollection" property="volume"
labelProperty="increment"/>
</html:select>
<html:text name="charts" property="value.selectedVolume"
readonly="true" size="17" indexed="true"/>
</logic:iterate>
The volumeValue property is not ever used, but I needed a property to
use in the struts select tag.
The onchange event on the select tag takes the value of the selected
option and puts it in the text field. I need the setSelectedVolume
setter on the TankChartBean to be invoked upon submission of the page
with the value in the text field, but the setter method never gets
called. When loading the page, the getter method is called, so it
seems that struts is finding what it needs.
If anybody could help with this, I would be greatly appreciate it.
thank you.
but when the page is submitted, the setter method I need to be called
is not called. Here is the class structure I am using. I will only
include what is necessary so I can keep this as brief as possible. If
more information is needed, I will gladly provide it.
public class TankChart
{
private String name;
private ArrayList incrementList; //contains Increment objects
//getter and setter methods for both of these.
}
public class Increment
{
private String incrementUnit;
private String volume;
//getter and setter methods for both of these.
}
public class TankChartBean
{
private TankChart tankChart;
private String selectedVolume;
//getter and setter methods for both of these.
}
My ActionForm class is as follows:
public class StickReadingForm extends ValidatorActionForm
{
private TreeMap tankChartList;
private String volumeValue;
public ActionErrors validate(ActionMapping actionMapping,
HttpServletRequest httpServletRequest)
{
//validate
}
public void reest(ActionMapping actionMapping, HttpServletRequest
httpServletRequest)
{
//populate the tankChartList TreeMap with TankChartBean objects.
}
//getter and setter methods for tankChartList and volumeValue
}
In my strut-config.xml file:
<form-bean name="stickReadingForm"
type="com.ecrsoft.plugins.ofs.administration.controller.form.StickReadingForm">
<form-property name="tankChartList"
type="java.util.TreeMap"/>
<form-proeprty name="volumeValue" type="java.util.TreeMap"/</form-bean>
And finally, the portion of my jsp page. I'm going to leave out the
table tags I'm using to organize the page. I'll just put the struts
tags.
<logic:iterate name="stickReadingForm" property="tankChartList"
id="charts" type="java.util.Map.Entry">
<bean:write name="charts" property="key"/>
<bean:write name="charts" property="value.tankChart.name"/>
<html:select name="stickReadingForm" property="volumeValue"
indexed="true" onchange="updateVolume(this)">
<bean:define name="charts"
property="value.tankChart.incrementList" id="incrementCollection"/>
<htmlptions collection="incrementCollection" property="volume"
labelProperty="increment"/>
</html:select>
<html:text name="charts" property="value.selectedVolume"
readonly="true" size="17" indexed="true"/>
</logic:iterate>
The volumeValue property is not ever used, but I needed a property to
use in the struts select tag.
The onchange event on the select tag takes the value of the selected
option and puts it in the text field. I need the setSelectedVolume
setter on the TankChartBean to be invoked upon submission of the page
with the value in the text field, but the setter method never gets
called. When loading the page, the getter method is called, so it
seems that struts is finding what it needs.
If anybody could help with this, I would be greatly appreciate it.
thank you.