You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Manuel Corrales <ma...@gmail.com> on 2008/06/04 18:27:26 UTC

Contructor model

Hi, let assume i have a class with no empty constructors (at least no
publics). And i want to use a wicket page to instantiate this class. It is
possible to create a model for this, so i dont have to use another object or
add setters. I dont know if i made myself clear. Please feel free to ask.

Thanks in advance!

Regards.

Re: Contructor model

Posted by Manuel Corrales <ma...@gmail.com>.
I will try that, thanks!

On Thu, Jun 5, 2008 at 11:25 AM, Gwyn Evans <gw...@gmail.com> wrote:

> In which case, maybe something along the lines of...
>
> MyPage() {
>  displayedName = "";
>  setModel(new CompoundPropertyModel(new Customer(displayedName));
>  Form form = new Form() {
>    void onSubmit() {
>      Customer customer = (Customer)getModelObject();
>      if (!displayedName.equals(customer.getName()) {
>        setModelObject(new Customer(customer.getName()));
>      } else {
>      ...
>      }
>  }
>  add(form);
>  form.add(new TextField("name"));
>  ...
>
> /Gwyn
>
> On Thu, Jun 5, 2008 at 3:09 PM, Manuel Corrales
> <ma...@gmail.com> wrote:
> > Half way there :)
> >
> > public class MyPage extends WebPage {
> >  public MyPage(String name) {
> >   setModel(new Model(new Customer(name));
> >
> > that what i want, but instead of having name as a parameter on the page
> > constructor, i would like to have it from the same form the other
> Customer
> > data is being filled.
> >
> >
> > On Thu, Jun 5, 2008 at 10:40 AM, Gwyn Evans <gw...@gmail.com>
> wrote:
> >
> >> Are you looking for something like:
> >>
> >> public class MyPage extends WebPage {
> >>  public MyPage(String name) {
> >>    setModel(new Model(new Customer(name));
> >>    ...
> >>
> >> /Gwyn
> >>
> >> On Thu, Jun 5, 2008 at 2:22 PM, Manuel Corrales
> >> <ma...@gmail.com> wrote:
> >> > Hi, i will rephrase. I have a class Customer on my domain, and
> Customer
> >> do
> >> > not have a default constructor. Lets assume Customer have a
> constructor
> >> with
> >> > a String:
> >> >
> >> > public class Customer {
> >> >   Customer(String name) {
> >> >       ...
> >> >   }
> >> > }
> >> >
> >> > It is possible to create a wicket model, to create a new instance of
> >> > Customer? I mean, if i am not getting it wrong the wicket model use
> >> > accessors (get, set) to "fill" the objects, so how can i do to use the
> >> > Customer constructor from a wicket model?
> >> >
> >> > On Wed, Jun 4, 2008 at 5:41 PM, Maurice Marrink <ma...@gmail.com>
> >> wrote:
> >> >
> >> >> What do you mean?
> >> >> If your page accepts a certain model in its constructor you can do
> >> >> with it whatever you want.
> >> >> Any page (with or without empty constructor) can be created from
> >> >> within another page. Although typically you will do this on a link
> >> >> click or form submit.
> >> >> Just do setResponsePage(new MyPage(whatever_args_here);
> >> >>
> >> >> Maurice
> >> >>
> >> >> On Wed, Jun 4, 2008 at 6:27 PM, Manuel Corrales
> >> >> <ma...@gmail.com> wrote:
> >> >> > Hi, let assume i have a class with no empty constructors (at least
> no
> >> >> > publics). And i want to use a wicket page to instantiate this
> class.
> >> It
> >> >> is
> >> >> > possible to create a model for this, so i dont have to use another
> >> object
> >> >> or
> >> >> > add setters. I dont know if i made myself clear. Please feel free
> to
> >> ask.
> >> >> >
> >> >> > Thanks in advance!
> >> >> >
> >> >> > Regards.
> >> >> >
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Contructor model

Posted by Gwyn Evans <gw...@gmail.com>.
In which case, maybe something along the lines of...

MyPage() {
  displayedName = "";
  setModel(new CompoundPropertyModel(new Customer(displayedName));
  Form form = new Form() {
    void onSubmit() {
      Customer customer = (Customer)getModelObject();
      if (!displayedName.equals(customer.getName()) {
        setModelObject(new Customer(customer.getName()));
      } else {
      ...
      }
  }
  add(form);
  form.add(new TextField("name"));
  ...

/Gwyn

On Thu, Jun 5, 2008 at 3:09 PM, Manuel Corrales
<ma...@gmail.com> wrote:
> Half way there :)
>
> public class MyPage extends WebPage {
>  public MyPage(String name) {
>   setModel(new Model(new Customer(name));
>
> that what i want, but instead of having name as a parameter on the page
> constructor, i would like to have it from the same form the other Customer
> data is being filled.
>
>
> On Thu, Jun 5, 2008 at 10:40 AM, Gwyn Evans <gw...@gmail.com> wrote:
>
>> Are you looking for something like:
>>
>> public class MyPage extends WebPage {
>>  public MyPage(String name) {
>>    setModel(new Model(new Customer(name));
>>    ...
>>
>> /Gwyn
>>
>> On Thu, Jun 5, 2008 at 2:22 PM, Manuel Corrales
>> <ma...@gmail.com> wrote:
>> > Hi, i will rephrase. I have a class Customer on my domain, and Customer
>> do
>> > not have a default constructor. Lets assume Customer have a constructor
>> with
>> > a String:
>> >
>> > public class Customer {
>> >   Customer(String name) {
>> >       ...
>> >   }
>> > }
>> >
>> > It is possible to create a wicket model, to create a new instance of
>> > Customer? I mean, if i am not getting it wrong the wicket model use
>> > accessors (get, set) to "fill" the objects, so how can i do to use the
>> > Customer constructor from a wicket model?
>> >
>> > On Wed, Jun 4, 2008 at 5:41 PM, Maurice Marrink <ma...@gmail.com>
>> wrote:
>> >
>> >> What do you mean?
>> >> If your page accepts a certain model in its constructor you can do
>> >> with it whatever you want.
>> >> Any page (with or without empty constructor) can be created from
>> >> within another page. Although typically you will do this on a link
>> >> click or form submit.
>> >> Just do setResponsePage(new MyPage(whatever_args_here);
>> >>
>> >> Maurice
>> >>
>> >> On Wed, Jun 4, 2008 at 6:27 PM, Manuel Corrales
>> >> <ma...@gmail.com> wrote:
>> >> > Hi, let assume i have a class with no empty constructors (at least no
>> >> > publics). And i want to use a wicket page to instantiate this class.
>> It
>> >> is
>> >> > possible to create a model for this, so i dont have to use another
>> object
>> >> or
>> >> > add setters. I dont know if i made myself clear. Please feel free to
>> ask.
>> >> >
>> >> > Thanks in advance!
>> >> >
>> >> > Regards.
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

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


Re: Contructor model

Posted by Manuel Corrales <ma...@gmail.com>.
Half way there :)

public class MyPage extends WebPage {
 public MyPage(String name) {
   setModel(new Model(new Customer(name));

that what i want, but instead of having name as a parameter on the page
constructor, i would like to have it from the same form the other Customer
data is being filled.


On Thu, Jun 5, 2008 at 10:40 AM, Gwyn Evans <gw...@gmail.com> wrote:

> Are you looking for something like:
>
> public class MyPage extends WebPage {
>  public MyPage(String name) {
>    setModel(new Model(new Customer(name));
>    ...
>
> /Gwyn
>
> On Thu, Jun 5, 2008 at 2:22 PM, Manuel Corrales
> <ma...@gmail.com> wrote:
> > Hi, i will rephrase. I have a class Customer on my domain, and Customer
> do
> > not have a default constructor. Lets assume Customer have a constructor
> with
> > a String:
> >
> > public class Customer {
> >   Customer(String name) {
> >       ...
> >   }
> > }
> >
> > It is possible to create a wicket model, to create a new instance of
> > Customer? I mean, if i am not getting it wrong the wicket model use
> > accessors (get, set) to "fill" the objects, so how can i do to use the
> > Customer constructor from a wicket model?
> >
> > On Wed, Jun 4, 2008 at 5:41 PM, Maurice Marrink <ma...@gmail.com>
> wrote:
> >
> >> What do you mean?
> >> If your page accepts a certain model in its constructor you can do
> >> with it whatever you want.
> >> Any page (with or without empty constructor) can be created from
> >> within another page. Although typically you will do this on a link
> >> click or form submit.
> >> Just do setResponsePage(new MyPage(whatever_args_here);
> >>
> >> Maurice
> >>
> >> On Wed, Jun 4, 2008 at 6:27 PM, Manuel Corrales
> >> <ma...@gmail.com> wrote:
> >> > Hi, let assume i have a class with no empty constructors (at least no
> >> > publics). And i want to use a wicket page to instantiate this class.
> It
> >> is
> >> > possible to create a model for this, so i dont have to use another
> object
> >> or
> >> > add setters. I dont know if i made myself clear. Please feel free to
> ask.
> >> >
> >> > Thanks in advance!
> >> >
> >> > Regards.
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Contructor model

Posted by Gwyn Evans <gw...@gmail.com>.
Are you looking for something like:

public class MyPage extends WebPage {
  public MyPage(String name) {
    setModel(new Model(new Customer(name));
    ...

/Gwyn

On Thu, Jun 5, 2008 at 2:22 PM, Manuel Corrales
<ma...@gmail.com> wrote:
> Hi, i will rephrase. I have a class Customer on my domain, and Customer do
> not have a default constructor. Lets assume Customer have a constructor with
> a String:
>
> public class Customer {
>   Customer(String name) {
>       ...
>   }
> }
>
> It is possible to create a wicket model, to create a new instance of
> Customer? I mean, if i am not getting it wrong the wicket model use
> accessors (get, set) to "fill" the objects, so how can i do to use the
> Customer constructor from a wicket model?
>
> On Wed, Jun 4, 2008 at 5:41 PM, Maurice Marrink <ma...@gmail.com> wrote:
>
>> What do you mean?
>> If your page accepts a certain model in its constructor you can do
>> with it whatever you want.
>> Any page (with or without empty constructor) can be created from
>> within another page. Although typically you will do this on a link
>> click or form submit.
>> Just do setResponsePage(new MyPage(whatever_args_here);
>>
>> Maurice
>>
>> On Wed, Jun 4, 2008 at 6:27 PM, Manuel Corrales
>> <ma...@gmail.com> wrote:
>> > Hi, let assume i have a class with no empty constructors (at least no
>> > publics). And i want to use a wicket page to instantiate this class. It
>> is
>> > possible to create a model for this, so i dont have to use another object
>> or
>> > add setters. I dont know if i made myself clear. Please feel free to ask.
>> >
>> > Thanks in advance!
>> >
>> > Regards.
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

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


Re: Contructor model

Posted by Manuel Corrales <ma...@gmail.com>.
Hi, i will rephrase. I have a class Customer on my domain, and Customer do
not have a default constructor. Lets assume Customer have a constructor with
a String:

public class Customer {
   Customer(String name) {
       ...
   }
}

It is possible to create a wicket model, to create a new instance of
Customer? I mean, if i am not getting it wrong the wicket model use
accessors (get, set) to "fill" the objects, so how can i do to use the
Customer constructor from a wicket model?

On Wed, Jun 4, 2008 at 5:41 PM, Maurice Marrink <ma...@gmail.com> wrote:

> What do you mean?
> If your page accepts a certain model in its constructor you can do
> with it whatever you want.
> Any page (with or without empty constructor) can be created from
> within another page. Although typically you will do this on a link
> click or form submit.
> Just do setResponsePage(new MyPage(whatever_args_here);
>
> Maurice
>
> On Wed, Jun 4, 2008 at 6:27 PM, Manuel Corrales
> <ma...@gmail.com> wrote:
> > Hi, let assume i have a class with no empty constructors (at least no
> > publics). And i want to use a wicket page to instantiate this class. It
> is
> > possible to create a model for this, so i dont have to use another object
> or
> > add setters. I dont know if i made myself clear. Please feel free to ask.
> >
> > Thanks in advance!
> >
> > Regards.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Contructor model

Posted by Maurice Marrink <ma...@gmail.com>.
What do you mean?
If your page accepts a certain model in its constructor you can do
with it whatever you want.
Any page (with or without empty constructor) can be created from
within another page. Although typically you will do this on a link
click or form submit.
Just do setResponsePage(new MyPage(whatever_args_here);

Maurice

On Wed, Jun 4, 2008 at 6:27 PM, Manuel Corrales
<ma...@gmail.com> wrote:
> Hi, let assume i have a class with no empty constructors (at least no
> publics). And i want to use a wicket page to instantiate this class. It is
> possible to create a model for this, so i dont have to use another object or
> add setters. I dont know if i made myself clear. Please feel free to ask.
>
> Thanks in advance!
>
> Regards.
>

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