Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4582076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:01:20+00:00 2026-05-21T21:01:20+00:00

I am a n00b when it comes to Wicket, as i started earlier this

  • 0

I am a n00b when it comes to Wicket, as i started earlier this week. What i am trying to do is display a list of people on a page with radio buttons describing their gender. Now the radio buttons are selected properly when the page loads, however when i submit the page, the changes (if any are made) are not persisted. I am used to asp.net MVC so i am familiar with Model Binding, but wicket is kind of alien to me and to be honest, there isnt much documentation relating to this specific problem. So if you guys would be so kind as to check over my code i would very much appreciate it.
Any comments and/or fixes would also be appreciated.

.java code

public class FlightInfo extends WebPage 
{
private static final long serialVersionUID = 1L;

private ListView<GuestInfo> guestRecordListView;

public FlightInfo() {
    this.init();
}

private void init() 
{
    FeedbackPanel feedbackPanel = new FeedbackPanel("flightinfo.errormessages");
    add(feedbackPanel);

    final SearchResponse searchResponse = ((DciSession)super.getSession()).getSearchResponse();

    //Data lists
    guestRecordListView = new ListView<GuestInfo>("guestRecordListView", searchResponse.getObj().getGuestList())
    {
        private static final long serialVersionUID = 1L;
        private static final long MALE = 1L;
        private static final long FEMALE = 2L;

        @Override
        protected void populateItem(ListItem<GuestInfo> item)
        {
            item.add(new Label("guestRecordNameListItem", new PropertyModel<String>(item.getModel().getObject(), "Name")));

            String gender = item.getModel().getObject().getGender();

            IModel genderModel = new PropertyModel<String>(item.getModel(), "Gender");

            final RadioGroup<String> guestTypeRadioGroup = new RadioGroup("radio-passengerType", genderModel);
            item.add(guestTypeRadioGroup);

            final Model mModel = new Model(new PersonGenderXRef(item.getModel().getObject(), MALE));
            final Model fModel = new Model(new PersonGenderXRef(item.getModel().getObject(), FEMALE));
            final Model cModel = new Model(new PersonGenderXRef(item.getModel().getObject(), CHILD));

            guestTypeRadioGroup.add(new Radio("radio-male", mModel));
            guestTypeRadioGroup.add(new Radio("radio-female", fModel));
            guestTypeRadioGroup.add(new Radio("radio-child", cModel));

            if(gender.toUpperCase().equals("M"))
            {
                guestTypeRadioGroup.setModel(mModel);
            }
            else 
            {
                if (gender.toUpperCase().equals("F"))
                {
                    guestTypeRadioGroup.setModel(fModel);                   
                }
                else
                {
                    if (gender.toUpperCase().equals("C"))
                    {
                        guestTypeRadioGroup.setModel(cModel);
                    }
                }

            }
        }
    };

    //Buttons
    Button continueButton = new Button("input.submitChanges");

    Form form = new Form("form.reviewAndEditForm")
    {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("serial")
        protected void onSubmit()
        {       

            try
            {                       
                List<GuestInfo> guests = (List<GuestInfo>) guestRecordListView.getModelObject();
                List<Person> people = new ArrayList<Person>();
                //Construct people list
                for(int i = 0; i < guests.size(); i++)
                {
                    people.add(guests.get(i).getPerson());
                }
                //Submit request
            }
            catch(Exception e)
            {

            }
        }           
    };
    add(form);

    form.add(continueButton);
    form.add(guestRecordListView);
    form.add(flightRecordListView);
}

private final void saveStuff(ListView<GuestInfo> data)
{
    ListView<GuestInfo> dataview2 = data;
}
}

Other class that is mentioned

public class PersonGenderXRef implements Serializable
{
/**
 * 
 */
private static final long serialVersionUID = 1L;

private GuestInfo guest;
private long gender;

public PersonGenderXRef(GuestInfo guest, long gender)
{
    this.guest = guest;
    this.gender = gender;
}

public GuestInfo guest()
{
    return this.guest;
}

public void setGuest(GuestInfo guest)
{
    this.guest = guest;
}

public long getGender()
{
    return this.gender;
}

public void setGender(long gender)
{
    this.gender = gender;
}
}

And here is the markup

                    <table id="guestTable">
                        <tr>
                            <th width="20"><!-- <input id="select_all_guests" type="checkbox" /> --></th>
                            <th width="150"><b>Name</b></th>
                            <th colspan="3"><b>Guest Type<span style="color:red">*</span></b></th>
                        </tr>
                        <tr wicket:id="guestRecordListView">
                            <td width="20"><input type="checkbox" /></td>
                            <td width="150"><span wicket:id="guestRecordNameListItem"></span></td>
                            <wicket:container wicket:id="radio-passengerType">
                                <td width="80"><input wicket:id="radio-male" type="radio" />Male</td>
                                <td width="80"><input wicket:id="radio-female" type="radio" />Female</td>
                            </wicket:container>
                        </tr>
                    </table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:01:21+00:00Added an answer on May 21, 2026 at 9:01 pm

    The model of the RadioGroup should point to the property on an underlying bean which is persisted to the database.

    For example, suppose you have a model for a root object which knows how to load and persist changes to the database (or the changes are persisted on form submit):

    IModel personModel = new PropertyModel<Person>(item.getModel(), "person");
    

    You want the radio group to be a sub-property of the person which is the gender property:

    IModel genderModel = new PropertyModel<String>(personModel, "gender")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

n00b problem- I am trying to have a list show the most recent entry
G'day, I'm a total n00b when it comes to SQL Server reports and my
Ok, I'm a bit of a n00b when it comes to JS (I'm not
I need some help ... I'm a bit (read total) n00b when it comes
maybe this is a n00b-question. I try to parse an xml-file like that: <?xml
I'm a total n00b to c++ and am trying to make a simple form
I am a Clojure n00b trying to create some XML strings. My goal is
Well this kind of n00b question but I still can't figure it out. I
this is probably a n00b question, but even so... Apart from MS Office, I
I'm a n00b so I'm sorry if I'm way off with this one but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.