You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Serban Balamaci <se...@asf.ro> on 2011/04/11 17:06:47 UTC

Wicket 1.5 PageParameters vs IRequestParameters question.

Hello everybody, I''m in the process of migrating an app from 1.4 to 1.5-RC3
 
I see that the PageParameters and IRequestParameters are pretty separate
things now. Any reason why it's done this way and why they not extend a
Common Interface that exposes methods like getParameterNames
getParameterValue. 

Because I  have this usecase: I try to keep a stateless page by heavily
encoding state in the pageParameters, so on different actions I'm resending
parameters that I initially received on this page.
In 1.4 there was no difference in handling parameters that came from
constructor WebPage(final PageParameters parameters) and those that were
received in the request( RequestCycle.get().getPageParameters()) and there
was very easy to reuse the same parameters received in the request - clone 

Is it an easy method to create PageParameters from IRequestParameters(which
I get from RequestCycle.get().getRequest().getRequestParameters()), or
iterating and adding them to PageParameters is the way to go?

Thank you.

-----
http://balamaci.wordpress.com 
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-PageParameters-vs-IRequestParameters-question-tp3442239p3442239.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: Wicket 1.5 PageParameters vs IRequestParameters question.

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

Feel free to create a patch with your proposed changes (IParams) and we will
consider it.
About stateless - see https://github.com/martin-g/wicket-stateless and
https://github.com/robmcguinness/wicket-stateless
 <https://github.com/robmcguinness/wicket-stateless>Those are Jolira's
ported to 1.5.

To work they need a patch in o.a.wicket.Behaviors.java which looks like:
--- wicket-core/src/main/java/org/apache/wicket/Behaviors.java (revision
1091311)
+++ wicket-core/src/main/java/org/apache/wicket/Behaviors.java (working
copy)
@@ -56,6 +56,7 @@
  }

  internalAdd(behavior);
+                      getBehaviorId(behavior);

but it breaks few test expectations and I haven't had time to see whether
this is harmful somehow.

On Tue, Apr 12, 2011 at 10:51 AM, Serban Balamaci <se...@asf.ro>wrote:

> Hello Pedro,
> In my mind IRequestParameters and PageParameters should have stemmed from a
> common interface, extend some even generic one like(IKeyValues, IParams)
> but
> I trust you guys see the bigger picture maybe IRequestParameters is a very
> generic thing that doesn't have to mean a page's parameters.
>
> By
> "IRequestParameters interface has PageParameters correspondent API to
> access
> page parameters. Can be accessed like:
> RequestCycle.get().getRequest().getQueryParameters()" you mean that
> IRequestParameters has methods present in PageParameters? (yes I know, that
> why I thought the methods could have been shared in a common interface).
>
> "If you want to recreate page parameters for some request, you can use the
> PageParametersEncoder". It seems that PageParametersEncoder handles how the
> parameters are rendered in the url(declared somehow like mounting pages)
> and
> I guess it does not have access to the original page parameters. And not
> all
> the parameters must be cloned, some must get overwritten and reflect the
> new
> state of the page.
>
> What I had in the original code is that I would have a helper method:
> public static PageParameters keepPageParameters(PageParameters pageParams,
> String[] paramNamesToKeep) {
> // iterate through pageParams and recreate those with matching names
> }
>
> and pass these parameters to bookmarkablepagelinks. I would use this method
> from PageParameters coming both from super(PageParameters) and
> RequestCycle.get().getPageParameters().
>
> Now I must have two methods one that handles PageParameters and one that
> handles , actually I have just  one method now
> public static PageParameters keepRequestPageParameters(IRequestParameters
> pageParams, String[] paramNamesToKeep) and always get my parameters from
> RequestCycle.get().getRequest().getQueryParameters() not from
>
> but it would have been better in my opinion to have a
> public static PageParameters keepPageParameters(IParams pageParams,
> String[]
> paramNamesToKeep) {
> }
>
> Btw does someone have a better way of keeping page parameters from one page
> to another. I like the utility method that I see in the page I'm working on
> what parameters I'm working with.
>
> I have not looked upon the new request cycle, I plan to, as migration to
> 1.5
> is triggered by the feeling that somehow stateless ajax behaviours would be
> easier to implement in 1.5. My current approach to  was to have zero
> compile
> errors and then understand what is changed internally.
>
> Regards
>
>
> -----
> http://balamaci.wordpress.com
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-PageParameters-vs-IRequestParameters-question-tp3442239p3444058.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 <http://jweekend.com/>

