You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Lutz Hühnken <lh...@googlemail.com> on 2010/09/18 12:40:18 UTC

Re: Is there any way to render the "get" method of form?

I don't understand how this answers the question. I followed all of
the links and could not find instructions how to use the get method in
forms in tapestry. Must have overlooked it.. could you be more
specific maybe?


On Sun, Aug 22, 2010 at 3:03 PM, based2 <ba...@free.fr> wrote:
>
> http://www.cgisecurity.com/owasp/html/ch11s04.html
>
> http://tapestry.apache.org/tapestry5.0/tapestry-core/guide/beaneditform.html
>
> http://www.seomoz.org/blog/11-best-practices-for-urls
>
> == http://wiki.apache.org/tapestry/Tapestry5HowTos
> == http://wiki.apache.org/tapestry/Tapestry5OpensourceApps
> == http://wiki.apache.org/tapestry/Tapestry5ModuleRegistry
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Is-there-any-way-to-render-the-get-method-of-form-tp2643651p2643760.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
altocon GmbH
http://www.altocon.de/
Software Development, Consulting
Hamburg, Germany

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


Re: Is there any way to render the "get" method of form?

Posted by Martin Strand <do...@gmail.com>.
On Tue, 28 Sep 2010 18:47:17 +0200, Manuel Sugawara  
<ma...@gmail.com> wrote:

> On Tue, Sep 28, 2010 at 11:24 AM, Martin Strand <
> do.not.eat.yellow.snow@gmail.com> wrote:
>>
>> Of course is a matter of taste but I rather have
>>> http://localhost/?q=c%E1lculo+diferencial<
>>> http://localhost/?q=c%C3%A1lculo+diferencial>than
>>>
>>> http://localhost:8080/C$00e1lculo$0020diferencial
>>>
>>
>> I happen to prefer the second URL so I am doing this with an activation
>> context, just as you describe:
>>
>> POST /search.form
>> redirects to
>> GET /search/my-search-query
>>
>
> Which requires an extra round trip to the server that is not needed at  
> all.
> See
> http://royal.pingdom.com/2010/09/22/is-the-web-heading-toward-redirect-hell/
>
> Regards,
> Manuel.

Indeed, but this is just what I wanted in my particular case.
I'm using a custom Form component where the POST request is validated and  
any error messages are immediately displayed in an uncachable response,  
without any redirection.
If the form validates, a redirect sends the client to a new URL that is  
cachable for a very long time.


It's not impossible to use GET method for forms, it's just that the  
built-in form component doesn't support this so you would have to roll  
your own.
As far as I can tell from how Tapestry uses client side form data to  
replay events on the server, the GET URL you suggest would not be able to  
trigger all the validate/submit/success/etc events that the built-in form  
component does.
If you don't need functionality like that from the Form component, I  
suppose you could create a very simple GetForm component and use that  
instead.
I'm guessing you would also have to provide your own FormSupport in order  
to use built-in components such as TextField etc

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


Re: Is there any way to render the "get" method of form?

Posted by Manuel Sugawara <ma...@gmail.com>.
On Tue, Sep 28, 2010 at 11:24 AM, Martin Strand <
do.not.eat.yellow.snow@gmail.com> wrote:
>
> Of course is a matter of taste but I rather have
>> http://localhost/?q=c%E1lculo+diferencial<
>> http://localhost/?q=c%C3%A1lculo+diferencial>than
>>
>> http://localhost:8080/C$00e1lculo$0020diferencial
>>
>
> I happen to prefer the second URL so I am doing this with an activation
> context, just as you describe:
>
> POST /search.form
> redirects to
> GET /search/my-search-query
>

Which requires an extra round trip to the server that is not needed at all.
See
http://royal.pingdom.com/2010/09/22/is-the-web-heading-toward-redirect-hell/

Regards,
Manuel.

Re: Is there any way to render the "get" method of form?

Posted by Martin Strand <do...@gmail.com>.
On Tue, 28 Sep 2010 17:58:35 +0200, Manuel Sugawara  
<ma...@gmail.com> wrote:

