You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by smoothe19 <sa...@justassociates.com> on 2016/01/11 20:29:27 UTC

Checking/Dechecking a checkbox multiple choice

How can I check or uncheck one checkbox item from a checkboxmultiple choice

I tried mpCheckBoxes.get(0).setDefaultModel(new Model<>(true)); and also
mpCheckBoxes.get(0).setDefaultObjectModel(new Model<>(true)); both threw an
error




List<JobAdvStates> mpDECISIONS = new ArrayList<JobAdvStates>();


CheckBoxMultipleChoice<JobAdvStates> mpCheckBoxes = 
                new CheckBoxMultipleChoice<JobAdvStates>(
                     "mpToggles", new Model(mpDecisionsSelect),
mpDECISIONS);

         for (JobAdvStates advanceState: advStatesList){
           
            if (advanceState.getRecordState().equals("MP") ){
                mpDECISIONS.add(advanceState);
            }
                 
         }
        
    
      
        fieldEditForm.add(mpCheckBoxes); 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Checking-Dechecking-a-checkbox-multiple-choice-tp4673251.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Checking/Dechecking a checkbox multiple choice

Posted by smoothe19 <sa...@justassociates.com>.
Yes I ended up having to do the below.. basically where i initialize the
variables for storing the values selected pre-select some based on if it was
already toggled in the database


    private ArrayList<JobAdvStates> evDecisionsSelect;
    private ArrayList<JobAdvStates> mpDecisionsSelect;

        evDecisionsSelect = new ArrayList<JobAdvStates>(
                evSelectors);
        mpDecisionsSelect = new ArrayList<JobAdvStates>(mpSelectors);

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Checking-Dechecking-a-checkbox-multiple-choice-tp4673251p4673278.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Checking/Dechecking a checkbox multiple choice

Posted by Martin Grigorov <mg...@apache.org>.
https://sirsaula.wordpress.com/2016/01/11/wicket-using-checkboxmultiplechoice/

I guess this means you managed to make it working for your application!
Good!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Jan 11, 2016 at 10:12 PM, Martin Grigorov <mg...@apache.org>
wrote:

>
> JobAdvStates state1 = new JobAdvStates();
> JobAdvStates state2 = new JobAdvStates();
> JobAdvStates state3 = new JobAdvStates();
>
> List<JobAdvStates> selected = new ArrayList<>();
> selected.add(state1);
> selected.add(state3);
> ListModel<JobAdvStates> model = new ListModel(selected);
>
>
> List<JobAdvStates> allPossible = new ArrayList<>();
> allPossible.add(state1);
> allPossible.add(state2);
> allPossible.add(state3);
>
> new CheckBoxMultipleChoice<JobAdvStates>(id, model, allPossible)
>
>
> Make sure JobAdvStates has good impl of #equals()
>
> On Mon, Jan 11, 2016 at 9:24 PM, smoothe19 <sa...@justassociates.com>
> wrote:
>
>> Can you display an example?
>>
>>  I essentially want to be able to have some of the checkboxes checked
>> (based
>> on a boolean in database) when displayed on the screne
>> <http://apache-wicket.1842946.n4.nabble.com/file/n4673257/Capture.png>
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Checking-Dechecking-a-checkbox-multiple-choice-tp4673251p4673257.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: Checking/Dechecking a checkbox multiple choice

Posted by Martin Grigorov <mg...@apache.org>.
JobAdvStates state1 = new JobAdvStates();
JobAdvStates state2 = new JobAdvStates();
JobAdvStates state3 = new JobAdvStates();

List<JobAdvStates> selected = new ArrayList<>();
selected.add(state1);
selected.add(state3);
ListModel<JobAdvStates> model = new ListModel(selected);


List<JobAdvStates> allPossible = new ArrayList<>();
allPossible.add(state1);
allPossible.add(state2);
allPossible.add(state3);

new CheckBoxMultipleChoice<JobAdvStates>(id, model, allPossible)


Make sure JobAdvStates has good impl of #equals()

On Mon, Jan 11, 2016 at 9:24 PM, smoothe19 <sa...@justassociates.com>
wrote:

> Can you display an example?
>
>  I essentially want to be able to have some of the checkboxes checked
> (based
> on a boolean in database) when displayed on the screne
> <http://apache-wicket.1842946.n4.nabble.com/file/n4673257/Capture.png>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Checking-Dechecking-a-checkbox-multiple-choice-tp4673251p4673257.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Checking/Dechecking a checkbox multiple choice

Posted by smoothe19 <sa...@justassociates.com>.
Can you display an example?

 I essentially want to be able to have some of the checkboxes checked (based
on a boolean in database) when displayed on the screne 
<http://apache-wicket.1842946.n4.nabble.com/file/n4673257/Capture.png> 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Checking-Dechecking-a-checkbox-multiple-choice-tp4673251p4673257.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Checking/Dechecking a checkbox multiple choice

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

In  new CheckBoxMultipleChoice<JobAdvStates>(id, modelOfCollection,
allPossibleChoices) you have to add/remove entries to "modelOfCollection"

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Jan 11, 2016 at 8:29 PM, smoothe19 <sa...@justassociates.com>
wrote:

> How can I check or uncheck one checkbox item from a checkboxmultiple choice
>
> I tried mpCheckBoxes.get(0).setDefaultModel(new Model<>(true)); and also
> mpCheckBoxes.get(0).setDefaultObjectModel(new Model<>(true)); both threw an
> error
>
>
>
>
> List<JobAdvStates> mpDECISIONS = new ArrayList<JobAdvStates>();
>
>
> CheckBoxMultipleChoice<JobAdvStates> mpCheckBoxes =
>                 new CheckBoxMultipleChoice<JobAdvStates>(
>                      "mpToggles", new Model(mpDecisionsSelect),
> mpDECISIONS);
>
>          for (JobAdvStates advanceState: advStatesList){
>
>             if (advanceState.getRecordState().equals("MP") ){
>                 mpDECISIONS.add(advanceState);
>             }
>
>          }
>
>
>
>         fieldEditForm.add(mpCheckBoxes);
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Checking-Dechecking-a-checkbox-multiple-choice-tp4673251.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>