You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martijn Dashorst (JIRA)" <ji...@apache.org> on 2006/11/01 15:58:20 UTC

[jira] Created: (WICKET-27) Make LoadableDetachableModel writable

Make LoadableDetachableModel writable
-------------------------------------

                 Key: WICKET-27
                 URL: http://issues.apache.org/jira/browse/WICKET-27
             Project: Wicket
          Issue Type: Improvement
            Reporter: Martijn Dashorst
             Fix For: 1.3, 2.0


To keep it compatible with current usage:

public final void setObject(Object obj) {
    reload(obj);
    tempModelObject = obj;
}

protected void reload(Object obj) {
    throw new OperationNotSupportedException("Read only model");
}

Subclasses can now implement their own write logic. This is necessary for for instance stand alone dropdownchoice components that need to store their selection.

e.g.

MyPage {
    IModel<SchoolYear> selectedSchoolYear;
    public MyPage() {
        selectedSchoolYear = new HibernateModel<SchoolYear>(SchoolYear.current());
        new SchoolYearDropDownChoice(this, "schoolyear", selectedSchoolYear);
    }
}

If HibernateModel is not writeable then the selected SchoolYear instance would end up in the session.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (WICKET-27) Make LoadableDetachableModel writable

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/WICKET-27?page=all ]

Igor Vaynberg resolved WICKET-27.
---------------------------------

    Fix Version/s:     (was: 2.0)
                       (was: 1.3)
       Resolution: Fixed

since there seems to be a lack of discussion im closing it.

> Make LoadableDetachableModel writable
> -------------------------------------
>
>                 Key: WICKET-27
>                 URL: http://issues.apache.org/jira/browse/WICKET-27
>             Project: Wicket
>          Issue Type: Improvement
>            Reporter: Martijn Dashorst
>
> To keep it compatible with current usage:
> public final void setObject(Object obj) {
>     reload(obj);
>     tempModelObject = obj;
> }
> protected void reload(Object obj) {
>     throw new OperationNotSupportedException("Read only model");
> }
> Subclasses can now implement their own write logic. This is necessary for for instance stand alone dropdownchoice components that need to store their selection.
> e.g.
> MyPage {
>     IModel<SchoolYear> selectedSchoolYear;
>     public MyPage() {
>         selectedSchoolYear = new HibernateModel<SchoolYear>(SchoolYear.current());
>         new SchoolYearDropDownChoice(this, "schoolyear", selectedSchoolYear);
>     }
> }
> If HibernateModel is not writeable then the selected SchoolYear instance would end up in the session.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (WICKET-27) Make LoadableDetachableModel writable

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/WICKET-27?page=comments#action_12446299 ] 
            
Igor Vaynberg commented on WICKET-27:
-------------------------------------

i dont want this in LDM. right now it is a simple model that is made to pull only, which i think is the 90% usecase for it. i can see where you are going as well, so what i would propose is to do the following:

instead of having LDM extend readonlymodel it can implemet IModel directly
it can have a non-final setObject() that throws an UnsupportedOperationException by default

that way you can subclass the LDM and implement what you want - i guess we would need some method for you to access the tempModelObject and set it.

but i guess at that point why not just roll a different imodel alltogether? its pretty simple.

> Make LoadableDetachableModel writable
> -------------------------------------
>
>                 Key: WICKET-27
>                 URL: http://issues.apache.org/jira/browse/WICKET-27
>             Project: Wicket
>          Issue Type: Improvement
>            Reporter: Martijn Dashorst
>             Fix For: 2.0, 1.3
>
>
> To keep it compatible with current usage:
> public final void setObject(Object obj) {
>     reload(obj);
>     tempModelObject = obj;
> }
> protected void reload(Object obj) {
>     throw new OperationNotSupportedException("Read only model");
> }
> Subclasses can now implement their own write logic. This is necessary for for instance stand alone dropdownchoice components that need to store their selection.
> e.g.
> MyPage {
>     IModel<SchoolYear> selectedSchoolYear;
>     public MyPage() {
>         selectedSchoolYear = new HibernateModel<SchoolYear>(SchoolYear.current());
>         new SchoolYearDropDownChoice(this, "schoolyear", selectedSchoolYear);
>     }
> }
> If HibernateModel is not writeable then the selected SchoolYear instance would end up in the session.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira