Hi,
On Wed, Aug 17, 2016 at 2:58 PM, senlog80 <[email protected]> wrote:
> I have a form on my page, which when submitted goes the next page, but all
> the form's fields appear as URL parameters in the resulting page. I want
> to
> hide all the parameters in the url, so that I am using POST request but
> still it shows the parameters in the resulting page.
>
> My sample code
> -------------------
> HomePage.java
> ------------------
> PageParameters pp = new PageParameters();
> pp.add("lastName", lastName);
> pp.add("firstName", firstName);
> pp.add("commonName", commonName);
> pp.add("localeStr", localeStr);
> throw new RestartResponseException(UserDetailPage.class, pp);
>
The form submit POST request ends here.
>From now on a new GET request is issued with url like
/user/details?lastName=last&firstName=first...
>
> UserDetailPage
> ----------------
> public UserDetailPage(final PageParameters parameters) {
> String lastName = parameters.get("lastName").toString();
> String firstName = parameters.get("firstName").toString();
> String commonName = parameters.get("commonName").
> toString();
> userForm = new UserForm("modifyForm", parameters);
> add(userForm);
>
> UserForm.java
> ----------------
> public UserForm(String id, PageParameters parameters) {
> super(id);
> String typeFlagValue = "COMMON";
> if (parameters != null)
> {
> this.localeStr = parameters.get("localeStr").
> toString();
> this.userDN = parameters.get("parentDN").
> toString();
> this.userName = parameters.get("commonName").
> toString();
> this.firstName = parameters.get("firstName").
> toString();
> this.lastName = parameters.get("lastName").
> toString();
> }
>
> Actually, From the HomePage.java, the request parameters are passed to
> UserDetailPage.java. This UserDetailPage.java takes the reference Userform
> and shows the result in the GUI.
>
> So, the page parameters lastName, firstName, commonName, etc.. are shown in
> the URL of result page.
> We are using Bookmarakable Page.
>
> If I use the "throw new RestartResponseException(new UserDetailPage(pp));"
> instead of "throw new RestartResponseException(UserDetailPage.class, pp);"
> in HomePage.java then the URL hides the parameters in the URL. But I think
> this is stateful. Is it ok??
>
IMO the best for your use case if to not use Wicket Form at all in HomePage.
Use a normal HTML form: <form action="/user/details" method="POST">.
This will go directly to UserDetailsPage where you can read the parameters
with getRequest().getPostParameters()
>
> Could you provide the suggestions..
>
> --
> View this message in context: http://apache-wicket.1842946.
> n4.nabble.com/POST-request-shows-the-parameters-in-the-
> URL-of-result-page-tp4675323.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>