Wicket: Radiogroup with radio's in different panel

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Wicket: Radiogroup with radio's in different panel

vijayakumar B
I have a RadioGroup (searchChoice) in my Primarypanel, I have another panel (ResultPanel) which hold DataTable with radio as one of its column. I have added this ResultPanel to searchChoice RadioGroup, hence radio's in ResultPanel comes under searchChoice RadioGroup.
From primary panel i am adding another Radio to the searchChoice RadioGroup, which has an ajax behavior to enable and disable buttons on the PrimaryPanel.
My Probelm is how to get the selected object.

Code snippet:

In ResultPanel.java i have the radio column added as follows:

column[0] = new AbstractColumn<ProviderChoice>(new Model<String> ("Select"))
                     public void populateItem(
                                   Item<ICellPopulator<ProviderChoice> cellItem,
                                   String componentId,
                                   IModel<ProviderChoice> rowModel)
                              cellItem.add(new Radio("check", rowModel));

//all other colums comes

DataTable<Void> dataTable = new DataTable<Void> ("dataTable", columns, dataProvider, 20);

In my PrimaryPanel, I have the following code for RadioGroup.

final RadioGroup searchChoice = new RadioGroup("searchChoice",
                                                                  new PropertyModel(this, "currentObjectModel"));
//here currentObjectModel is declared as Object


//my submit button looks as follows.

Button submitButton = new Button("submitButton", new Model<String>("Submit")
    public void onSumbit()
    Object obj = searchChoice.getDetaultModelObject();  //--> i am getting nothing, its null.
    //Other stmts
    //Also tried like,
    Object obj = currentObjectModel;     // --> this also am getting null


i am not able to get the selected object from the RadioGroup.
Can someone please help me on this.

Reply | Threaded
Open this post in threaded view

Re: Wicket: Radiogroup with radio's in different panel

vijayakumar B
I have found the solution (or Work-around) for the problem i had. i am not sure why my previous code not worked. But i made the changes like, i have moved the searchChoice radiogroup (i removed the property model binded to it) to my ResultPanel.java and made it a instance variable in ResultPanel.java. Then from PrimaryPanel.java when ever the search button is clicked, based on the search criteria,  i retrieve the searchChoice radiogroup and inturn get the Default object set it in.

And this works awesome.
Exploring is Fun