You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kums <si...@gmail.com> on 2014/10/10 15:36:13 UTC

wicket checkgroup getconvertedInput returns null? how to retrieve checkedbox list from group?

I am using wicket for the following test case scenario: 
1. group of radio buttons- radiochoice 
2. group of check boxes- checkgroup 
3. when option is selected from 1, we update checkboxes for 2. This works
fine. 
4. now user can select more checkboxes in 2 and Goal is to retrieve the
information of all checked checkboxes on button click event(using radio
button & manually checked/unchecked by user). 

Any kind of help will be appreciated. Find the code below

val categories = util.Arrays.asList("A","B","C")
    val selectedObjects = new ArrayList[String]()

    val form = new Form("form") {
      val allitems = JavaConversions.asJavaList(allitemList)
      val choices = new RadioChoice("radioGroup", Model.of(""), categories)

      add(choices)
      choices.add(new AjaxFormChoiceComponentUpdatingBehavior() {
        @Override
        protected def onUpdate(target: AjaxRequestTarget) {
          if (null != choices.getModelObject()) {
            val allProdTypeList = .....
               
group.setModelObject(JavaConversions.asJavaList(allProdTypeList ))
            target.addComponent(group)
          }
        }
      })

      val group = new CheckGroup("group", new ArrayList[String]())
      group.setRenderBodyOnly(false)
      group.setOutputMarkupId(true)


      group.add(new CheckGroupSelector("groupselector"))
      val itemsList = new ListView("itemsList", allitems) {
        @Override
        protected def populateItem(item: ListItem[String]) {
          item.add(new Check("checkbox", item.getModel()))
          item.add(new Label("id", item.getDefaultModel))
        }
      }

      itemsList.setReuseItems(true)
      itemsList.setOutputMarkupId(true)
      group.add(itemsList)


      add(group)

//i tried various options:
//shows the updated list when radio button was clicked, but does not show
items that user selected
 group.add(new AjaxFormChoiceComponentUpdatingBehavior()
      {
        @Override
        protected def onUpdate(target: AjaxRequestTarget)
      {
        //update form elements
        System.out.println(group.getModelObject)

      }
      });
//below code shows null list but when getmodelobject is used it shows same
result as above
add(new Button("saveButton", new Model("Update list")).add(new
AjaxEventBehavior("onclick") {
        @Override
        protected def onEvent(target: AjaxRequestTarget) {
          group.validate()
          System.out.println(group.getConvertedInput);
        }
      }))
    }
//below code throws exception
      add(new Button("submit", new Model("update config")))

      override def onSubmit() {

        System.out.println(group.getDefaultModelObjectAsString)
      }
    }

    add(form)

  }


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-checkgroup-getconvertedInput-returns-null-how-to-retrieve-checkedbox-list-from-group-tp4667891.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org