You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Zbynek Vavros <zb...@gmail.com> on 2018/05/25 11:41:48 UTC

Calling Wicket from JS

Hey,

I am using the callBackScript() of AbstractDefaultAjaxBehavior:
AbstractDefaultAjaxBehavior behavior = new AbstractDefaultAjaxBehavior() {

            @Override
            public CharSequence getCallbackFunction(CallbackParameter...
extraParameters) {
                return super.getCallbackFunction(extraParameters);
            }

            @Override
            public void renderHead(Component component, IHeaderResponse
response) {
                super.renderHead(component, response);
                String callBackScript =
getCallbackFunction(CallbackParameter.explicit(JS_PARAM_CERTIFICATE),
CallbackParameter.explicit(JS_PARAM_CERTIFICATE_CHAIN)).toString();
                callBackScript = "sendCertificate=" + callBackScript + ";";

response.render(OnDomReadyHeaderItem.forScript(callBackScript));
            }

            protected void respond(final AjaxRequestTarget target) {

                String certificate =
getRequest().getRequestParameters().getParameterValue(JS_PARAM_CERTIFICATE).toString();
                String certificateChain =
getRequest().getRequestParameters().getParameterValue(JS_PARAM_CERTIFICATE_CHAIN).toString();
            }
        };
        add(behavior);


The problem is that I need to send certificate and certificateChain from JS
and these are obviously quite long. Thus I am getting " Wicket.Ajax:
Wicket.Ajax.Call.failure:
Error while parsing response: Request-URI Too Long".

Any idea how to solve this?

I am on Wicket 7.0.0...

Thanks,
Zbynek

Re: Calling Wicket from JS

Posted by Zbynek Vavros <zb...@gmail.com>.
Thanks Martin, exactly what I was looking for!

On Fri, May 25, 2018 at 1:54 PM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi,
>
> You need to use POST method for your Ajax request.
> See AbstractDefaultAjaxBehavior#updateAjaxAttributes()
>
> On Fri, May 25, 2018 at 2:41 PM, Zbynek Vavros <zb...@gmail.com>
> wrote:
>
> > Hey,
> >
> > I am using the callBackScript() of AbstractDefaultAjaxBehavior:
> > AbstractDefaultAjaxBehavior behavior = new AbstractDefaultAjaxBehavior()
> {
> >
> >             @Override
> >             public CharSequence getCallbackFunction(CallbackParameter...
> > extraParameters) {
> >                 return super.getCallbackFunction(extraParameters);
> >             }
> >
> >             @Override
> >             public void renderHead(Component component, IHeaderResponse
> > response) {
> >                 super.renderHead(component, response);
> >                 String callBackScript =
> > getCallbackFunction(CallbackParameter.explicit(JS_PARAM_CERTIFICATE),
> > CallbackParameter.explicit(JS_PARAM_CERTIFICATE_CHAIN)).toString();
> >                 callBackScript = "sendCertificate=" + callBackScript +
> ";";
> >
> > response.render(OnDomReadyHeaderItem.forScript(callBackScript));
> >             }
> >
> >             protected void respond(final AjaxRequestTarget target) {
> >
> >                 String certificate =
> > getRequest().getRequestParameters().getParameterValue(JS_PARAM_
> > CERTIFICATE).toString();
> >                 String certificateChain =
> > getRequest().getRequestParameters().getParameterValue(JS_PARAM_
> > CERTIFICATE_CHAIN).toString();
> >             }
> >         };
> >         add(behavior);
> >
> >
> > The problem is that I need to send certificate and certificateChain from
> JS
> > and these are obviously quite long. Thus I am getting " Wicket.Ajax:
> > Wicket.Ajax.Call.failure:
> > Error while parsing response: Request-URI Too Long".
> >
> > Any idea how to solve this?
> >
> > I am on Wicket 7.0.0...
> >
> > Thanks,
> > Zbynek
> >
>

Re: Calling Wicket from JS

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

You need to use POST method for your Ajax request.
See AbstractDefaultAjaxBehavior#updateAjaxAttributes()

On Fri, May 25, 2018 at 2:41 PM, Zbynek Vavros <zb...@gmail.com>
wrote:

> Hey,
>
> I am using the callBackScript() of AbstractDefaultAjaxBehavior:
> AbstractDefaultAjaxBehavior behavior = new AbstractDefaultAjaxBehavior() {
>
>             @Override
>             public CharSequence getCallbackFunction(CallbackParameter...
> extraParameters) {
>                 return super.getCallbackFunction(extraParameters);
>             }
>
>             @Override
>             public void renderHead(Component component, IHeaderResponse
> response) {
>                 super.renderHead(component, response);
>                 String callBackScript =
> getCallbackFunction(CallbackParameter.explicit(JS_PARAM_CERTIFICATE),
> CallbackParameter.explicit(JS_PARAM_CERTIFICATE_CHAIN)).toString();
>                 callBackScript = "sendCertificate=" + callBackScript + ";";
>
> response.render(OnDomReadyHeaderItem.forScript(callBackScript));
>             }
>
>             protected void respond(final AjaxRequestTarget target) {
>
>                 String certificate =
> getRequest().getRequestParameters().getParameterValue(JS_PARAM_
> CERTIFICATE).toString();
>                 String certificateChain =
> getRequest().getRequestParameters().getParameterValue(JS_PARAM_
> CERTIFICATE_CHAIN).toString();
>             }
>         };
>         add(behavior);
>
>
> The problem is that I need to send certificate and certificateChain from JS
> and these are obviously quite long. Thus I am getting " Wicket.Ajax:
> Wicket.Ajax.Call.failure:
> Error while parsing response: Request-URI Too Long".
>
> Any idea how to solve this?
>
> I am on Wicket 7.0.0...
>
> Thanks,
> Zbynek
>