Yes, I think the AbstractDefaultAjaxBehavior could look to something like:

public void renderHead(Component component, IHeaderResponse response)
{
    super.renderHead(component, response);

    response.renderJavaScript("function boup(id) { " +
this.getCallbackScript() + " }", "my-script-id");
    //TODO: <input type="checkbox" onclick="boup(10);" /> where (id = 10)
}

protected CharSequence getCallbackScript()
{
    return this.generateCallbackScript("wicketAjaxGet('" +
this.getCallbackUrl() + "&id=' + id"); //warning, do not close script with
")"!
}

protected void respond(AjaxRequestTarget target)
{
    final IRequestParameters parameters =
RequestCycle.get().getRequest().getQueryParameters();

    int id = parameters.getParameterValue("id").toInt();
    //TODO: do something with id
}


On Fri, Sep 28, 2012 at 2:52 PM, Ernesto Reinaldo Barreiro <
reier...@gmail.com> wrote:

> Hi,
>
> I would do the following
>
> 1- attach an AbstractDefaultAjaxBehavior to the table
> 2- Use that behavior as a context for making AJAX call-backs (i.e. generate
> a URL to it amd pas it to the client side).
> 3- On client side use some jquery (or similar machinery) to generate
> wickeAjaxGet(URL in step 2) passing as extra parameter the info you need
>
> This way you reduce the amount of "code" to be streamed back to the client
> as well as the "foot-print" on server side. This approach should work in
> any of the current version of wicket (AFAIK).
>
> On Fri, Sep 28, 2012 at 5:41 AM, lukuperman <lukuper...@hotmail.com>
> wrote:
>
> > Hello all, I am working on an application that was built with Wicket
> > 1.4.15.
> > It has to show a table with an AjaxCheckBox on each cell. Most of the
> final
> > html size is because of the inline ajax behavior on each cb (ie 20Mb for
> a
> > 200x200 table). Leaving aside the fact of rendering big tables (which is
> > imposed by business), can you give me some hints or ideas on how can I
> > decrease final html size maintaining ajax behavior? For example, how can
> I:
> >
> > -centralize the javascript and make checkboxes call it passing the
> minimum
> > parameters needed (id, etc)
> > -or event registration, without migrating to Wicket 6 (not allowed to)
> > -some other way?
> >
> > Thank you!
> > Lucas
> >
> >
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/Centralizing-ajax-inline-javascript-tp4652499.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com
>

Reply via email to