You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by gmparker2000 <gr...@brovada.com> on 2012/03/27 16:26:53 UTC

Re: Adding extra request parameters to AJAX calls

Follow up:  

I managed to get this working with an entirely different approach.  By
creating my own WebRequestCodingStrategy implementation I was able to add a
conversation id parameter to every URL that Wicket generates.  Essentially
things look like this:

WebApplication class:
 
    @Override
    protected IRequestCycleProcessor newRequestCycleProcessor() {
        return new ConversationRequestCycleProcessor();
    }

ConversationRequestCycleProcessor class:

public class ConversationRequestCycleProcessor extends
WebRequestCycleProcessor {
    @Override
    protected IRequestCodingStrategy newRequestCodingStrategy() {
        return new ConversationEncodingStrategy();
    }
}

ConversationEncodingStrategy class (I'm only showing one encode method - I
override them all) :

public class ConversationEncodingStrategy extends WebRequestCodingStrategy {
    protected CharSequence encode(RequestCycle requestCycle,
IBookmarkablePageRequestTarget requestTarget) {
        CharSequence url = super.encode(requestCycle, requestTarget);

       // add conversation id to url
       ....

       return url;
    }

There are a lot of things I'm omitting here for brevity - such as handling
multi-part requests and redirects.  So far this works really well; hopefully
I won't find out otherwise after more testing.  If anyone would like to see
more, or knows of a reason this is a bad idea please let me know.




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Adding-extra-request-parameters-to-AJAX-calls-tp4405842p4508979.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Adding extra request parameters to AJAX calls

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

On Tue, Mar 27, 2012 at 6:16 PM, gmparker2000 <gr...@brovada.com> wrote:
> Good to know.  I am planning on making the move some time in the coming
> months and had anticipated that this may not work exactly like this in 1.5.
> From what I have described is there any reason to think this can't be done
> in 1.5?  Can I take "reimplement it completely" to mean that it is possible
> with a similar approach?  Thanks

I believe it will be even easier in 1.5 with a custom root IRequestMapper.

>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Adding-extra-request-parameters-to-AJAX-calls-tp4405842p4509344.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Adding extra request parameters to AJAX calls

Posted by gmparker2000 <gr...@brovada.com>.
Good to know.  I am planning on making the move some time in the coming
months and had anticipated that this may not work exactly like this in 1.5. 
>From what I have described is there any reason to think this can't be done
in 1.5?  Can I take "reimplement it completely" to mean that it is possible
with a similar approach?  Thanks

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Adding-extra-request-parameters-to-AJAX-calls-tp4405842p4509344.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Adding extra request parameters to AJAX calls

Posted by Martin Grigorov <mg...@apache.org>.
On Tue, Mar 27, 2012 at 4:26 PM, gmparker2000 <gr...@brovada.com> wrote:
> Follow up:
>
> I managed to get this working with an entirely different approach.  By
> creating my own WebRequestCodingStrategy implementation I was able to add a
> conversation id parameter to every URL that Wicket generates.  Essentially
> things look like this:
>
> WebApplication class:
>
>    @Override
>    protected IRequestCycleProcessor newRequestCycleProcessor() {
>        return new ConversationRequestCycleProcessor();
>    }
>
> ConversationRequestCycleProcessor class:
>
> public class ConversationRequestCycleProcessor extends
> WebRequestCycleProcessor {
>    @Override
>    protected IRequestCodingStrategy newRequestCodingStrategy() {
>        return new ConversationEncodingStrategy();
>    }
> }
>
> ConversationEncodingStrategy class (I'm only showing one encode method - I
> override them all) :
>
> public class ConversationEncodingStrategy extends WebRequestCodingStrategy {
>    protected CharSequence encode(RequestCycle requestCycle,
> IBookmarkablePageRequestTarget requestTarget) {
>        CharSequence url = super.encode(requestCycle, requestTarget);
>
>       // add conversation id to url
>       ....
>
>       return url;
>    }
>
> There are a lot of things I'm omitting here for brevity - such as handling
> multi-part requests and redirects.  So far this works really well; hopefully
> I won't find out otherwise after more testing.  If anyone would like to see
> more, or knows of a reason this is a bad idea please let me know.

One bad thing that I see is that you'll have to reimplement it
completely if you ever decide to upgrade to Wicket 1.5+.
This was the major task of Wicket 1.5 - re-write of the request handling.

>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Adding-extra-request-parameters-to-AJAX-calls-tp4405842p4508979.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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