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"/>
<html:options 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.
|
|
0
|
|
|
|
Reply
|
trracz (1)
|
4/18/2007 7:55:58 PM |
|
On 18 avr, 21:55, trr...@yahoo.com wrote:
> 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=3D"stickReadingForm"
> type=3D"com.ecrsoft.plugins.ofs.administration.controller.form.StickReadi=
ngFo=ADrm">
> <form-property name=3D"tankChartList"
> type=3D"java.util.TreeMap"/>
> <form-proeprty name=3D"volumeValue" type=3D"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=3D"stickReadingForm" property=3D"tankChartList"
> id=3D"charts" type=3D"java.util.Map.Entry">
> <bean:write name=3D"charts" property=3D"key"/>
> <bean:write name=3D"charts" property=3D"value.tankChart.name"/>
> <html:select name=3D"stickReadingForm" property=3D"volumeValue"
> indexed=3D"true" onchange=3D"updateVolume(this)">
> <bean:define name=3D"charts"
> property=3D"value.tankChart.incrementList" id=3D"incrementCollection"/>
> <html:options collection=3D"incrementCollection" property=3D"volume"
> labelProperty=3D"increment"/>
> </html:select>
> <html:text name=3D"charts" property=3D"value.selectedVolume"
> readonly=3D"true" size=3D"17" indexed=3D"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.
je cro que vs est un id=E9aux
|
|
0
|
|
|
|
Reply
|
rafikfree
|
6/14/2007 11:39:11 AM
|
|
On Apr 18, 12:55 pm, trr...@yahoo.com wrote:> 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"/>> <html:options 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.Would it matter that you're using "form-proeprty" instead of "form-property"?
|
|
0
|
|
|
|
Reply
|
david
|
6/14/2007 2:22:40 PM
|
|
trr...@yahoo.com wrote:>> public class StickReadingForm extends ValidatorActionForm>> {>> private TreeMap tankChartList;>> private String 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>david.karr wrote:> Would it matter that you're using "form-proeprty" instead of "form-property"?Or that the Java code declares "volumeValue" as String but the "strut-config.xml [sic]" declares it as TreeMap?It leads one to wonder if perhaps the actual deployment differs, perhaps significantly, from what the OP avers. If so, it severely limits the help available from the newsgroup. One might derive a lesson here, that it is vital to copy and paste actual text from an SSCCE (how is one's google-fu?) and its output in order to frame a useful request for assistance.Mightn't one?-- Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
6/14/2007 3:37:44 PM
|
|
|
3 Replies
135 Views
(page loaded in 0.184 seconds)
Similiar Articles:7/21/2012 5:43:01 PM
|