You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by pasto <pe...@gmail.com> on 2011/09/02 02:12:01 UTC

UrlEncoder - question mark not encoded for parameter values

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.


--
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: 1.5 equivalent of setRedirect(false); ?

Posted by bh...@actrix.gen.nz.
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,  <bh...@actrix.gen.nz> 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: 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


Re: 1.5 equivalent of setRedirect(false); ?

Posted by Martin Grigorov <mg...@apache.org>.
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,  <bh...@actrix.gen.nz> 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: 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


1.5 equivalent of setRedirect(false); ?

Posted by bh...@actrix.gen.nz.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: UrlEncoder - question mark not encoded for parameter values

Posted by pasto <pe...@gmail.com>.
aah, that was really long time ago, when I used this for
SpringComponentInjector, thanks for the tip. 
Peter.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785702.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: UrlEncoder - question mark not encoded for parameter values

Posted by Martin Grigorov <mg...@apache.org>.
org.apache.wicket.Application.getComponentInitializationListeners().add(new
IComponentInitializationListener() {
  onInitialize(Component) {
//    do the trick here
  }
})

On Fri, Sep 2, 2011 at 11:16 AM, pasto <pe...@gmail.com> 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]
> <ml...@n4.nabble.com> 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: 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: UrlEncoder - question mark not encoded for parameter values

Posted by pasto <pe...@gmail.com>.
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]
<ml...@n4.nabble.com> 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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: UrlEncoder - question mark not encoded for parameter values

Posted by Martin Grigorov <mg...@apache.org>.
use getMarkupId() to get the generated by Wicket and then
setMarkupId(orig + myUUID)

On Fri, Sep 2, 2011 at 11:05 AM, pasto <pe...@gmail.com> 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: 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: UrlEncoder - question mark not encoded for parameter values

Posted by pasto <pe...@gmail.com>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: UrlEncoder - question mark not encoded for parameter values

Posted by pasto <pe...@gmail.com>.
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.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/UrlEncoder-question-mark-not-encoded-for-parameter-values-tp3785027p3785632.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: UrlEncoder - question mark not encoded for parameter values

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

On Fri, Sep 2, 2011 at 2:12 AM, pasto <pe...@gmail.com> 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: 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