Problem with RadioGroup / Ajax

View: New views
2 Messages — Rating Filter:   Alert me  

Problem with RadioGroup / Ajax

by Travis Boswell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I'm having an issue with a RadioGroup that is used in conjunction with a ListView, the populateItem method for the ListView looks like:

public void populateItem(final ListItem listItem) {
final PoDetailAdj pda = (PoDetailAdj) listItem.getModelObject();

      listItem.add(new Radio("radio-status-pending", new Model()));
listItem.add(new Radio("radio-status-approved", new Model()));
}

The RadioGroup encloses the entire ListView, and the RadioGroup is added to a form on the page. The display works fine, so I added AjaxFormChoiceComponentUpdatingBehavior to the RadioGroup, but changing the Radio values doesn't trigger the onUpdate method of the RadioGroup. I also tried having one RadioGroup per ListItem (a new RadioGroup defined for every row) but that didn't work either. I'm starting to think that maybe the ListView is the problem. Any thoughts or suggestions?

Travis Boswell



Re: Problem with RadioGroup / Ajax

by Mathias Nilsson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've made a sample page.

public class HomePage extends WebPage {

        private static final long serialVersionUID = 1L;

    public HomePage(final PageParameters parameters) {

       String[] choices = new String[]{ "Wicket", "Spring", "DB4O" };
       
       final RadioGroup<String> group = new RadioGroup<String>("group", new Model<String>());
       ListView<String> groupView = new ListView<String>( "groupView" , Arrays.asList( choices )){
                private static final long serialVersionUID = 1L;

                @Override
                protected void populateItem(ListItem<String> item) {
                        item.add(  new Radio<String>( "radio", new Model<String>() ));
                }
     
       };
       group.setOutputMarkupId( true );
       group.add( new AjaxFormChoiceComponentUpdatingBehavior(){
                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                        // TODO: Check this
                        System.out.println( "Here" );
                }
     
       });
       
       group.add(  groupView );
       
       Form<Void> form = new Form<Void>( "form" );
       form.add( group );
       add( form );
   
   
    }
}