You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Stefan Lindner <li...@visionet.de> on 2008/10/02 17:41:38 UTC

Form submit to bookmarkable page

Is it possible to submit a form to a bookmarkable page (with form input
as page parameters)?
What I want is a form with a submit button/link that leads to a page
with e.g. URl

     http://mysite.com/myapp/targetPage/param1/value1/param2/value2

Of course I mount the submit link#s target page class in
Application.init() { mountBookmarkablePage ("targetPage",
MyTargetPage.class); }

Any hint?

Stefan

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


RE: Form submit to bookmarkable page

Posted by Stefan Lindner <li...@visionet.de>.
The solution, if anybody else should encounter this problem ist to put
the following into the onSubmitMethod

	PageParameters p = new PageParameters();
	p.add("myParameterName", <getModelObjectOfFormComponent()>);
	getResponse().redirect(urlFor(MyTargetPage.class,
p).toString());
	getRequestCycle().setRedirect(false);

and mount the page as bookmarkable page in Application.init().
Then the resulting URL is

	http://myApp/MyTargetPage/myParameterName/value

Stefan

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


RE: Form submit to bookmarkable page

Posted by Stefan Lindner <li...@visionet.de>.
Thank you Igor for your patience and your code fragments.

Stefan

-----Ursprüngliche Nachricht-----
Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Gesendet: Donnerstag, 2. Oktober 2008 23:20
An: users@wicket.apache.org
Betreff: Re: Form submit to bookmarkable page

onsubmit() {
getRequestCycle().setRequestTarget(new RedirectRequestTarget(myurl));
}

-igor

On Thu, Oct 2, 2008 at 2:12 PM, Stefan Lindner <li...@visionet.de> wrote:
> OK. But how to
>
> " and in onsubmit construct the url and redirect to it."
>
> The only methods for redirects I know are the redirectToInterceptPage method or the setResponsePage methods. An each method needs a page class as parameter an not a self constructed url. I did not find a auitable method in the requestCyle.
>
> How can I set the URL for the response?
>
> Stefan
>
> -----Ursprüngliche Nachricht-----
> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Gesendet: Donnerstag, 2. Oktober 2008 22:40
> An: users@wicket.apache.org
> Betreff: Re: Form submit to bookmarkable page
>
> if anything you can change the form.getmethod() to return GET, but
> even then it is the browser that will be doing the encoding and
> construcing the final url.
>
> if you really want a clean url like that you will have to use a
> regular form and in onsubmit construct the url and redirect to it.
>
> -igor
>
> On Thu, Oct 2, 2008 at 12:27 PM, Stefan Lindner <li...@visionet.de> wrote:
>> Wow! Seems to be a good starting point. I'm using wicket for 2 years now but still got a lot to learn. Sigh!
>> Now I have a form with a simple submit button. In the Form's onComponentTag I have
>>
>>     tag.put("action", urlFor(TargetPage.class, parameters));
>>
>> The URL now looks like
>>
>>     http://mysite.com/myapp/TargetPage
>>
>> That's a great leap forward. But is there any trick to have the Form's input fields as parameters in the URL? If the Form e.g. has an InputField called "parameter" the URL should look like
>>
>>     http://mysite.com/myapp/TargetPage/parameter/value
>>
>> or somethind similar? I have tried several URL encodings but all oft hem led tot he result
>>
>>     http://mysite.com/myapp/TargetPage
>>
>> Stefan
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> Gesendet: Donnerstag, 2. Oktober 2008 18:06
>> An: users@wicket.apache.org
>> Betreff: Re: Form submit to bookmarkable page
>>
>> you can override form's oncomponenttag() and call super then
>> tag.put(action, urlfor(yourpage.class));
>>
>> i believe that should work
>>
>> -igor
>>
>> On Thu, Oct 2, 2008 at 8:41 AM, Stefan Lindner <li...@visionet.de> wrote:
>>> Is it possible to submit a form to a bookmarkable page (with form input
>>> as page parameters)?
>>> What I want is a form with a submit button/link that leads to a page
>>> with e.g. URl
>>>
>>>     http://mysite.com/myapp/targetPage/param1/value1/param2/value2
>>>
>>> Of course I mount the submit link#s target page class in
>>> Application.init() { mountBookmarkablePage ("targetPage",
>>> MyTargetPage.class); }
>>>
>>> Any hint?
>>>
>>> Stefan
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
> ---------------------------------------------------------------------
> 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


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


Re: Form submit to bookmarkable page

Posted by Igor Vaynberg <ig...@gmail.com>.
onsubmit() {
getRequestCycle().setRequestTarget(new RedirectRequestTarget(myurl));
}

-igor

On Thu, Oct 2, 2008 at 2:12 PM, Stefan Lindner <li...@visionet.de> wrote:
> OK. But how to
>
> " and in onsubmit construct the url and redirect to it."
>
> The only methods for redirects I know are the redirectToInterceptPage method or the setResponsePage methods. An each method needs a page class as parameter an not a self constructed url. I did not find a auitable method in the requestCyle.
>
> How can I set the URL for the response?
>
> Stefan
>
> -----Ursprüngliche Nachricht-----
> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Gesendet: Donnerstag, 2. Oktober 2008 22:40
> An: users@wicket.apache.org
> Betreff: Re: Form submit to bookmarkable page
>
> if anything you can change the form.getmethod() to return GET, but
> even then it is the browser that will be doing the encoding and
> construcing the final url.
>
> if you really want a clean url like that you will have to use a
> regular form and in onsubmit construct the url and redirect to it.
>
> -igor
>
> On Thu, Oct 2, 2008 at 12:27 PM, Stefan Lindner <li...@visionet.de> wrote:
>> Wow! Seems to be a good starting point. I'm using wicket for 2 years now but still got a lot to learn. Sigh!
>> Now I have a form with a simple submit button. In the Form's onComponentTag I have
>>
>>     tag.put("action", urlFor(TargetPage.class, parameters));
>>
>> The URL now looks like
>>
>>     http://mysite.com/myapp/TargetPage
>>
>> That's a great leap forward. But is there any trick to have the Form's input fields as parameters in the URL? If the Form e.g. has an InputField called "parameter" the URL should look like
>>
>>     http://mysite.com/myapp/TargetPage/parameter/value
>>
>> or somethind similar? I have tried several URL encodings but all oft hem led tot he result
>>
>>     http://mysite.com/myapp/TargetPage
>>
>> Stefan
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
>> Gesendet: Donnerstag, 2. Oktober 2008 18:06
>> An: users@wicket.apache.org
>> Betreff: Re: Form submit to bookmarkable page
>>
>> you can override form's oncomponenttag() and call super then
>> tag.put(action, urlfor(yourpage.class));
>>
>> i believe that should work
>>
>> -igor
>>
>> On Thu, Oct 2, 2008 at 8:41 AM, Stefan Lindner <li...@visionet.de> wrote:
>>> Is it possible to submit a form to a bookmarkable page (with form input
>>> as page parameters)?
>>> What I want is a form with a submit button/link that leads to a page
>>> with e.g. URl
>>>
>>>     http://mysite.com/myapp/targetPage/param1/value1/param2/value2
>>>
>>> Of course I mount the submit link#s target page class in
>>> Application.init() { mountBookmarkablePage ("targetPage",
>>> MyTargetPage.class); }
>>>
>>> Any hint?
>>>
>>> Stefan
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
> ---------------------------------------------------------------------
> 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: Form submit to bookmarkable page

Posted by Stefan Lindner <li...@visionet.de>.
OK. But how to 

" and in onsubmit construct the url and redirect to it."

The only methods for redirects I know are the redirectToInterceptPage method or the setResponsePage methods. An each method needs a page class as parameter an not a self constructed url. I did not find a auitable method in the requestCyle.

How can I set the URL for the response?

Stefan

-----Ursprüngliche Nachricht-----
Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Gesendet: Donnerstag, 2. Oktober 2008 22:40
An: users@wicket.apache.org
Betreff: Re: Form submit to bookmarkable page

if anything you can change the form.getmethod() to return GET, but
even then it is the browser that will be doing the encoding and
construcing the final url.

if you really want a clean url like that you will have to use a
regular form and in onsubmit construct the url and redirect to it.

-igor

On Thu, Oct 2, 2008 at 12:27 PM, Stefan Lindner <li...@visionet.de> wrote:
> Wow! Seems to be a good starting point. I'm using wicket for 2 years now but still got a lot to learn. Sigh!
> Now I have a form with a simple submit button. In the Form's onComponentTag I have
>
>     tag.put("action", urlFor(TargetPage.class, parameters));
>
> The URL now looks like
>
>     http://mysite.com/myapp/TargetPage
>
> That's a great leap forward. But is there any trick to have the Form's input fields as parameters in the URL? If the Form e.g. has an InputField called "parameter" the URL should look like
>
>     http://mysite.com/myapp/TargetPage/parameter/value
>
> or somethind similar? I have tried several URL encodings but all oft hem led tot he result
>
>     http://mysite.com/myapp/TargetPage
>
> Stefan
>
> -----Ursprüngliche Nachricht-----
> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Gesendet: Donnerstag, 2. Oktober 2008 18:06
> An: users@wicket.apache.org
> Betreff: Re: Form submit to bookmarkable page
>
> you can override form's oncomponenttag() and call super then
> tag.put(action, urlfor(yourpage.class));
>
> i believe that should work
>
> -igor
>
> On Thu, Oct 2, 2008 at 8:41 AM, Stefan Lindner <li...@visionet.de> wrote:
>> Is it possible to submit a form to a bookmarkable page (with form input
>> as page parameters)?
>> What I want is a form with a submit button/link that leads to a page
>> with e.g. URl
>>
>>     http://mysite.com/myapp/targetPage/param1/value1/param2/value2
>>
>> Of course I mount the submit link#s target page class in
>> Application.init() { mountBookmarkablePage ("targetPage",
>> MyTargetPage.class); }
>>
>> Any hint?
>>
>> Stefan
>>
>> ---------------------------------------------------------------------
>> 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
>
>
> ---------------------------------------------------------------------
> 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


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


