Try a dynamic model

Boolean value  ;

check = new CheckBox("check", new Model<Boolean>(){

        public void setObject(Boolean object){ value=object}
        public Boolean getObject(){return value}
});

//YOu may want to add an ajax onchange behaviour to the checkbox if you
want to value to be updated immediately you flip the checkbox.

AjaxLink link = new AjaxLink("link")
{
   @Override
   public void onClick(AjaxRequestTarget target)
   {
       System.out.println(value);
   }
};
add(link);

Try something along those lines.

Josh.


> AjaxLink link = new AjaxLink("link")
> {
>    @Override
>    public void onClick(AjaxRequestTarget target)
>    {
>         Boolean x = check.getModelObject();
>         System.out.println(x);
>    }
> };
> add(link);
>
>

> The problem is that the check.getModelObject() returns true even if the
> checkbox is unchecked.
> I have tried adding check.modelChanged() method. Nothing changed.
>
> Any suggestions ?Thx
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-checkbox-problem-tp4650022.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to