You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ayodeji Aladejebi <al...@gmail.com> on 2007/10/20 16:54:51 UTC

On Using Models (Again)

Greetings,
Please I have some further questions to ask about models.

LoadableDetachableModel cannot be used as a CompoundPropertyModel obviously

meaning that if I load an Object with LoadableDetachableModel , I cant
simple pass the LoadableDetachableModel to a Label so that the Label can use
its id to resolve the value,

Which means I have to first get the Object from the LoadableDetachableModel
before wrapping it into CompoundPropertyModel again or a PropertyModel

Please help me out;

class MyData {

Long id;
String name;
String address;
String info;

}

class MyDataModel extends LoadableDetachableModel {
Long id;

public Object load(){
 return dao.getData(id);
}
}

MyDataModel mymodel = ...;
Label nameLabel = new Label("name", mymodel);
Label addressLabel = new Label("address, mymodel);
Label infoLabel = new Label("info", mymodel);

because i see so many codes like this:

 Label label = new Label("name", new AbstractReadOnlyModel() {

     public Object getObject(Component component) {
         return someobject.getName();
     }
 });
1.  why create another Model
2. to retreive my someobject from another model to use in another model just
to display does yet seem nice to me

so why can that single instance of LoadableDetachableModel which is a
readonly model be very handy for so many Label components knowing fully well
that Websites are filled with labels loading from a Data Object.

shoot me somebody :)

am still using 1.2.6 please, is it time to move to 1.3?

Re: On Using Models (Again)

Posted by Ayodeji Aladejebi <al...@gmail.com>.
wonderful!, it was the javadoc that confused me since it wrote Object and
there is no other constuctor for IModel


On 10/20/07, Johan Compagner <jc...@gmail.com> wrote:
>
> new Compoundpropertymodel(new Loadabledetachablemodel(yourdbobject))
>
> so just wrap it and then use it as compound
>
> On 10/20/07, Ayodeji Aladejebi <al...@gmail.com> wrote:
> > Greetings,
> > Please I have some further questions to ask about models.
> >
> > LoadableDetachableModel cannot be used as a CompoundPropertyModel
> obviously
> >
> > meaning that if I load an Object with LoadableDetachableModel , I cant
> > simple pass the LoadableDetachableModel to a Label so that the Label can
> use
> > its id to resolve the value,
> >
> > Which means I have to first get the Object from the
> LoadableDetachableModel
> > before wrapping it into CompoundPropertyModel again or a PropertyModel
> >
> > Please help me out;
> >
> > class MyData {
> >
> > Long id;
> > String name;
> > String address;
> > String info;
> >
> > }
> >
> > class MyDataModel extends LoadableDetachableModel {
> > Long id;
> >
> > public Object load(){
> >  return dao.getData(id);
> > }
> > }
> >
> > MyDataModel mymodel = ...;
> > Label nameLabel = new Label("name", mymodel);
> > Label addressLabel = new Label("address, mymodel);
> > Label infoLabel = new Label("info", mymodel);
> >
> > because i see so many codes like this:
> >
> >  Label label = new Label("name", new AbstractReadOnlyModel() {
> >
> >      public Object getObject(Component component) {
> >          return someobject.getName();
> >      }
> >  });
> > 1.  why create another Model
> > 2. to retreive my someobject from another model to use in another model
> just
> > to display does yet seem nice to me
> >
> > so why can that single instance of LoadableDetachableModel which is a
> > readonly model be very handy for so many Label components knowing fully
> well
> > that Websites are filled with labels loading from a Data Object.
> >
> > shoot me somebody :)
> >
> > am still using 1.2.6 please, is it time to move to 1.3?
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: On Using Models (Again)

Posted by Johan Compagner <jc...@gmail.com>.
new Compoundpropertymodel(new Loadabledetachablemodel(yourdbobject))

so just wrap it and then use it as compound

On 10/20/07, Ayodeji Aladejebi <al...@gmail.com> wrote:
> Greetings,
> Please I have some further questions to ask about models.
>
> LoadableDetachableModel cannot be used as a CompoundPropertyModel obviously
>
> meaning that if I load an Object with LoadableDetachableModel , I cant
> simple pass the LoadableDetachableModel to a Label so that the Label can use
> its id to resolve the value,
>
> Which means I have to first get the Object from the LoadableDetachableModel
> before wrapping it into CompoundPropertyModel again or a PropertyModel
>
> Please help me out;
>
> class MyData {
>
> Long id;
> String name;
> String address;
> String info;
>
> }
>
> class MyDataModel extends LoadableDetachableModel {
> Long id;
>
> public Object load(){
>  return dao.getData(id);
> }
> }
>
> MyDataModel mymodel = ...;
> Label nameLabel = new Label("name", mymodel);
> Label addressLabel = new Label("address, mymodel);
> Label infoLabel = new Label("info", mymodel);
>
> because i see so many codes like this:
>
>  Label label = new Label("name", new AbstractReadOnlyModel() {
>
>      public Object getObject(Component component) {
>          return someobject.getName();
>      }
>  });
> 1.  why create another Model
> 2. to retreive my someobject from another model to use in another model just
> to display does yet seem nice to me
>
> so why can that single instance of LoadableDetachableModel which is a
> readonly model be very handy for so many Label components knowing fully well
> that Websites are filled with labels loading from a Data Object.
>
> shoot me somebody :)
>
> am still using 1.2.6 please, is it time to move to 1.3?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org