You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Dariusz Wojtas <dw...@gmail.com> on 2007/08/05 14:29:13 UTC

mountBookmarkablePage and missing parameters - exception thrown

Hi,

I am experimenting with parameters passed to pages mounted this way (as
shown in wicket-examples):
   mountBookmarkablePage("/navi", ProductCategoryPage.class);

When I add a parameter (cat=value) to such page, when rendered, it may look
like this:
   http://localhost:8080/testApp/app/navi/cat/value
and that's fine, works nicely.
But what if the user cuts the link and tries:
   http://localhost:8080/testApp/app/navi/cat/
or
   http://localhost:8080/testApp/app/navi/cat
?

java.lang.IllegalStateException: URL fragment has unmatched key/value pair:
cat
     at
org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy.decodeParameters(AbstractRequestTargetUrlCodingStrategy.java:165)
     at
org.apache.wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy.decode(BookmarkablePageRequestTargetUrlCodingStrategy.java:76)
     at
org.apache.wicket.protocol.http.request.WebRequestCodingStrategy.targetForRequest(WebRequestCodingStrategy.java:373)
     at
org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:175)
     at org.apache.wicket.RequestCycle.step(RequestCycle.java:1090)
     at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1176)
     at org.apache.wicket.RequestCycle.request(RequestCycle.java:499)
     at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:257)
     at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:127)

This exception could be optional (configurable somewhere), as it is normal
for me (and probably many other users of the net) to cut/shorten such links
to go to the parent 'category' or topic. I do it all the time with
downloads, with blogs or other internet stuff that has nice URLs.
Providing a general error page here is not what I would expect.

I know that some param is not matched with value, but this is different
behaviour from identical situation when I use the 'traditional' CGI-like
params.
If I cut something from URL
   http://localhost:8080/testApp/app/navi?cat=value&cat2=val2
and leave
   http://localhost:8080/testApp/app/navi?cat=&cat2=
then it still works and does not throw exceptions.

I would rather expect that the value for such param is null instead of
throwing exceptions.

Is this something for a JIRA ticket or well discussed, known and wanted
behaviour?

I am using wicket 1.3 beta 2

Regards

Dariusz Wojtas
-- 
View this message in context: http://www.nabble.com/mountBookmarkablePage-and-missing-parameters---exception-thrown-tf4219655.html#a12004300
Sent from the Wicket - User 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: mountBookmarkablePage and missing parameters - exception thrown

Posted by chickabee <ja...@gmail.com>.
I believe the
org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy.decodeParameters(),
shold not throw a RunTime Exception as it does now,  if the url is tampered,
instead it should always provide the parameters and values to it's best
guess and then let the user decided how the request needs to be processed.

Also, org.apache.wicket.PageParameters, should provide one iterator with all
available params, 

Any comments?

================================


igor.vaynberg wrote:
> 
> On 8/8/07, Dariusz Wojtas <dw...@gmail.com> wrote:
>>
>> I want to use it in cases where the user may be given feeling that he is
>> browsing some structure.
> 
> 
> well, my point was that structure is probably better represented by
> indexed
> coding strategy, which is forgiving. for example
> 
> /products/clothes/tshirts/red (indexed)
> 
> is better imho then
> 
> /products/category/clothes/subcategory/tshirts/color/red (default)
> 
> -igor
> 
> 

-- 
View this message in context: http://www.nabble.com/mountBookmarkablePage-and-missing-parameters---exception-thrown-tf4219655.html#a12590494
Sent from the Wicket - User 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: mountBookmarkablePage and missing parameters - exception thrown

Posted by Igor Vaynberg <ig...@gmail.com>.
On 8/8/07, Dariusz Wojtas <dw...@gmail.com> wrote:
>
> I want to use it in cases where the user may be given feeling that he is
> browsing some structure.


well, my point was that structure is probably better represented by indexed
coding strategy, which is forgiving. for example

/products/clothes/tshirts/red (indexed)

is better imho then

/products/category/clothes/subcategory/tshirts/color/red (default)

-igor

Re: mountBookmarkablePage and missing parameters - exception thrown

Posted by Dariusz Wojtas <dw...@gmail.com>.
I believe this syntax should be forgiving to the user.
A framework should ease life where possible.
What is the benefit of encoding URLs
   /param1/value1/param2/value2
over
   ?param1=value1&param2=value2
?
The way it is shown to the users. Not for developers. And not only for
search engine spiders.
I want to use it in cases where the user may be given feeling that he is
browsing some structure.
If we say 'a' and hide the implementation details from users - then why to
prohibit saying 'b'?

The only thing that should be checked (possibly already works) is to check
if shorter path does not make incorrect assumptions on the nesting level
when referring resources like CSS or IMG files.
It matters if it generates
  '../../../style.css'
or
  '../../style.css'
But possibly this is already working.

Darek




Eelco Hillenius wrote:
> 
>> i dont see why we should support this.
>> if you expect the user to mess with your urls then you should either
>> leave
>> it as a query string or use indexed coding strat. imho we should fail
>> early
>> - imagine looking at logs and trying to figure out wtf that url came
>> from.
>> could it be a wicket encoding problem? user messed with it? etc etc.
> 
> I don't think it's always bad if people mess with parameters,
> especially not when it concerns paths like Dariusz mentioned. To me,
> it is natural to directly play with a path, though I wouldn't play
> with parameters if they come in the form ?foo=bar. I would prefer
> Wicket to be more forgiving and let users decide whether they have
> enough information to process a request.
> 
>> the code to support this wouldnt be hairy at all - just remove the check
>> and
>> see if param is missing and add it as ""...hmm or maybe better to add it
>> as
>> null? see what i mean.
> 
> Yeah, that's the kind of hairyness I meant. Then again, that could be
> just a setting.
> 
> Eelco
> 

