« Return to Thread: [Question] wicket.markup.html.form.Radio

Re: [Question] wicket.markup.html.form.Radio

by jq58 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View in Thread

This works to an extent.  It appears that sometimes (totally random as far as I can tell) I have to click twice to get it to actually invoke the ajax action.

But, once it is invoked, I am trying to enable the drop down and disable the text box via:
[code]
  private void setupAjaxRadio(final Panel panel,
      final RadioGroup radioGroup,
      final Radio radio) {
    radioGroup.add(radio.add(new AjaxEventBehavior("onchange") {

                private static final long serialVersionUID = 1L;
                protected void onEvent(AjaxRequestTarget target) {
                        radioGroup.processInput();
                        if (radioGroup.getConvertedInput().equals(Component.getApplyToRadioGroupChoices().get(Component.AMOUNT_TYPE_GLOBAL)) ) {
                                radioGroup.get("percentGFId").setEnabled(true);
                                radioGroup.get("amount").setEnabled(false);
                        } else {
                                radioGroup.get("percentGFId").setEnabled(false);
                                radioGroup.get("amount").setEnabled(true);
                        }
                        target.addComponent(panel);
                }
[/code]

However, the enabling and disabling of the controls under the radio group are being ignored.
Any idea why?

Thanks.
Kent Tong wrote:
Alex Objelean <alexandru.objelean <at> isdc.ro> writes:

> Thank you Jan! Sad thing is that 1.2.x branch will never support this
> feature.

Try:

    Form f = ...;
    RadioGroup rg2 = new RadioGroup("rg2", ...);
    rg2.setOutputMarkupId(true);
    setupAjaxRadio(f, rg2, new Radio("r3", new Model("abc")));
    setupAjaxRadio(f, rg2, new Radio("r4", new Model("def")));
    ...

  private void setupAjaxRadio(final Form form,
      final RadioGroup radioGroup,
      final Radio radio) {
    radioGroup.add(radio.add(new AjaxEventBehavior("onchange") {
      protected void onEvent(AjaxRequestTarget target) {
        radioGroup.processInput();
        target.addComponent(form);
      }
      protected CharSequence getEventHandler() {
        return getCallbackScript(new AppendingStringBuffer(
            "wicketAjaxPost('").append(getCallbackUrl()).append(
            "', wicketSerialize(document.getElementById('"
                + radio.getMarkupId() + "'))"), null, null);
      }

    }));
  }



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

 « Return to Thread: [Question] wicket.markup.html.form.Radio