UrlEncoder - question mark not encoded for parameter values

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

UrlEncoder - question mark not encoded for parameter values

pasto
Hi,

while patching the original portlet support in Wicket 1.4 to Wicket 1.5, I run into 2 problems:

1) Url returned by the RequestMapper does not seem to be properly rendered, as it does not encode question mark character in the Url parameter value (I haven't checked the w3c spec, but at least Liferay Portal seems to require it to be encoded)

The reason is this definition in the UrlEncoder:
                        case QUERY :
                                // to allow direct passing of URL in query
                                dontNeedEncoding.set('/');
                                // to allow direct passing of URL in query
                                dontNeedEncoding.set('?');

Is it a bug or (according to the comment) a feature?

2) I could not find an easy way to make the markup ID unique across applications (multiple applications per page). The original portlet support adds a portlet identifier to the markup ID in the PortletRequestContext. Is there a way to do it in Wicket 1.5? (I haven't checked, if it's possible, but maybe a MarkupFilter?)

Thanks,
Peter.
bht
Reply | Threaded
Open this post in threaded view
|

1.5 equivalent of setRedirect(false); ?

bht
Hi,

In 1.4, in a page constructor, we can call setRedirect(false);

What is the equivalent of this in Wicket 1.5?

The purpose of it is to avoid the creation of a new request. I am
aware of the consequences of doing this in 1.4, and I am prepared for
them in 1.5, too.

Many thanks.

Bernard

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: 1.5 equivalent of setRedirect(false); ?

Martin Grigorov-4
Wicket automatically decides whether redirect is needed for the
current request or not depending on the configured
org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy and by
comparing the current url with the one that the IRequestMapper has
generated for the page that is going to be rendered.
I.e. if the current is: /my/mount/point and the page is stateful then
the new url should be /my/mount/point?0 and Wicket will need to do a
redirect. Otherwise Refresh button wont work, or at least wont refresh
the current page but will create a new one. If you need to always
create a new one then better make your page stateless or map this page
with a custom IRequestMapper based on the default MountedMapper but
not producing ?0.

On Fri, Sep 2, 2011 at 8:18 AM,  <[hidden email]> wrote:

> Hi,
>
> In 1.4, in a page constructor, we can call setRedirect(false);
>
> What is the equivalent of this in Wicket 1.5?
>
> The purpose of it is to avoid the creation of a new request. I am
> aware of the consequences of doing this in 1.4, and I am prepared for
> them in 1.5, too.
>
> Many thanks.
>
> Bernard
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

bht
Reply | Threaded
Open this post in threaded view
|

Re: 1.5 equivalent of setRedirect(false); ?

bht
Martin,

Thanks very much, got the idea!

Regards,

Bernard

On Fri, 2 Sep 2011 09:31:39 +0200, you wrote:

>Wicket automatically decides whether redirect is needed for the
>current request or not depending on the configured
>org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy and by
>comparing the current url with the one that the IRequestMapper has
>generated for the page that is going to be rendered.
>I.e. if the current is: /my/mount/point and the page is stateful then
>the new url should be /my/mount/point?0 and Wicket will need to do a
>redirect. Otherwise Refresh button wont work, or at least wont refresh
>the current page but will create a new one. If you need to always
>create a new one then better make your page stateless or map this page
>with a custom IRequestMapper based on the default MountedMapper but
>not producing ?0.
>
>On Fri, Sep 2, 2011 at 8:18 AM,  <[hidden email]> wrote:
>> Hi,
>>
>> In 1.4, in a page constructor, we can call setRedirect(false);
>>
>> What is the equivalent of this in Wicket 1.5?
>>
>> The purpose of it is to avoid the creation of a new request. I am
>> aware of the consequences of doing this in 1.4, and I am prepared for
>> them in 1.5, too.
>>
>> Many thanks.
>>
>> Bernard
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: UrlEncoder - question mark not encoded for parameter values

Martin Grigorov-4
In reply to this post by pasto
Hi,

On Fri, Sep 2, 2011 at 2:12 AM, pasto <[hidden email]> wrote:

> Hi,
>
> while patching the original portlet support in Wicket 1.4 to Wicket 1.5, I
> run into 2 problems:
>
> 1) Url returned by the RequestMapper does not seem to be properly rendered,
> as it does not encode question mark character in the Url parameter value (I
> haven't checked the w3c spec, but at least Liferay Portal seems to require
> it to be encoded)
>
> The reason is this definition in the UrlEncoder:
>                        case QUERY :
>                                // to allow direct passing of URL in query
>                                dontNeedEncoding.set('/');
>                                // to allow direct passing of URL in query
>                                dontNeedEncoding.set('?');
File a bug for this. We need to verify it.
I also found a bug there few months ago so it is not impossible.
>
> Is it a bug or (according to the comment) a feature?
>
> 2) I could not find an easy way to make the markup ID unique across
> applications (multiple applications per page). The original portlet support
> adds a portlet identifier to the markup ID in the PortletRequestContext. Is
> there a way to do it in Wicket 1.5? (I haven't checked, if it's possible,
> but maybe a MarkupFilter?)
The unique id (its suffix) is generated by
org.apache.wicket.Session.nextSequenceValue().
Override it with something that will produce an unique id for your case.