-- 
View this message in context: http://www.nabble.com/mountBookmarkablePage-and-missing-parameters---exception-thrown-tf4219655.html#a12061758
Sent from the Wicket - User 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: mountBookmarkablePage and missing parameters - exception thrown

Posted by Eelco Hillenius <ee...@gmail.com>.
> i dont see why we should support this.
> if you expect the user to mess with your urls then you should either leave
> it as a query string or use indexed coding strat. imho we should fail early
> - imagine looking at logs and trying to figure out wtf that url came from.
> could it be a wicket encoding problem? user messed with it? etc etc.

I don't think it's always bad if people mess with parameters,
especially not when it concerns paths like Dariusz mentioned. To me,
it is natural to directly play with a path, though I wouldn't play
with parameters if they come in the form ?foo=bar. I would prefer
Wicket to be more forgiving and let users decide whether they have
enough information to process a request.

> the code to support this wouldnt be hairy at all - just remove the check and
> see if param is missing and add it as ""...hmm or maybe better to add it as
> null? see what i mean.

Yeah, that's the kind of hairyness I meant. Then again, that could be
just a setting.

Eelco

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


Re: mountBookmarkablePage and missing parameters - exception thrown

Posted by Igor Vaynberg <ig...@gmail.com>.
i dont see why we should support this.
if you expect the user to mess with your urls then you should either leave
it as a query string or use indexed coding strat. imho we should fail early
- imagine looking at logs and trying to figure out wtf that url came from.
could it be a wicket encoding problem? user messed with it? etc etc.

the code to support this wouldnt be hairy at all - just remove the check and
see if param is missing and add it as ""...hmm or maybe better to add it as
null? see what i mean.

-igor

On 8/6/07, Eelco Hillenius <ee...@gmail.com> wrote:
>
> On 8/5/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > mount with indexed url coding strategy if you dont mind users messing
> > with your urls.
>
> I think it's kind of annoying as well. Are we (Wicket devs) really
> against supporting this, or don't we support it because the code gets
> a bit hairy?
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: mountBookmarkablePage and missing parameters - exception thrown

Posted by Eelco Hillenius <ee...@gmail.com>.
On 8/5/07, Igor Vaynberg <ig...@gmail.com> wrote:
> mount with indexed url coding strategy if you dont mind users messing
> with your urls.

I think it's kind of annoying as well. Are we (Wicket devs) really
against supporting this, or don't we support it because the code gets
a bit hairy?

Eelco

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


Re: mountBookmarkablePage and missing parameters - exception thrown

Posted by Igor Vaynberg <ig...@gmail.com>.
mount with indexed url coding strategy if you dont mind users messing
with your urls.

-igor


On 8/5/07, Dariusz Wojtas <dw...@gmail.com> wrote:
>
> Hi,
>
> I am experimenting with parameters passed to pages mounted this way (as
> shown in wicket-examples):
>    mountBookmarkablePage("/navi", ProductCategoryPage.class);
>
> When I add a parameter (cat=value) to such page, when rendered, it may look
> like this:
>    http://localhost:8080/testApp/app/navi/cat/value
> and that's fine, works nicely.
> But what if the user cuts the link and tries:
>    http://localhost:8080/testApp/app/navi/cat/
> or
>    http://localhost:8080/testApp/app/navi/cat
> ?
>
> java.lang.IllegalStateException: URL fragment has unmatched key/value pair:
> cat
>      at
> org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy.decodeParameters(AbstractRequestTargetUrlCodingStrategy.java:165)
>      at
> org.apache.wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy.decode(BookmarkablePageRequestTargetUrlCodingStrategy.java:76)
>      at
> org.apache.wicket.protocol.http.request.WebRequestCodingStrategy.targetForRequest(WebRequestCodingStrategy.java:373)
>      at
> org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:175)
>      at org.apache.wicket.RequestCycle.step(RequestCycle.java:1090)
>      at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1176)
>      at org.apache.wicket.RequestCycle.request(RequestCycle.java:499)
>      at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:257)
>      at
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:127)
>
> This exception could be optional (configurable somewhere), as it is normal
> for me (and probably many other users of the net) to cut/shorten such links
> to go to the parent 'category' or topic. I do it all the time with
> downloads, with blogs or other internet stuff that has nice URLs.
> Providing a general error page here is not what I would expect.
>
> I know that some param is not matched with value, but this is different
> behaviour from identical situation when I use the 'traditional' CGI-like
> params.
> If I cut something from URL
>    http://localhost:8080/testApp/app/navi?cat=value&cat2=val2
> and leave
>    http://localhost:8080/testApp/app/navi?cat=&cat2=
> then it still works and does not throw exceptions.
>
> I would rather expect that the value for such param is null instead of
> throwing exceptions.
>
> Is this something for a JIRA ticket or well discussed, known and wanted
> behaviour?
>
> I am using wicket 1.3 beta 2
>
> Regards
>
> Dariusz Wojtas
> --
> View this message in context: http://www.nabble.com/mountBookmarkablePage-and-missing-parameters---exception-thrown-tf4219655.html#a12004300
> Sent from the Wicket - User 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
>
>

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