Still, this is not what I'm asking for.

class Component {
...
        public Component setModel(final IModel model)
        {
...             
                // If a compound model is explicitly set on this component
                if (model instanceof CompoundPropertyModel)
                {
                        // we need to remember this for getModelObject()
                        setFlag(FLAG_HAS_ROOT_MODEL, true);
                }
...     }
}

I don't understand, why in setModel function, the FLAG_HAS_ROOT_MODEL is set only if model is instanceof CompoundPropertyModel.

Should it be
                if (model instanceof ICompoundModel)
                {
                        // we need to remember this for getModelObject()
                        setFlag(FLAG_HAS_ROOT_MODEL, true);
                }
?

Because in your example, the form won't have this flag set unless the MyCompoundModel is derived from CompoundPropertyModel (just implementing ICompoundModel is not enough)

So initModel of the text field won't succeed, because Form has no root model, if MyCompoundModel isn't derived from CompoundPropertyModel.

-Matej

Johan Compagner wrote:
Form form = new Form();
form.setModel(new MyCompoundModel); // set a compound model so it is the root!
TextField tf = new TextField(); // no model!

then tf.initModel() will get the forms model and use it as its own BUT it is not the root.

johan



On 11/14/05, *Matej Knopp* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Sorry, I still don't understand.
    What shoud I do if I want to have my own compound model, that is not
    derived from CompoundPropertyModel? Why is in Component#setModel a
    check, whether the model is instance of CompoundPropertyModel
    instand of
    ICompoundModel?

    -Matej

    Johan Compagner wrote:
     > No because components can have a ICompoundModel but not be the
    root because
     > they got there model from the root. (see initModel())
     >
     > johan
     >
     >
     >
     > On 11/14/05, *Matej Knopp* <[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>>> wrote:
     >
     >     Hi.
     >
     >     In Component class, the flag FLAG_HAS_ROOT_MODEL is set only
    if the
     >     model is CompoundPropertyModel. Why do we have ICompoundModel
    then?
     >
     >     Shouldn't it only check if the model implements ICompoundModel?
     >
     >     -Matej
     >
     >
     >     -------------------------------------------------------
     >     SF.Net email is sponsored by:
     >     Tame your development challenges with Apache's Geronimo App
    Server.
     >     Download
     >     it for free - -and be entered to win a 42" plasma tv or your
    very own
     >     Sony(tm)PSP.  Click here to play:
    http://sourceforge.net/geronimo.php
    <http://sourceforge.net/geronimo.php>
     >     _______________________________________________
     >     Wicket-user mailing list
     >     [email protected]
    <mailto:[email protected]>
     >     <mailto: [email protected]
    <mailto:[email protected]>>
     >     https://lists.sourceforge.net/lists/listinfo/wicket-user
    <https://lists.sourceforge.net/lists/listinfo/wicket-user>
     >
     >



    -------------------------------------------------------
    SF.Net email is sponsored by:
    Tame your development challenges with Apache's Geronimo App Server.
    Download
    it for free - -and be entered to win a 42" plasma tv or your very own
    Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
    _______________________________________________
    Wicket-user mailing list
    [email protected]
    <mailto:[email protected]>
    https://lists.sourceforge.net/lists/listinfo/wicket-user





-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to