Hi Matthew,

use a Check instead of a Checkbox.

Sven


Matthew Arck wrote:
Hey all,

Go easy on me here as I'm not only brand new to wicket but this is also
my first email to this user group!

I've inherited a project from a co-worker who has left the company and a
request has been put into to ask new users to specify their race and
ethnicity when they register on our web site.

After doing a good deal of reading and experimenting I have the
questions displaying properly and the form submits with no exceptions.
The problem I have  is that my user model doesn't get updated with any
of the race or ethnicity selections.

Race and ethnicity are essentially handled the same way so to keep
things short I'll just post what I'm doing for the possible race
selections.

Here's my markup:

<div class="vertical-form-field label">

<span wicket:id="selectOneOrMoreRaces">Select one or more races to
indicate what you consider yourself to be.</span>

      <br />

      <span class="field" wicket:id="races">

            <span wicket:id="raceGroup">

                  <input wicket:id="value" type="checkbox" />

                  <span wicket:id="racDesc"
style="font-weight:normal;">Race Text</span>

                  <br />

            </span>

      </span>

</div>

Here's my markup the code I have for setting up the relevant parts of
the form:

public NewAccountForm(final String id, CompoundPropertyModel userModel)

{ super(id, userModel);
      /*

       * Set up a bunch of fields and validations

       */

// ADD RACE QUESTION

       String raceQuestion = fhDAO.getRaceQuestion();

       Label selectOneOrMoreRacesLabel = new
Label("selectOneOrMoreRaces", new Model(raceQuestion));

       add(selectOneOrMoreRacesLabel);

       CheckGroup racesCheckGroup = new CheckGroup<RaceAnswer>("races");

       add(racesCheckGroup);

       ListView races = new ListView("raceGroup",
fhDAO.getRaceAnswers())

       {

           protected void populateItem(ListItem item)

           {

           RaceAnswer access = (RaceAnswer)item.getModelObject();

           CheckBox chk = new CheckBox("value", item.getModel());

           item.add(chk);

           item.add(new Label("racDesc", access.getDescription()));

           }

       };

       racesCheckGroup.add(races);

}

And finally, the relevant portions of my user model:

private ArrayList<RaceAnswer> race;

public ArrayList<RaceAnswer> getRaces()

{

      return race;

}

public void setRaces(ArrayList<RaceAnswer> races)

{

      race = races;

}

My RaceAnswer model consists of getters and setters for the Value
property (String) and Description property (also a String).

If anyone is able to point out where I've gone wrong or just help me
with the proper way to bind an ArrayList to a CheckGroup I would be
forever grateful.

Thanks,

Matt




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to