You don't want an empty model either, just declare a class field and use a 
PropertyModel instead.

Like so:

 public class MyPanel {
   // Add the field and its getter/setter (not shown here)
   private boolean myCheckBoxState;
   
   public MyPanel(id, IModel<MyObj> model){
         super(id, new CompoundPropertyModel<MyObj>(model);
         ....
         Form<MyObj> form = new Form("id", model);
         // Specify a different model for your form fields that are independent 
of MyObj
         form.add(new AjaxCheckBox("anyStupidId", new 
PropertyModel<MyPanel>("myCheckBoxState", MyPanel.this));
         add(form);
   }
 
 }

~ Thank you,
  Paul Bors

-----Original Message-----
From: Joachim Schrod [mailto:jsch...@acm.org] 
Sent: Tuesday, July 09, 2013 6:27 PM
To: users@wicket.apache.org
Subject: Re: FormComponent independent from the Model/Model object

Dmitriy Neretin wrote:
> Hi everyone,
> 
> I have a dummy question:
> 
> If I have a panel with a form (not everything is my code) ->
> 
> public class MyPanel{
> 
>   public MyPanel(id, IModel<MyObj> model){
>         super(id, new CompoundPropertyModel<MyObj>(model);
>         ....
>         Form<MyObj> form = new Form("id", model);
>         form.add(new AjaxCheckBox("anyStupidId");
>         add(form);
> 
>      }
> 
> }
> 
> And I want to add a Component (AjaxCheckBox) to the form above, but 
> this component shouldn't have anything to do with a model object.

Why don't you construct it with an empty model object, i.e., with new Model()? 
Then the CPM from the panel is not accessed.

        Joachim

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod, Roedermark, Germany
Email: jsch...@acm.org


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



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

Reply via email to