>
> Thanks,
> Peter.
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785027.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: UrlEncoder - question mark not encoded for parameter values

pasto
Thanks a lot, somehow I did not expect it so be so easy to override :). I have filed a bug for the UrlEncoder https://issues.apache.org/jira/browse/WICKET-4019.

Peter.
Reply | Threaded
Open this post in threaded view
|

Re: UrlEncoder - question mark not encoded for parameter values

pasto
In reply to this post by Martin Grigorov-4
Now I remembered, why I did not check the 'nextSequenceValue'. It returns an integer and I don't know about any unique portlet identifier, that is a number and could be used to make the markup ID unique. Of course, I can generate a hash or use a part of the portlet name, but that does not look that nice. Is there a way, how to add a string to the markup ID?
Reply | Threaded
Open this post in threaded view
|

Re: UrlEncoder - question mark not encoded for parameter values

Martin Grigorov-4
use getMarkupId() to get the generated by Wicket and then
setMarkupId(orig + myUUID)

On Fri, Sep 2, 2011 at 11:05 AM, pasto <[hidden email]> wrote:

> Now I remembered, why I did not check the 'nextSequenceValue'. It returns an
> integer and I don't know about any unique portlet identifier, that is a
> number and could be used to make the markup ID unique. Of course, I can
> generate a hash or use a part of the portlet name, but that does not look
> that nice. Is there a way, how to add a string to the markup ID?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785658.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: UrlEncoder - question mark not encoded for parameter values

pasto
I might be missing something. But how to do this automatically for
every component that is being rendered?

On Fri, Sep 2, 2011 at 11:08 AM, Martin Grigorov-4 [via Apache Wicket]
<[hidden email]> wrote:

> use getMarkupId() to get the generated by Wicket and then
> setMarkupId(orig + myUUID)
>
> On Fri, Sep 2, 2011 at 11:05 AM, pasto <[hidden email]> wrote:
>> Now I remembered, why I did not check the 'nextSequenceValue'. It returns
>> an
>> integer and I don't know about any unique portlet identifier, that is a
>> number and could be used to make the markup ID unique. Of course, I can
>> generate a hash or use a part of the portlet name, but that does not look
>> that nice. Is there a way, how to add a string to the markup ID?
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785658.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785666.html
> To unsubscribe from UrlEncoder - question mark not encoded for parameter
> values, click here.
Reply | Threaded
Open this post in threaded view
|

Re: UrlEncoder - question mark not encoded for parameter values

Martin Grigorov-4
org.apache.wicket.Application.getComponentInitializationListeners().add(new
IComponentInitializationListener() {
  onInitialize(Component) {
//    do the trick here
  }
})

On Fri, Sep 2, 2011 at 11:16 AM, pasto <[hidden email]> wrote:

> I might be missing something. But how to do this automatically for
> every component that is being rendered?
>
> On Fri, Sep 2, 2011 at 11:08 AM, Martin Grigorov-4 [via Apache Wicket]
> <[hidden email]> wrote:
>> use getMarkupId() to get the generated by Wicket and then
>> setMarkupId(orig + myUUID)
>>
>> On Fri, Sep 2, 2011 at 11:05 AM, pasto <[hidden email]> wrote:
>>> Now I remembered, why I did not check the 'nextSequenceValue'. It returns
>>> an
>>> integer and I don't know about any unique portlet identifier, that is a
>>> number and could be used to make the markup ID unique. Of course, I can
>>> generate a hash or use a part of the portlet name, but that does not look
>>> that nice. Is there a way, how to add a string to the markup ID?
>>>
>>> --
>>> View this message in context:
>>> http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785658.html
>>> Sent from the Users forum mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>>
>> --
>> Martin Grigorov
>> jWeekend
>> Training, Consulting, Development
>> http://jWeekend.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785666.html
>> To unsubscribe from UrlEncoder - question mark not encoded for parameter
>> values, click here.
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785678.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: UrlEncoder - question mark not encoded for parameter values

pasto
aah, that was really long time ago, when I used this for SpringComponentInjector, thanks for the tip.
Peter.