struts logic:iterate tag and setter methods

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"/>
<html:eek:ptions 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.
 
R

rafikfree

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.StickReadingFo­rm">
<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:eek:ptions 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.

je cro que vs est un idéaux
 
D

david.karr

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:eek:ptions 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"?
 
L

Lew

david.karr said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top