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]

Reply via email to