> On Tue, Sep 28, 2010 at 7:08 AM, Thiago H. de Paula Figueiredo  
> <th...@gmail.com> wrote:
>
>> On Tue, 28 Sep 2010 05:41:50 -0300, Lutz Hühnken  
>> <lh...@googlemail.com> wrote:
>>
>>> Of course I am willing to learn. What would be the "Tapestry way" of
>>> implementing this?
>>>
>>
>> Use Form and leave it using POST. If you want a bookmarkable URL, use  
>> the
>> page activation context instead. Tapestry and the form field components  
>> do
>> all the value handling for you.
>
> Of course is a matter of taste but I rather have
> http://localhost/?q=c%E1lculo+diferencial<http://localhost/?q=c%C3%A1lculo+diferencial>than
> http://localhost:8080/C$00e1lculo$0020diferencial

I happen to prefer the second URL so I am doing this with an activation  
context, just as you describe:

POST /search.form
redirects to
GET /search/my-search-query

If you're concerned about the peculiar characters showing up in the  
activation context ($0020 etc) you could ovverride the default URL encoder  
and provide your own version to get prettier URLs:
http://localhost:8080/Cálculo+diferencial

Here's an example to get you started:
http://www.mail-archive.com/users@tapestry.apache.org/msg44973.html

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


Re: Is there any way to render the "get" method of form?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 28 Sep 2010 12:58:35 -0300, Manuel Sugawara  
<ma...@gmail.com> wrote:

> Oh well, I'm not alone ;-). Particulary because doing this by hand is too
> much burden and you cannot use any of the components already provided by
> tapestry.

I'm not following you on why you cannot use Tapestry-provided components.  
You can easily create a mixin that changes forms from get to post. You can  
also file a JIRA asking for a parameter in Form that does that.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Is there any way to render the "get" method of form?

Posted by Manuel Sugawara <ma...@gmail.com>.
On Tue, Sep 28, 2010 at 7:08 AM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Tue, 28 Sep 2010 05:41:50 -0300, Lutz Hühnken <
> lh.tapestry.list@googlemail.com> wrote:
>
>  Dear Thiago,
>>
>
> Hi, Lutz!
>
>
>  now this - the lack of <form method=get> - is something that has been
>> puzzling me in Tapestry 5 for a long time.
>
>
Oh well, I'm not alone ;-). Particulary because doing this by hand is too
much burden and you cannot use any of the components already provided by
tapestry.



> Why would you say using
>> "GET" is a bad idea?
>>
>
> Because all field values end up in the URL.


That's exactly what makes it a good idea, in particular for the case
described below. Also this allows the application to easily interoperate.
Think all those sites that provides a GET interface to search that can be
easily integrated with browsers (ej, the search box in firefox).


>  The use case I think of is a search field. You enter a search term,
>> submit the form, get the result. I think using a form with method=get
>> is the absolutely correct thing to do to achieve this.
>>
>
> I disagree 100%. Why not POST?
> GET was always meant to be used in request that don't change the state of
> the application (including database), while POST for requests that change
> the state. In addition, Tapestry uses redirect-after-post by default (a very
> good thing), so using GET would be useless anyway. Search Google for "get vs
> post security" for some info and "redirect-after-post".


Note the use case, is a search which will not change the database or
application state. I do agree with Lutz, there are cases where GET is much
more appropriate than POST. Not just because it makes more sense but also
because it gives you a bookmarkable URL. That being said, I just love
default redirect-after-post for those forms that *actually* modifies the
application state, just this is not the only use case.


>  Of course I am willing to learn. What would be the "Tapestry way" of
>> implementing this?
>>
>
> Use Form and leave it using POST. If you want a bookmarkable URL, use the
> page activation context instead. Tapestry and the form field components do
> all the value handling for you.


Of course is a matter of taste but I rather have
http://localhost/?q=cálculo+diferencial<http://localhost/?q=c%C3%A1lculo+diferencial>than
http://localhost:8080/C$00e1lculo$0020diferencial

Regards,
Manuel.

Re: Is there any way to render the "get" method of form?

Posted by LLTYK <LL...@mailinator.com>.
Here's a mixin, implement activation context and one GET request with the
search terms in the context will be done:

    <t:textfield value="dummy" t:mixins="livelinkcontext" t:linkId="linkid"
t:placeholder="placeholdergibberish3452" />
    <t:pagelink id="linkid" page="index"
context="literal:placeholdergibberish3452">Search</t:pagelink>



