You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lorenzo Bolzani <l....@gmail.com> on 2008/09/12 11:58:37 UTC
Form values lost on converter error when inside table
Hi,
I'need to display some editable values inside an HTML table.
The form contains both string and numeric values. If I submit an
invalid numeric value an error is reporter but all other values are
lost.
Using a simple form this does not happens, it happens only when we had
the "table part". I think we have done something wrong with the
dataview and the dataProvider but we cannot see what's wrong.
Following this article (we skipped the detachable part)
http://liminescence.blogspot.com/2007/12/wicket-html-table-implementation.html
I defined a very simple DataProvider
protected List readAll() {
return Arrays.asList(new Bean("a", 1), new Bean("b", 2));
}
a simple dataView
@Override
protected void populateItem(Item item) {
Bean bean = (Bean) item.getModelObject();
item.setModel(new CompoundPropertyModel(bean));
item.add(new TextField("rock"));
item.add(new TextField("number"));
}
and added this to a form
final DataView personDataView = new PersonDataView("beanList",
dataProvider);
form.add(personDataView);
This is the markup
<table width="100%" border="0" >
<tr><th>Rock</th>
<th>Number</th></tr>
<tr wicket:id="beanList">
<td >
<input wicket:id="rock" type="text" size="20"
maxlength="5"/><br/>
</td>
<td>
<input wicket:id="number" type="text" size="20"
maxlength="5"/><br/>
</td>
</tr>
</table>
When I type an invalid value for the "number" field the "rock" field
is reset to the default value and the input from the user is lost.
What are we doing wrong?
Thanks, bye
Lorenzo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form values lost on converter error when inside table
Posted by Serkan Camurcuoglu <se...@telenity.com>.
I think you can make a quick test by implementing a simple reuse
strategy which directly returns the existingItems iterator..
Lorenzo Bolzani wrote:
> 2008/9/12 Serkan Camurcuoglu <se...@telenity.com>:
>
>> if you were using a listview, you should have called setReuseItems(true) on
>> it.. Maybe there exists something similar for DataView.. ListView javadoc
>> says:
>>
>> "If you nest a ListView in a Form, ALLWAYS set this property to true, as
>> otherwise validation will not work properly. "
>>
>>
>
> Hi Serkan,
> think you very much for the reply, we looked for something similar but
> we completely missed that.
> I think could be useful to report the same warning in the DataView and
> DataTable javadoc (or maybe just Form).
>
> Anyway in our example we are using a DataView and that method is not present.
> We found a setReuseStrategy both on DataView and on DataTable but none
> of the provided strategies (default and reuseIfEquals) worked.
>
> What is the ReuseStrategy providing a behavior equivalent to
> setReuseItems(true)?
>
> I suspect is ReuseIfModelsEqualStrategy and we have to define a custom
> model with the correct equals but I'm not sure and I'm looking for a
> confirm.
>
>
> Thanks again.
>
> Bye
>
> Lorenzo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form values lost on converter error when inside table
Posted by Lorenzo Bolzani <l....@gmail.com>.
2008/9/12 Igor Vaynberg <ig...@gmail.com>:
> On Fri, Sep 12, 2008 at 5:57 AM, Lorenzo Bolzani <l....@gmail.com> wrote:
>> 2008/9/12 Serkan Camurcuoglu <se...@telenity.com>:
>> I suspect is ReuseIfModelsEqualStrategy and we have to define a custom
>> model with the correct equals but I'm not sure and I'm looking for a
>> confirm.
>
> consider this a confirmation.
>
Ok, we did it!
We wrote a ReuseIfModelObjectIsEqualStrategy that compares
modelObjects. It worked.
Thanks again.
Bye
Lorenzo
P.S.
TGIF :)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form values lost on converter error when inside table
Posted by Igor Vaynberg <ig...@gmail.com>.
On Fri, Sep 12, 2008 at 5:57 AM, Lorenzo Bolzani <l....@gmail.com> wrote:
> 2008/9/12 Serkan Camurcuoglu <se...@telenity.com>:
> I suspect is ReuseIfModelsEqualStrategy and we have to define a custom
> model with the correct equals but I'm not sure and I'm looking for a
> confirm.
consider this a confirmation.
-igor
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form values lost on converter error when inside table
Posted by Lorenzo Bolzani <l....@gmail.com>.
2008/9/12 Serkan Camurcuoglu <se...@telenity.com>:
> if you were using a listview, you should have called setReuseItems(true) on
> it.. Maybe there exists something similar for DataView.. ListView javadoc
> says:
>
> "If you nest a ListView in a Form, ALLWAYS set this property to true, as
> otherwise validation will not work properly. "
>
Hi Serkan,
think you very much for the reply, we looked for something similar but
we completely missed that.
I think could be useful to report the same warning in the DataView and
DataTable javadoc (or maybe just Form).
Anyway in our example we are using a DataView and that method is not present.
We found a setReuseStrategy both on DataView and on DataTable but none
of the provided strategies (default and reuseIfEquals) worked.
What is the ReuseStrategy providing a behavior equivalent to
setReuseItems(true)?
I suspect is ReuseIfModelsEqualStrategy and we have to define a custom
model with the correct equals but I'm not sure and I'm looking for a
confirm.
Thanks again.
Bye
Lorenzo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Form values lost on converter error when inside table
Posted by Serkan Camurcuoglu <se...@telenity.com>.
if you were using a listview, you should have called setReuseItems(true)
on it.. Maybe there exists something similar for DataView.. ListView
javadoc says:
"If you nest a ListView in a Form, ALLWAYS set this property to true, as
otherwise validation will not work properly. "
Lorenzo Bolzani wrote:
> Hi,
> I'need to display some editable values inside an HTML table.
> The form contains both string and numeric values. If I submit an
> invalid numeric value an error is reporter but all other values are
> lost.
>
> Using a simple form this does not happens, it happens only when we had
> the "table part". I think we have done something wrong with the
> dataview and the dataProvider but we cannot see what's wrong.
>
> Following this article (we skipped the detachable part)
>
> http://liminescence.blogspot.com/2007/12/wicket-html-table-implementation.html
>
> I defined a very simple DataProvider
>
> protected List readAll() {
> return Arrays.asList(new Bean("a", 1), new Bean("b", 2));
> }
>
> a simple dataView
>
> @Override
> protected void populateItem(Item item) {
> Bean bean = (Bean) item.getModelObject();
> item.setModel(new CompoundPropertyModel(bean));
> item.add(new TextField("rock"));
> item.add(new TextField("number"));
> }
>
> and added this to a form
>
> final DataView personDataView = new PersonDataView("beanList",
> dataProvider);
> form.add(personDataView);
>
> This is the markup
>
> <table width="100%" border="0" >
> <tr><th>Rock</th>
> <th>Number</th></tr>
> <tr wicket:id="beanList">
> <td >
> <input wicket:id="rock" type="text" size="20"
> maxlength="5"/><br/>
> </td>
> <td>
> <input wicket:id="number" type="text" size="20"
> maxlength="5"/><br/>
> </td>
> </tr>
> </table>
>
> When I type an invalid value for the "number" field the "rock" field
> is reset to the default value and the input from the user is lost.
>
> What are we doing wrong?
>
>
> Thanks, bye
>
> Lorenzo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org