1> True, but why is it important that is has to be the same collection? I
only care about changes being propagated to the ListItems, I don't care if
they are contained in a Set within the Model or in a List given to the
ListView. In other words, if you are saying, that you have to give the same
List from the Model to the ListView, means you cannot render a Model object
with a Set using a ListView. This is quite a restriction you have to be
aware of then I think. We choosed the Set on purpose to avoid duplicates,
there must be a way to render the contents of a Set using any Repeater
component.
2> Yes, in my code snippet where it says "// getModelObject and save" this
is very I call getModelObject().
Johan Compagner wrote:
>
> 1> because you dont have that detacheable list in the listview?? You
> are just giving a ArrayList directly to the listview
>
> 2> i dont see exactly where you call getModelObject on in onsubmit but
> i guess thats on page? Then it is loaded yes, this has nothing to do
> with the listview model.
>
> On 3/28/08, reikje <[EMAIL PROTECTED]> wrote:
>>
>> I have a rather specific question about a problem I am having. We have a
>> domain object (OperatorSyncConfig) that we need to diplay in a page. That
>> object contain a Set of FunctionSetting objects which I want to render in
>> a
>> ListView. For each ListItem (FunctionSetting) it should be possible to
>> change the timeout value and then with one Form submit save the whole
>> OperatorSyncConfig objects. Here is a snippet of the objects:
>>
>> public class OperatorSyncConfig implements Serializable
>> {
>> private Set<FunctionSetting> m_functionSettings = new
>> LinkedHashSet<FunctionSetting>();
>>
>> public Set<FunctionSetting> getFunctionSettings()
>> {
>> return Collections.unmodifiableSet(new
>> LinkedHashSet<FunctionSetting>(m_functionSettings));
>> }
>>
>> .. no setter method for the set, just single add and remove accessors
>> }
>>
>> public class FunctionSetting implements Serializable
>> {
>> private Long m_timeoutInMilliseconds;
>> .. get and set for that
>> }
>>
>>
>> The WebPage looks in short like that:
>>
>> public class EditOperatorPage extends WebPage
>> {
>> LoadableDetachableModel model = new LoadableDetachableModel() { ...
>> }
>> // load the OperatorSyncConfig
>> setModel(model);
>>
>> Form updateDeleteForm = new Form("updateForm") {
>> @Override
>> protected void onSubmit() {
>> // getModelObject and save
>> }
>> };
>>
>> OperatorSyncConfig operatorSyncConfig = (OperatorSyncConfig)
>> getModelObject();
>> Set<FunctionSetting> settingsAsSet =
>> operatorSyncConfig.getFunctionSettings();
>> List<FunctionSetting> settings = new
>> ArrayList<FunctionSetting>(settingsAsSet);
>>
>> updateDeleteForm.add(new ListView("operatorFunctionsList", settings)
>> {
>> @Override
>> protected void populateItem(ListItem item)
>> {
>> FunctionSetting functionSetting = (FunctionSetting)
>> item.getModelObject();
>>
>> item.add(new TextField("Timeout", new
>> PropertyModel(functionSetting, "timeoutInMilliseconds")));
>> }
>> });
>>
>> ....
>> }
>>
>> The problem is that in the onSubmit of the Form I will always get the
>> "old"
>> version of the OperatorSyncConfig since getPage().getModelObject() in
>> there
>> will trigger LoadableDetachableModel.load() and get the object from the
>> Database. If I debug, I see that the new value for timeoutInMilliseconds
>> is
>> bound properly to the FunctionSetting object in the model of the
>> ListItem.
>> However, the model of the whole ListView contains an ArrayList which
>> itself
>> contains different FunctionSetting objects (not the ones contained in the
>> Page model OperatorSyncConfig.getFunctionSettings()). By different I mean
>> they are equal but different objects in memory.
>>
>> Question is:
>> 1) why are there different FunctionSetting objects in the Page model and
>> the
>> ListView model
>> 2) why does onSubmit() call load() on the DetachableModel if form values
>> have been bound already
>> --
>> View this message in context:
>> http://www.nabble.com/ListView-with-a-Set-instead-of-a-List-tp16349670p16349670.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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]
>
>
>
--
View this message in context:
http://www.nabble.com/ListView-with-a-Set-instead-of-a-List-tp16349670p16418733.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]