/**
 * Replace the context of a link with a value from a textfield
 */
@IncludeJavaScriptLibrary({"context:/js/mixins.js"})
public class LiveLinkContext
{
  @InjectContainer
  private ClientElement element;
  @Inject
  private RenderSupport renderSupport;
  @Parameter(defaultPrefix="literal")
  private String linkId;
  @Parameter(defaultPrefix="literal")
  private String placeholder;
  
  void afterRender()
  {
    renderSupport.addScript(String.format("new
LiveLinkContext('%s','%s','%s');", element.getClientId(), linkId,
placeholder));
  }
}


var LiveLinkContext = Class.create({
	initialize : function(textfieldId,linkId,placeholder) {
		try {
			this.textfield = $(textfieldId);
			this.link = $(linkId);
			this.oldhref = this.link.href;
			this.regex = new RegExp(placeholder, "g");
			Event.observe(this.textfield, 'keyup',
this.updateContext.bindAsEventListener(this));
			this.updateContext();
		} catch (ex) {
			//log(ex);
		}
	},
	updateContext : function() {
		this.link.href = this.oldhref.replace(this.regex, this.textfield.value);
	}
});
-- 
View this message in context: http://tapestry-users.832.n2.nabble.com/Is-there-any-way-to-render-the-get-method-of-form-tp5449243p5603046.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


Re: Is there any way to render the "get" method of form?

Posted by Peter Stavrinides <P....@albourne.com>.
Point us to the Jira Lutz, the HTML 2 specification details the following:
"If the processing of a form is idempotent (i.e. it has no lasting observable effect on the state of the world), then the form method should be GET. Many database searches have no visible side-effects and make ideal applications of query forms."

and:

"If the service associated with the processing of a form has side effects (for example, modification of a database or subscription to a service), the method should be POST."

so I believe you have a case.

Cheers,
Peter
 


----- Original Message -----
From: "Lutz Hühnken" <lh...@googlemail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Tuesday, 28 September, 2010 21:00:06 GMT +02:00 Athens, Beirut, Bucharest, Istanbul
Subject: Re: Is there any way to render the "get" method of form?

Dear Thiago,

thanks for your patient reply and the advice. Of course I realize that
I can still implement a search with Tapestry, with redirect-after-post
or else, and I have actually done so in the past.

But please take a minute and think about these two things:

1. You say,
> GET was always meant to be used in request that don't change the state of
> the application (including database)

and this is exactly what I would like to use it for - as I said, a
search. You could re-phrase your argument:
"POST was meant for requests that do change the state."
So why do I have to use it for requests that do not?

2. Of course, a lot of things are doable, change the DOM and what not.
But wasn't the idea of Tapestry "make the simple things easy, the
difficult things possible"?
A form with method=get is totally valid HTML, and I think it should be
easy, not complicated.

These two reasons are why I said the lack of get-forms is "puzzling"
me, it just seems somewhat inconsistent with the rest of Tapestry
(which I use and will continue to use with great pleasure).

I did as you told me and created a JIRA ticket (a "wish") for it:
"https://issues.apache.org/jira/browse/TAP5-1285"

Keep up the good work,

Lutz


-- 
altocon GmbH
http://www.altocon.de/
Software Development, Consulting
Hamburg, Germany

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


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


Re: Is there any way to render the "get" method of form?

Posted by Lutz Hühnken <lh...@googlemail.com>.
Dear Thiago,

thanks for your patient reply and the advice. Of course I realize that
I can still implement a search with Tapestry, with redirect-after-post
or else, and I have actually done so in the past.

But please take a minute and think about these two things:

1. You say,
> GET was always meant to be used in request that don't change the state of
> the application (including database)

and this is exactly what I would like to use it for - as I said, a
search. You could re-phrase your argument:
"POST was meant for requests that do change the state."
So why do I have to use it for requests that do not?

2. Of course, a lot of things are doable, change the DOM and what not.
But wasn't the idea of Tapestry "make the simple things easy, the
difficult things possible"?
A form with method=get is totally valid HTML, and I think it should be
easy, not complicated.

These two reasons are why I said the lack of get-forms is "puzzling"
me, it just seems somewhat inconsistent with the rest of Tapestry
(which I use and will continue to use with great pleasure).

