I need to read you response a little better. The choice id is being
submitted with the form the button is on. Now if I have the button on a
different form, can I update the ListChoice by simply adding the
ListChoice to the target?
Warren
-Original Message-
From: Warren Bell [mailto:warr...@clarksnutrition.com]
Sent: Friday, August 21, 2009 12:43 PM
To: users@wicket.apache.org
Subject: RE: LoadableDetachableModel#load() called twice
Ok, I see what is happening. I am using one of the selected choice
objects in the onSubmit and then adding a new choice object to the list.
In order for me to use that selected object, LDM#load() has to be called
first to get it. But how does it know I am going to use that chosen
object if I am not calling getObject()? Now if the selected object is a
member of the page and I don't use the selected object anywhere or add
the ListChoice to the tagret, does the ListChoice choices LDM#load get
called everytime any AjaxButton is pressed regardless of what form it is
on? Or to put it another way, in the situation below what are the
conditions that cause the LDM#load() to be called?
class MyPage extends WebPage
{
private MyObject myListChoiceSelectedObject;
public MyPage()
{
setDefaultModel(new CompoundPropertyModelMyPage(this));
...
someForm.add(new ListChoiceMyObject(myListChoiceSelectedObject,
new LoadableDetachableModelListMyObject(){...}, new
IChoiceRendererMyObject(){...}));
...
}
}
Thanks for your help
Warren
-Original Message-
From: jWeekend [mailto:jweekend_for...@cabouge.com]
Sent: Friday, August 21, 2009 11:37 AM
To: users@wicket.apache.org
Subject: Re: LoadableDetachableModel#load() called twice
Warren,
Unless you are indirectly calling load() yourself, eg by calling
getObject(), on your LDM) during form processing it's Wicket converting
the selected item (by choice id) to the actual choice object, by
matching the id against the list of choices, calling load() on your LDM
in the process.
This implies that you may be submitting the selected value from the list
which is probably unnecessary if that particular submit is designed to
just add a value to the choices' backing model (eg the List or table
etc... you are deriving your list of choices from).
One way to get around your issue would be to have your Add an item to
my list button and, the associated component where you add that new
list object, both on a separate form. Then, after that new form's
submit, your LDM's load() should only be called during any rendering,
which is probably what you want.
Does that do it?
Regards - Cemal
jWeekend
OO Java Technologies, Wicket Training and Development
http://jWeekend.com
Warren Bell-3 wrote:
I have a ListChoice that I add a choice to. I do this in an
AjaxButton#onSubmit(...). The problem is that load() has been called
before onSubmit() and I have to call LoadableDetachableMode#detach()
and have load() called again. This seems like a waste to have load()
called twice in order to get the new choice added to the ListChoice.
Is there a better way of doing this?
Warren
--
View this message in context:
http://www.nabble.com/LoadableDetachableModel-load%28%29-called-twice-tp
25082195p25085222.html
Sent from the Wicket - User mailing list archive at Nabble.com.
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org