What do you mean by "quickstart"?

Shelli

-----Original Message-----
From: Igor Vaynberg [mailto:igor.vaynb...@gmail.com] 
Sent: Thursday, September 23, 2010 10:57 AM
To: users@wicket.apache.org
Subject: Re: Setting Checked Boxes in CheckGroup

im going to guess something is wrong with your model. hard to tell
without a quickstart.

-igor

On Thu, Sep 23, 2010 at 9:25 AM, Shelli Orton <shelli.or...@sjrb.ca> wrote:
> Does anybody have a suggestion for this?
>
> Thanks,
>
> Shelli
>
> -----Original Message-----
> From: Shelli Orton
> Sent: Wednesday, September 22, 2010 1:54 PM
> To: users@wicket.apache.org
> Subject: Setting Checked Boxes in CheckGroup
>
> Hi,
>
> I am trying to use a CheckGroup to manage which columns are used in a
> datatable.  I've set up my columns as per the code below.  The
> getColumnCheckBoxes method creates the check boxes that will be part of
> the group.  The getDefaultColumns defines which columns should be
> checked by default.  The default columns are being set, but the boxes
> are not being displayed as "checked" when the page is first loaded.
> However, the correct columns are being displayed in the datatable, so
> they are being set "behind the scenes".
>
> How do I get them to display as checked on page load?
>
> Thanks in advance!
>
> Shelli
>
> CODE:
>
> public class HomePage extends WebPage
> {
>    StringResourceModel columnA = new StringResourceModel("columnA",
>            this,
>            null);
>    StringResourceModel columnB = new StringResourceModel("columnB",
>            this,
>            null);
>    StringResourceModel columnC = new StringResourceModel("columnC",
>            this,
>            null);
>    StringResourceModel columnD = new StringResourceModel("columnD",
>            this,
>            null);
>
>    ArrayList<SelectOption> columnCheckBoxes = null;
>
>    CheckGroup<SelectOption> columnCheckGroup = new
> CheckGroup<SelectOption>("columnCheckGroup",
>            new ArrayList<SelectOption>());
>
>   �...@suppresswarnings("rawtypes")
>    List<IColumn> columns = new ArrayList<IColumn>();
>
>    /**
>     * Constructor that is invoked when page is invoked without a
> session.
>     *
>     * @param parameters Page parameters
>     */
>   �...@suppresswarnings("rawtypes")
>    public HomePage(final PageParameters parameters)
>    {
>       �...@suppresswarnings("serial")
>        Form queryForm = new Form("queryForm")
>        {
>           �...@override
>            protected void onSubmit()
>            {
>                // do stuff
>            }
>        };
>
>        add(queryForm);
>
>        // Create column selection boxes
>        columnCheckGroup.add(new
> CheckGroupSelector("columnCheckGroupSelector"));
>
>       �...@suppresswarnings({ "unchecked", "serial" })
>        ListView checkBoxes = new ListView("columnCheckGroup",
>                getColumnCheckBoxes())
>        {
>           �...@suppresswarnings("unchecked")
>            protected void populateItem(ListItem item)
>            {
>                item.add(new Check("columnCheckbox", item.getModel()));
>                item.add(new Label("displayValue",
>                        new PropertyModel(item.getModel(),
> "displayValue")));
>            }
>
>        };
>
>        if (columnCheckGroup.getModelObject().isEmpty())
>        {
>            columnCheckGroup.setModelObject(this.getDefaultColumns());
>        }
>
>        columnCheckGroup.add(checkBoxes);
>        queryForm.add(columnCheckGroup);
>
>        // more init stuff...
>
>    }
>
>    public ArrayList<SelectOption> getColumnCheckBoxes()
>    {
>        if (columnCheckBoxes == null)
>        {
>            columnCheckBoxes = new ArrayList<SelectOption>();
>
>            columnCheckBoxes.add(new SelectOption("columnA",
> this.columnA.getObject()));
>            columnCheckBoxes.add(new SelectOption("columnB",
> this.columnB.getObject()));
>            columnCheckBoxes.add(new SelectOption("columnC",
> this.columnC.getObject()));
>            columnCheckBoxes.add(new SelectOption("columnD",
> this.columnD.getObject()));
>        }
>
>        return columnCheckBoxes;
>    }
>
>    /*
>        By default, columns A and B are selected
>    */
>    private ArrayList<SelectOption> getDefaultColumns()
>    {
>        ArrayList<SelectOption> defaultColumns = new
> ArrayList<SelectOption>();
>
>        defaultColumns.add(new SelectOption("columnA",
> this.columnA.getObject()));
>        defaultColumns.add(new SelectOption("columnB",
> this.columnB.getObject()));
>
>        return defaultColumns;
>    }
>
>    class SelectOption implements Serializable
>    {
>        private static final long serialVersionUID = 1L;
>
>        private String propertyValue;
>        private String displayValue;
>
>        /**
>         * Utility class for storing property and display values for
> option
>         * widgets (e.g. drop down lists, check boxes).
>         */
>        public SelectOption(String propertyValue, String displayValue)
>        {
>            this.propertyValue = propertyValue;
>            this.displayValue = displayValue;
>        }
>
>        // getters/setters ....
>    }
> }
>
>
> ---------------------------------------------------------------------
> 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
>
>

---------------------------------------------------------------------
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