You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by venky221 <ve...@splashnote.com> on 2008/08/21 22:37:38 UTC
Object in PageParameters
How can I pass an object in PageParameters.
I am doing like this
onSubmit(){
UserVO user = (userVO)getModelObject();
PageParameters params = new PageParameters();
params.put("user",user);
setRedirect(true);
setResponsePage(ValidateUser.class, params);
}
ValidateUser's constructor:
ValidateUser(PageParameters params){
UserVO user = (UserVO) params.get("user");
}
and its throwing InvocationTargetException.
I can use the constructor of ValidateUser to accept UserVO object and
redirect after instantiating but I want to send the object through
PageParameters.
Some pointers please on how can I achieve this and what URLCodingStratergy I
need to use??
--
View this message in context: http://www.nabble.com/Object-in-PageParameters-tp19096413p19096413.html
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: Object in PageParameters
Posted by Jeremy Thomerson <je...@wickettraining.com>.
Everything in PageParameters needs to boil down to a String. PageParameters
are put in your URL. You could, for instance, put user ID (but of course,
depending on the application, this may not be safe - URL fiddling could give
access to other users, etc...).
If you do not need a bookmarkable URL for this page, just do this:
onSubmit(){
setResponsePage(new ValidateUser((UserVO)getModelObject()));
}
Or, if you need the bookmarkable URL, you will need to put some key to pull
up the user in the PageParameters, like:
onSubmit(){
UserVO user = (UserVO)getModelObject();
PageParameters params = new PageParameters();
params.put("user", user.getUniqueKey());
setRedirect(true);
setResponsePage(ValidateUser.class, params);
}
ValidateUser's constructor:
ValidateUser(PageParameters params){
final String userKey = params.getString("user");
setModel(new LoadableDetachableModel<UserVO>() {
public UserVO load() {
getMyUserService().findByUniqueKey(userKey);
}
}
}
Hope this helps.
--
Jeremy Thomerson
http://www.wickettraining.com
On Thu, Aug 21, 2008 at 3:37 PM, venky221 <ve...@splashnote.com> wrote:
>
> How can I pass an object in PageParameters.
>
> I am doing like this
>
> onSubmit(){
> UserVO user = (userVO)getModelObject();
> PageParameters params = new PageParameters();
> params.put("user",user);
>
> setRedirect(true);
> setResponsePage(ValidateUser.class, params);
> }
>
> ValidateUser's constructor:
>
> ValidateUser(PageParameters params){
> UserVO user = (UserVO) params.get("user");
> }
>
> and its throwing InvocationTargetException.
>
> I can use the constructor of ValidateUser to accept UserVO object and
> redirect after instantiating but I want to send the object through
> PageParameters.
>
> Some pointers please on how can I achieve this and what URLCodingStratergy
> I
> need to use??
> --
> View this message in context:
> http://www.nabble.com/Object-in-PageParameters-tp19096413p19096413.html
> 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
>
>