function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jeremy_rossjeremy_ross 

Possible to have apex:form use method="GET"?

Anyone successfully use GET with an apex:form?  Is there support for it?

Jeremy

dchasmandchasman
Changing the method is not supported and not something that is planned or likely to happen. Visualforce requires a number of hidden inputs to track viewstate, anti tampering and anti Cross Site Request Forgery (CSRF) tokens that are unlikely to fit in the typical max URL restrictions in the internet and our servers.

Can you provide information about what it is you are trying to accomplish?
jeremy_rossjeremy_ross
I've got some pagination stuff going on.  Prob is when you drill into a record, the back button is broken by the fact that the pagination page used an apex form and http post.  I'll have to rewrite this without the apex form so I can keep state is in the URL. 

Jeremy
dchasmandchasman
Can you elaborate on "broken" here - e.g. do you get a browser security message or into an infinite reposting loop?
jeremy_rossjeremy_ross
Most browsers will prompt the user to ask if they want to resubmit/resend the post.  This is a usability issue.

Another issue with the post verb I didn't mention earlier is that I can't link to an arbitrary page, i.e. https://salesforce.com/blabla/myvfpage?page=3&searchTerm=sample+search

What I'd like is to be able to use VF UI components while using GET, even if that means no view state, persistent properties, etc.  I understand this is not available today, but perhaps should be considered for a future release.

thanks

Jeremy
dchasmandchasman
Ah that is what I was looking for - you can definitely POST to a VF page using a <form> or XHR etc with the method=GET just not using <apex:form> and things will work just fine. The apex:form  component really brings in much more than just simple generation of a <form> tag. We are actually planning on removing the need for <apex:form> all together in a future release.

Make sure that you do not include the VF hidden inputs in your form data and you will get is "What I'd like is to be able to use VF UI components while using GET, even if that means no view state, persistent properties, etc".

Make sense?
jeremy_rossjeremy_ross
Makes sense.  But I'd still like a way to use VF components in a simple stateless form with action=get.  Saves me from having to build URLs manually.  I'm lazy and would rather the browser do it for me.

Edit: Is there a way to prevent the hidden fields from rendering.  If not, are you suggesting something like javascript to remove the hidden fields before submit?


Message Edited by jeremy_ross on 10-08-2008 11:32 AM
dchasmandchasman
I meant if you are building your own <form> do clone the hidden inputs from a VF generated <form> - you would be surprised by the number of folks that will just blindly View Source, cut and paste, and create a living support nightmare :-)