Re: Wicket 1.5 PageParameters vs IRequestParameters question.

Posted by Serban Balamaci <se...@asf.ro>.
Hello Pedro,
In my mind IRequestParameters and PageParameters should have stemmed from a
common interface, extend some even generic one like(IKeyValues, IParams) but
I trust you guys see the bigger picture maybe IRequestParameters is a very
generic thing that doesn't have to mean a page's parameters.

By 
"IRequestParameters interface has PageParameters correspondent API to access 
page parameters. Can be accessed like: 
RequestCycle.get().getRequest().getQueryParameters()" you mean that
IRequestParameters has methods present in PageParameters? (yes I know, that
why I thought the methods could have been shared in a common interface).

"If you want to recreate page parameters for some request, you can use the 
PageParametersEncoder". It seems that PageParametersEncoder handles how the
parameters are rendered in the url(declared somehow like mounting pages) and
I guess it does not have access to the original page parameters. And not all
the parameters must be cloned, some must get overwritten and reflect the new
state of the page.

What I had in the original code is that I would have a helper method:
public static PageParameters keepPageParameters(PageParameters pageParams,
String[] paramNamesToKeep) {
// iterate through pageParams and recreate those with matching names
}

and pass these parameters to bookmarkablepagelinks. I would use this method
from PageParameters coming both from super(PageParameters) and
RequestCycle.get().getPageParameters().

Now I must have two methods one that handles PageParameters and one that
handles , actually I have just  one method now
public static PageParameters keepRequestPageParameters(IRequestParameters
pageParams, String[] paramNamesToKeep) and always get my parameters from
RequestCycle.get().getRequest().getQueryParameters() not from 

but it would have been better in my opinion to have a 
public static PageParameters keepPageParameters(IParams pageParams, String[]
paramNamesToKeep) {
}

Btw does someone have a better way of keeping page parameters from one page
to another. I like the utility method that I see in the page I'm working on
what parameters I'm working with.

I have not looked upon the new request cycle, I plan to, as migration to 1.5
is triggered by the feeling that somehow stateless ajax behaviours would be
easier to implement in 1.5. My current approach to  was to have zero compile
errors and then understand what is changed internally.

Regards


-----
http://balamaci.wordpress.com 
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-PageParameters-vs-IRequestParameters-question-tp3442239p3444058.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: Wicket 1.5 PageParameters vs IRequestParameters question.

Posted by Pedro Santos <pe...@gmail.com>.
IRequestParameters interface has PageParameters correspondent API to access
page parameters. Can be accessed like:
RequestCycle.get().getRequest().getQueryParameters()

If you want to recreate page parameters for some request, you can use the
PageParametersEncoder.


On Mon, Apr 11, 2011 at 12:06 PM, Serban Balamaci <se...@asf.ro>wrote:

> Hello everybody, I''m in the process of migrating an app from 1.4 to
> 1.5-RC3
>
> I see that the PageParameters and IRequestParameters are pretty separate
> things now. Any reason why it's done this way and why they not extend a
> Common Interface that exposes methods like getParameterNames
> getParameterValue.
>
> Because I  have this usecase: I try to keep a stateless page by heavily
> encoding state in the pageParameters, so on different actions I'm resending
> parameters that I initially received on this page.
> In 1.4 there was no difference in handling parameters that came from
> constructor WebPage(final PageParameters parameters) and those that were
> received in the request( RequestCycle.get().getPageParameters()) and there
> was very easy to reuse the same parameters received in the request - clone
>
> Is it an easy method to create PageParameters from IRequestParameters(which
> I get from RequestCycle.get().getRequest().getRequestParameters()), or
> iterating and adding them to PageParameters is the way to go?
>
> Thank you.
>
> -----
> http://balamaci.wordpress.com
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Wicket-1-5-PageParameters-vs-IRequestParameters-question-tp3442239p3442239.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
>
>


-- 
Pedro Henrique Oliveira dos Santos