You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Catalin Marinas <ca...@gmail.com> on 2008/05/01 00:41:34 UTC
Re: submit form to bookmarkable page
I got something working with the example code below (Hello.class is
bookmarkable and mounted). What we would need in Wicket is a
BookmarkableForm class:
StatelessForm form = new StatelessForm("form") {
@Override
protected void onComponentTag(final ComponentTag tag) {
super.onComponentTag(tag);
tag.put("action", urlFor(Hello.class, new PageParameters()));
}
@Override
protected void onComponentTagBody(final MarkupStream markupStream,
final ComponentTag openTag) {
super.renderComponentTagBody(markupStream, openTag);
}
};
I'm not sure that's the best way but I wanted to avoid calling
onComponentTagBody in Form which generates the hidden fields. Ideally, I
should use a WebMarkupContainer but, as you noticed, it adds the changes the
elementname with formname:elementname. Somehow, the Form class manages to
avoid this even though it inherits WebMarkupContainer but I couldn't figure
out. Does anyone now how it does this?
Thanks,
Catalin
Doug Donohoe wrote:
>
> Obviously, if you post with "GET" method, you don't get those dialogs. A
> post and redirect means two hits to the server where-as a GET is only one.
> Using the GET method makes your average web page bookmarkable.
>
> The code I used was basically this:
>
> super.onComponentTag(tag)
> tag.put("action", urlFor(Foo.class, params);
>
> That doesn't work. It still submits using the 'interface' stuff -
> apparently because of hidden fields. I tried using a WebMarkupContainer
> instead of a form, but that fails due to the ? in the URL. Also, for some
> reason the form elements are renamed 'formname:elementname' when using a
> WebMarkupContainer.
>
> I really like Wicket quite a bit, but this issue with forms and constant
> 'session expired' messages are my biggest sticking point.
>
> -Doug
>
>
> igor.vaynberg wrote:
>>
>> thats what stateless forms are for. after a submit you want a redirect
>> anyways so that a refresh doesnt popup that annoying post values
>> dialog.
>>
>> overriding oncomponenttag() should work just fine, you just have to
>> make sure to call super first.
>>
>> -igor
>>
>>
>> On Mon, Apr 28, 2008 at 7:08 PM, Doug Donohoe <do...@donohoe.info> wrote:
>>>
>>> Overriding onComponentTag doesn't seem to work. The URL that gets
>>> generated
>>> (using urlFor) starts with a question mark which isn't included when
>>> the
>>> form is submitted. The only thing passed down is the form parameters,
>>> which obviously doesn't work since the page is missing. I'm using the
>>> default URL encoding strategy - was saving that investigation for
>>> later.
>>> Maybe I need to bump that up in the queue.
>>>
>>> I'll also look at using a stateless form next (and redirecting to a
>>> bookmarkable page so the URL is nice).
>>>
>>> Just a general comment on this. I basically want a form that can be
>>> submitted at any time, regardless if a session is there or not. This
>>> is a
>>> common use case (e.g., google, login, search) and for all the excellent
>>> stuff in wicket, this seems very hard to do.
>>>
>>> Does anyone else have advice on how to do nice-looking-urls using
>>> GET-method
>>> form posts? In other words, if I wanted to build Google's home page in
>>> wicket and be able to bookmark search results, how would I do it? If
>>> anyone
>>> has an example they can share, I would appreciate it.
>>>
>>> Regards,
>>>
>>> -Doug
>>>
>>>
>>>
>>>
>>> igor.vaynberg wrote:
>>> >
>>> > override the form's action value in its oncomponenttag callback with
>>> a
>>> > url to a bookmarkable page. but then you have to parse all posted
>>> > values yourself.
>>> >
>>> > if you dont care about the url you can use a statelessform instead
>>> and
>>> > probably avoid a bunch of headache.
>>> >
>>> > -igor
>>> >
>>> >
>>> > On Sat, Apr 26, 2008 at 6:36 AM, Doug Donohoe <do...@donohoe.info>
>>> wrote:
>>> >>
>>> >> Hi,
>>> >>
>>> >> I'm like to submit a form using bookmarkable page style, so that
>>> >>
>>> >> a) the form can always be submitted, regardless if the session is
>>> >> expired or
>>> >> not (think of a Google search submission e.g.,
>>> >> http://www.google.com/search?q=wicket)
>>> >>
>>> >> b) the form remembers PageParameters that were there when the page
>>> was
>>> >> generated (think of google advanced search where you change the
>>> number
>>> >> of
>>> >> items per page and that is remembered in subsequent searches e.g.,
>>> >> http://www.google.com/search?q=wicket&num=30)
>>> >>
>>> >> How do I tell the form to submit using bookmarkable format (using
>>> the
>>> >> assigned URL encoding strategy)?
>>> >>
>>> >> Thanks,
>>> >>
>>> >> -Doug
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/submit-form-to-bookmarkable-page-tp16912974p16912974.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
>>> >>
>>> >>
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/submit-form-to-bookmarkable-page-tp16912974p16951990.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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
>
--
View this message in context: http://www.nabble.com/submit-form-to-bookmarkable-page-tp16912974p16992741.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: submit form to bookmarkable page
Posted by Doug Donohoe <do...@donohoe.info>.
Hi Catalin,
Good find on the 'formname:elementname' issue. I'm not sure whether
isTransparentResolver() will solve the issue - you can try it and find out.
I ended up using a StatelessForm and redirect as I've document here:
http://wiki.donohoedigital.com/wiki/Wiki.jsp?page=Bookmarkable%20Form%20Submission%20in%20Wicket
I haven't looked into getting a single GET to work, however the solution
would basically be putting the wicket stuff in hidden fields.
In the meantime, the Stateless form and redirect is a decent interim
solution.
-Doug
Catalin Marinas wrote:
>
>
> Catalin Marinas wrote:
>>
>> I'm not sure that's the best way but I wanted to avoid calling
>> onComponentTagBody in Form which generates the hidden fields. Ideally, I
>> should use a WebMarkupContainer but, as you noticed, it adds the changes
>> the elementname with formname:elementname. Somehow, the Form class
>> manages to avoid this even though it inherits WebMarkupContainer but I
>> couldn't figure out. Does anyone now how it does this?
>>
>
> Looking through the code, it seems that the "formname:elementname" string
> gets generated in FormComponent#getInputName(). This function checks
> whether the parent is a Form and no longer adds the "formname:" string.
> Since WebMarkupContainer is not a Form, it always does this. A solution
> would be to override this function in any newly created FormComponent.
>
> Would overriding WebMarkupContainer#isTransparentResolver() to return true
> have the same effect by attaching the children directly to the page?
>
> Thanks,
>
> Catalin
>
--
View this message in context: http://www.nabble.com/submit-form-to-bookmarkable-page-tp16912974p16993338.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: submit form to bookmarkable page
Posted by Catalin Marinas <ca...@gmail.com>.
Catalin Marinas wrote:
>
> I'm not sure that's the best way but I wanted to avoid calling
> onComponentTagBody in Form which generates the hidden fields. Ideally, I
> should use a WebMarkupContainer but, as you noticed, it adds the changes
> the elementname with formname:elementname. Somehow, the Form class manages
> to avoid this even though it inherits WebMarkupContainer but I couldn't
> figure out. Does anyone now how it does this?
>
Looking through the code, it seems that the "formname:elementname" string
gets generated in FormComponent#getInputName(). This function checks whether
the parent is a Form and no longer adds the "formname:" string. Since
WebMarkupContainer is not a Form, it always does this. A solution would be
to override this function in any newly created FormComponent.
Would overriding WebMarkupContainer#isTransparentResolver() to return true
have the same effect by attaching the children directly to the page?
Thanks,
Catalin
--
View this message in context: http://www.nabble.com/submit-form-to-bookmarkable-page-tp16912974p16993335.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