I would think that you need to either use a session- or application-wide
ASO to hold the values.
Right now, the properties that you use to hold them will be cleaned out
again when the page is returned to the page-pool.
That's a mechanism that avoids one user from getting another user's data.
MARK
Mat Gessel wrote:
I have a trivial app which consists of a Form, a Submit and one
TextField wrapped by a For loop. The TextField is bound to a mutable
String wrapper class (Value.java).
Every other time I submit the form the TextField value is dropped. The
TextField updates it's binding, but in the listener method the
property's value is incorrect (and the response).
Some things I noticed:
* this behavior alternates every other submit
* this behavior does not happen if the @For is removed and the field
is bound to values[0].value
* on the 1st submit the field sets the value of the same object
which is a property of the page (see hashcodes in debug output)
* on the 2nd submit the field sets the value of a different object
than the page property. I don't know where it's getting this object.
Is this a bug or am I doing something wrong? Also, is there a better
way to collect the values of fields generated by a for loop?
-= Mat
Home.html
----------------
<html>
<body>
<form jwcid="@Form">
<table>
<tr>
<td
jwcid="@For"
element="td"
source="ognl:values"
value="ognl:currentValue">
<input
jwcid="@TextField"
value="ognl:currentValue.value"/>
</td>
</tr>
</table>
<p><input jwcid="@Submit" listener="listener:onSubmit"/></p>
</form>
</body>
</html>
Home.java
---------------
public abstract class Home extends BasePage implements
PageBeginRenderListener
{
public abstract Value getCurrentValue();
public abstract Value[] getValues();
public abstract void setValues(Value[] values);
public void pageBeginRender(PageEvent event)
{
Value[] values = getValues();
if (values == null)
{
System.out.println("\nHome.pageBeginRender()
{instansiating values}");
values = new Value[] { new Value("a") };
setValues(values);
}
}
public void onSubmit(IRequestCycle cycle)
{
System.out.println("Home.onSubmit() {values[0].value=" +
getValues()[0].getValue() + ", values[0]=" + getValues()[0] + "}");
System.out.flush();
}
}
Value.java
---------------
public class Value implements Serializable
{
private static final long serialVersionUID = 3631215785425922895L;
private String m_value;
public Value(String value)
{
System.out.println("Value.<init>(" + value + ")");
m_value = value;
}
public String getValue()
{
return m_value;
}
public void setValue(String value)
{
System.out.println("Value.setValue(" + value + ") {value=" +
m_value
+ ", this=" + this + "}");
m_value = value;
}
}
Debug output
-------------------
Home.pageBeginRender() {instansiating values}
Value.<init>(a)
Home.pageBeginRender() {instansiating values}
Value.<init>(a)
Value.setValue(b) {value=a, [EMAIL PROTECTED]
Home.onSubmit() {values[0].value=b, [EMAIL PROTECTED]
Home.pageBeginRender() {instansiating values}
Value.<init>(a)
Value.setValue(c) {value=b, [EMAIL PROTECTED]
Home.onSubmit() {values[0].value=a, [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]