Re: Form submit to bookmarkable page

Posted by Igor Vaynberg <ig...@gmail.com>.
if anything you can change the form.getmethod() to return GET, but
even then it is the browser that will be doing the encoding and
construcing the final url.

if you really want a clean url like that you will have to use a
regular form and in onsubmit construct the url and redirect to it.

-igor

On Thu, Oct 2, 2008 at 12:27 PM, Stefan Lindner <li...@visionet.de> wrote:
> Wow! Seems to be a good starting point. I'm using wicket for 2 years now but still got a lot to learn. Sigh!
> Now I have a form with a simple submit button. In the Form's onComponentTag I have
>
>     tag.put("action", urlFor(TargetPage.class, parameters));
>
> The URL now looks like
>
>     http://mysite.com/myapp/TargetPage
>
> That's a great leap forward. But is there any trick to have the Form's input fields as parameters in the URL? If the Form e.g. has an InputField called "parameter" the URL should look like
>
>     http://mysite.com/myapp/TargetPage/parameter/value
>
> or somethind similar? I have tried several URL encodings but all oft hem led tot he result
>
>     http://mysite.com/myapp/TargetPage
>
> Stefan
>
> -----Ursprüngliche Nachricht-----
> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Gesendet: Donnerstag, 2. Oktober 2008 18:06
> An: users@wicket.apache.org
> Betreff: Re: Form submit to bookmarkable page
>
> you can override form's oncomponenttag() and call super then
> tag.put(action, urlfor(yourpage.class));
>
> i believe that should work
>
> -igor
>
> On Thu, Oct 2, 2008 at 8:41 AM, Stefan Lindner <li...@visionet.de> wrote:
>> Is it possible to submit a form to a bookmarkable page (with form input
>> as page parameters)?
>> What I want is a form with a submit button/link that leads to a page
>> with e.g. URl
>>
>>     http://mysite.com/myapp/targetPage/param1/value1/param2/value2
>>
>> Of course I mount the submit link#s target page class in
>> Application.init() { mountBookmarkablePage ("targetPage",
>> MyTargetPage.class); }
>>
>> Any hint?
>>
>> Stefan
>>
>> ---------------------------------------------------------------------
>> 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
>
>
> ---------------------------------------------------------------------
> 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: Form submit to bookmarkable page

Posted by Stefan Lindner <li...@visionet.de>.
Wow! Seems to be a good starting point. I'm using wicket for 2 years now but still got a lot to learn. Sigh!
Now I have a form with a simple submit button. In the Form's onComponentTag I have

     tag.put("action", urlFor(TargetPage.class, parameters));

The URL now looks like

     http://mysite.com/myapp/TargetPage

That's a great leap forward. But is there any trick to have the Form's input fields as parameters in the URL? If the Form e.g. has an InputField called "parameter" the URL should look like

     http://mysite.com/myapp/TargetPage/parameter/value

or somethind similar? I have tried several URL encodings but all oft hem led tot he result

     http://mysite.com/myapp/TargetPage

Stefan

-----Ursprüngliche Nachricht-----
Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Gesendet: Donnerstag, 2. Oktober 2008 18:06
An: users@wicket.apache.org
Betreff: Re: Form submit to bookmarkable page

you can override form's oncomponenttag() and call super then
tag.put(action, urlfor(yourpage.class));

i believe that should work

-igor

On Thu, Oct 2, 2008 at 8:41 AM, Stefan Lindner <li...@visionet.de> wrote:
> Is it possible to submit a form to a bookmarkable page (with form input
> as page parameters)?
> What I want is a form with a submit button/link that leads to a page
> with e.g. URl
>
>     http://mysite.com/myapp/targetPage/param1/value1/param2/value2
>
> Of course I mount the submit link#s target page class in
> Application.init() { mountBookmarkablePage ("targetPage",
> MyTargetPage.class); }
>
> Any hint?
>
> Stefan
>
> ---------------------------------------------------------------------
> 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


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


Re: Form submit to bookmarkable page

Posted by Igor Vaynberg <ig...@gmail.com>.
you can override form's oncomponenttag() and call super then
tag.put(action, urlfor(yourpage.class));

i believe that should work

-igor

On Thu, Oct 2, 2008 at 8:41 AM, Stefan Lindner <li...@visionet.de> wrote:
> Is it possible to submit a form to a bookmarkable page (with form input
> as page parameters)?
> What I want is a form with a submit button/link that leads to a page
> with e.g. URl
>
>     http://mysite.com/myapp/targetPage/param1/value1/param2/value2
>
> Of course I mount the submit link#s target page class in
> Application.init() { mountBookmarkablePage ("targetPage",
> MyTargetPage.class); }
>
> Any hint?
>
> Stefan
>
> ---------------------------------------------------------------------
> 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