Oops, solved it myself. I should have used getModel().getObject(null).

I found this out while stepping through the wicket code.
In my opinion, the documentation for IModel.getObject should be
extended. Right now it says:

    /**
     * Gets the model object.
     *
     * @param component
     *            The component which wants to get a model Object
     *
     * @return The model object
     */
    Object getObject(final Component component);

I think it should be something like:

  Gets the model object. If the component passed in is null, the model
object passed at construction of the
  model is passed back. For compound models, the component must be a
nested component of the model.
  Passing in the component to which the model was attached is illegal.

Also, what about the return value. When does it return null and when
does it result in an exception. This is
also not clear from the documentation.

Cheers
  Erik

Erik Brakkee wrote:
> Hi,
>
>
> I have a  form with a compound property model and want to have full
> support for the back button. To this I am already calling
> modelChanging() and modelChanged() on the form before and after the
> change, and debugging through the code I see that indeed the framework
> is creating a copy of my model.  In an early version I stored the model
> (java bean) that I constructed the CompoundPropertyModel with in the
> form, but then versioning does not work, since the bean stored as a
> private instance variable in the Form is not versioned.
>
> Therefore, I am no longer storing the bean in the page but now I am
> having trouble getting the bean from the compound property model.
> In particular:
>
>    getModel().getObject(this); 
>
> throws an exception:
> Caused by: wicket.WicketRuntimeException: No get method defined for
> class: class nl.mycompany.app.dataobjects.EvenementData expression:
> evenementForm
>     at
> wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:324)
>     at
> wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:200)
>     at wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:88)
>     at
> wicket.model.AbstractPropertyModel.onGetObject(AbstractPropertyModel.java:132)
>     at
> wicket.model.AbstractDetachableModel.getObject(AbstractDetachableModel.java:104)
>     ... 47 more
>
>
> How do I solve this problem?
>
> Cheers
>   Erik
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>   


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to