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

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

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

by Alex Objelean :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Why wicket.markup.html.form.Radio component does not extend FormComponent?

I wanted to add a FormComponentUpdatingBehavior to this component and it is not possible because it does not extend the FormComponent, but a WebMarkupContainer.

Thank you!

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

by Jan Kriesten-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message


hi alex,

> Why wicket.markup.html.form.Radio component does not extend FormComponent?
> I wanted to add a FormComponentUpdatingBehavior to this component and it is
> not possible because it does not extend the FormComponent, but a
> WebMarkupContainer.

i've got a similar issue and this topic is already being worked on:

https://issues.apache.org/jira/browse/WICKET-531

targeted for 1.3.0 beta 3

best regards, --- jan.



-------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/wicket-user

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

by Alex Objelean :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

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

Jan Kriesten-3 wrote:
hi alex,

> Why wicket.markup.html.form.Radio component does not extend FormComponent?
> I wanted to add a FormComponentUpdatingBehavior to this component and it is
> not possible because it does not extend the FormComponent, but a
> WebMarkupContainer.

i've got a similar issue and this topic is already being worked on:

https://issues.apache.org/jira/browse/WICKET-531

targeted for 1.3.0 beta 3

best regards, --- jan.



-------------------------------------------------------------------------
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

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

by Jan Kriesten-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message


hi alex,

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

actually, if you're up to building it from the sources yourself, modifying Radio
to work as you expect is pretty easy.

just remove the 'final' from FromComponent.getValue() and let Radio extend
FormComponent instead of WebMarkupContainer. that should be all.

regards, --- jan.


-------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/wicket-user

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

by Kent Tong :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

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@...
https://lists.sourceforge.net/lists/listinfo/wicket-user
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
Axis2 tutorials freely available at http://www.agileskills2.org/DWSAA

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

by Alex Objelean :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message


Thank you Tong, interesting approach.
  I make it work for me by adding AjaxFormSubmitingBehavior to the Radio component, just to keep in synch the model with the RadioGroup state. But your solution is more elegant.

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

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

by jq58 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

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

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

by Alex Objelean :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

You mean that in IE you have to click twice?
Use onclick event instead...



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


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

by jq58 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

Yep, that did it.  Still  a little confused as to why the onchange did not work.

Thanks to everyone for their suggestions.



You mean that in IE you have to click twice?
Use onclick event instead...


jq58 wrote:
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

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

by igor.vaynberg :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

because browsers suck :)

-igor


On 8/13/07, jq58 <quinnjohn58@...> wrote:

>
>
> Yep, that did it.  Still  a little confused as to why the onchange did not
> work.
>
> Thanks to everyone for their suggestions.
>
>
>
> Alex Objelean wrote:
> >
> > You mean that in IE you have to click twice?
> > Use onclick event instead...
> >
> >
> >
> > jq58 wrote:
> >>
> >> 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@...
> >>> https://lists.sourceforge.net/lists/listinfo/wicket-user
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-Question--wicket.markup.html.form.Radio-tf3926549.html#a12126632
> Sent from the Wicket - User (OLD) mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> IMPORTANT NOTICE:
>
> This mailing list is shutting down. Please subscribe to the Apache Wicket
> user list. Send a message to: "users-subscribe at wicket.apache.org" and
> follow the instructions.
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@...
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
IMPORTANT NOTICE:

This mailing list is shutting down. Please subscribe to the Apache Wicket user list. Send a message to: "users-subscribe at wicket.apache.org" and follow the instructions.
_______________________________________________
Wicket-user mailing list
Wicket-user@...
https://lists.sourceforge.net/lists/listinfo/wicket-user