I did as you told me and created a JIRA ticket (a "wish") for it:
"https://issues.apache.org/jira/browse/TAP5-1285"

Keep up the good work,

Lutz


-- 
altocon GmbH
http://www.altocon.de/
Software Development, Consulting
Hamburg, Germany

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


Re: Is there any way to render the "get" method of form?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 28 Sep 2010 05:41:50 -0300, Lutz Hühnken  
<lh...@googlemail.com> wrote:

> Dear Thiago,

Hi, Lutz!

> now this - the lack of <form method=get> - is something that has been
> puzzling me in Tapestry 5 for a long time. Why would you say using
> "GET" is a bad idea?

Because all field values end up in the URL.

> The use case I think of is a search field. You enter a search term,
> submit the form, get the result. I think using a form with method=get
> is the absolutely correct thing to do to achieve this.

I disagree 100%. Why not POST?
GET was always meant to be used in request that don't change the state of  
the application (including database), while POST for requests that change  
the state. In addition, Tapestry uses redirect-after-post by default (a  
very good thing), so using GET would be useless anyway. Search Google for  
"get vs post security" for some info and "redirect-after-post".

> Of course I am willing to learn. What would be the "Tapestry way" of
> implementing this?

Use Form and leave it using POST. If you want a bookmarkable URL, use the  
page activation context instead. Tapestry and the form field components do  
all the value handling for you.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Is there any way to render the "get" method of form?

Posted by Lutz Hühnken <lh...@googlemail.com>.
Dear Thiago,

now this - the lack of <form method=get> - is something that has been
puzzling me in Tapestry 5 for a long time. Why would you say using
"GET" is a bad idea?

The use case I think of is a search field. You enter a search term,
submit the form, get the result. I think using a form with method=get
is the absolutely correct thing to do to achieve this.

Of course I am willing to learn. What would be the "Tapestry way" of
implementing this?

Thanks for your help,

Lutz


>
> Using the GET method in forms is a bad idea. You can use DOM rewriting or
> JavaScript to do that.
>


-- 
altocon GmbH
http://www.altocon.de/
Software Development, Consulting
Hamburg, Germany

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


Re: Is there any way to render the "get" method of form?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sat, 18 Sep 2010 07:40:18 -0300, Lutz Hühnken  
<lh...@googlemail.com> wrote:

> I don't understand how this answers the question. I followed all of
> the links and could not find instructions how to use the get method in
> forms in tapestry. Must have overlooked it.. could you be more
> specific maybe?

Using the GET method in forms is a bad idea. You can use DOM rewriting or  
JavaScript to do that.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Is there any way to render the "get" method of form?

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
hi lutz,

the use of the 'post' method for the form is hardcoded. the easiest way to 
change this is to have some client-side script that rewrites the method 
attribute to 'get'. an alternative you could have a heartbeat that 
rewrites the generated HTML server-side (take a look at the Label 
component for how to use a heartbeat render command)

g,
kris



Von:    Lutz Hühnken <lh...@googlemail.com>
An:     Tapestry users <us...@tapestry.apache.org>
Datum:  18.09.2010 12:40
Betreff:        Re: Is there any way to render the "get" method of form?



I don't understand how this answers the question. I followed all of
the links and could not find instructions how to use the get method in
forms in tapestry. Must have overlooked it.. could you be more
specific maybe?


On Sun, Aug 22, 2010 at 3:03 PM, based2 <ba...@free.fr> wrote:
>
> http://www.cgisecurity.com/owasp/html/ch11s04.html
>
> 
http://tapestry.apache.org/tapestry5.0/tapestry-core/guide/beaneditform.html

>
> http://www.seomoz.org/blog/11-best-practices-for-urls
>
> == http://wiki.apache.org/tapestry/Tapestry5HowTos
> == http://wiki.apache.org/tapestry/Tapestry5OpensourceApps
> == http://wiki.apache.org/tapestry/Tapestry5ModuleRegistry
>
> --
> View this message in context: 
http://tapestry.1045711.n5.nabble.com/Is-there-any-way-to-render-the-get-method-of-form-tp2643651p2643760.html

> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
altocon GmbH
http://www.altocon.de/
Software Development, Consulting
Hamburg, Germany

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