You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michael O'Cleirigh <mi...@rivulet.ca> on 2008/02/05 17:13:03 UTC

Which wicket-ajax.js method will allow me to update a component using an AJAX request initiated from another component.

Hello,

I have a wicket Panel with the following structure:

1. drop down choice to select value
2. text field to specific contextual value details
3. help link to allow the user to see the applicable help if they want.
4. a hidden (style=display:none) div that contains a wicket panel to 
show the contextual help.

When the link(3) is clicked a javascript behaviour will toggle the 
display css attribute to make the help visible/invisible.

The onChange event for the drop down choice(1) invokes an ajax behaviour 
bound to the contextual help panel (4) and provides the currently 
selected value.

The ajax behaviour generates the new contextual help panel context and 
returns it.

The problem I have is in figuring out what wicket-ajax.js method I can 
call to have the results rendered properly, i.e. correctly replacing the 
existing contents on the help panel.

Here is the non-working version of the javascript behaviour:

final AbstractBehavior jsBehave = new AbstractBehavior() {

            @Override
            public void onComponentTag(Component component, ComponentTag 
tag) {

                String submitCall = "wicketAjaxGet('" +
                     ajaxBehave.getCallbackUrl(false) +
                     
"&value='+wicketEncode($("+ddc.getMarkupId()+").getValue()))";

                tag.put("onChange", submitCall);

            }
        };

This is the working version that has a dependency on Prototype's 
Ajax.Updater class.

    final AbstractBehavior jsBehave = new AbstractBehavior() {

            @Override
            public void onComponentTag(Component component, ComponentTag 
tag) {

                // now with the prototype call:
                String submitCall = "new Ajax.Updater("
                        + overlayPanel.getMarkupId() + ", '"
                        + ajaxBehave.getCallbackUrl(false) + "&value='+$("
                        + ddc.getMarkupId() + ").value);";
                tag.put("onChange", submitCall);

            }
        };

Thanks for your help,

Mike

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


Re: Which wicket-ajax.js method will allow me to update a component using an AJAX request initiated from another component.

Posted by Igor Vaynberg <ig...@gmail.com>.
where does ajaxBehave come from?

-igor


On Feb 5, 2008 8:13 AM, Michael O'Cleirigh <mi...@rivulet.ca> wrote:
> Hello,
>
> I have a wicket Panel with the following structure:
>
> 1. drop down choice to select value
> 2. text field to specific contextual value details
> 3. help link to allow the user to see the applicable help if they want.
> 4. a hidden (style=display:none) div that contains a wicket panel to
> show the contextual help.
>
> When the link(3) is clicked a javascript behaviour will toggle the
> display css attribute to make the help visible/invisible.
>
> The onChange event for the drop down choice(1) invokes an ajax behaviour
> bound to the contextual help panel (4) and provides the currently
> selected value.
>
> The ajax behaviour generates the new contextual help panel context and
> returns it.
>
> The problem I have is in figuring out what wicket-ajax.js method I can
> call to have the results rendered properly, i.e. correctly replacing the
> existing contents on the help panel.
>
> Here is the non-working version of the javascript behaviour:
>
> final AbstractBehavior jsBehave = new AbstractBehavior() {
>
>             @Override
>             public void onComponentTag(Component component, ComponentTag
> tag) {
>
>                 String submitCall = "wicketAjaxGet('" +
>                      ajaxBehave.getCallbackUrl(false) +
>
> "&value='+wicketEncode($("+ddc.getMarkupId()+").getValue()))";
>
>                 tag.put("onChange", submitCall);
>
>             }
>         };
>
> This is the working version that has a dependency on Prototype's
> Ajax.Updater class.
>
>     final AbstractBehavior jsBehave = new AbstractBehavior() {
>
>             @Override
>             public void onComponentTag(Component component, ComponentTag
> tag) {
>
>                 // now with the prototype call:
>                 String submitCall = "new Ajax.Updater("
>                         + overlayPanel.getMarkupId() + ", '"
>                         + ajaxBehave.getCallbackUrl(false) + "&value='+$("
>                         + ddc.getMarkupId() + ").value);";
>                 tag.put("onChange", submitCall);
>
>             }
>         };
>
> Thanks for your help,
>
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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