Advantages of RESTful URI's
Moderator: General Moderators
Re: Advantages of RESTful URI's
In my controllers actions that get posted to usually wind up redirecting the page to some other action, to prevent duplicate postings. It's on that subsequent request that I want to retrieve the messages.
Re: Advantages of RESTful URI's
I redirect only after a successful posting. There's no problem with multiple failed posting, they all return the same errors and do not change data.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Advantages of RESTful URI's
DittoI redirect only after a successful posting. There's no problem with multiple failed posting, they all return the same errors and do not change data.
Re: Advantages of RESTful URI's
I show messages on success not just failure, different message types... it is actually in the works for official Zend support
Re: Advantages of RESTful URI's
Success messages are usually generic, and you can include a flag in the URL. Error messages are often more specific, depending on the data submitted - in my opinion it's best to keep the data in the same action that processes the form instead of passing everything around in sessions.
Re: Advantages of RESTful URI's
Just wondering if you could explain why you feel thats the best way? Or are you just saying that that is just your strongest preference?
Re: Advantages of RESTful URI's
I never used RESTful URI's in practice, nor do I intend to. I like the idea of standardization, non-redundant URLs etc, but it seems no improvement to me at all to shrink /users/edit/5 to users/5 + requiring a PUT or POST request. It distributes the information about the intended action over 2 places, which doesn't make things significantly simpler in my world.
Besides technical issues (requiring PUT or DELETE requests is bound to give you more shyte than simply adding /add/ or /delete/ in your URL), it's very limiting - your are restricted to four actions (or 8 if we count all possible HTTP requests types) while I prefer a more flexible and dynamic setup. And, last but not least, to me, it feels like raping the standard for purposes it wasn't designed for.
Besides technical issues (requiring PUT or DELETE requests is bound to give you more shyte than simply adding /add/ or /delete/ in your URL), it's very limiting - your are restricted to four actions (or 8 if we count all possible HTTP requests types) while I prefer a more flexible and dynamic setup. And, last but not least, to me, it feels like raping the standard for purposes it wasn't designed for.
Re: Advantages of RESTful URI's
It just seems to me as the most straightforward and simple way to handle it. The POST request has the data you want to process. Submitting it to the action that handles the post data allows you to generate error messages and prefill form inputs without passing all the data around in sessions. What are the advantages of using sessions for this purpose?Just wondering if you could explain why you feel thats the best way? Or are you just saying that that is just your strongest preference?
Re: Advantages of RESTful URI's
Because the user can accidentally hit refresh and repost the form.
It sounds like we're not talking about the same thing though. I was thinking an error message like "record could not be created now, try again later". Or maybe "record deleted" should get a different CSS class then "record saved", thats what I meant by message types.
At the field level we validate with javascript before the form gets submitted, and it would show the errors right on that page (no redirect) if they posted an invalid form.
It sounds like we're not talking about the same thing though. I was thinking an error message like "record could not be created now, try again later". Or maybe "record deleted" should get a different CSS class then "record saved", thats what I meant by message types.
At the field level we validate with javascript before the form gets submitted, and it would show the errors right on that page (no redirect) if they posted an invalid form.
Re: Advantages of RESTful URI's
As I and Alex have said, that doesn't matter. The data gets posted again, and the same errors are shown. Not that accidentally hitting refresh is such a common occurrence either way.Because the user can accidentally hit refresh and re-post the form.
We're talking about form validation errors (such as empty and misformatted fields). I sometimes have javascript validation as well, but there is always PHP validation to back it up. An error such as "record could not be created now, try again later" sounds like something fatal has happened (like the database going down). That might be handled using sessions, though I don't see the difference either way. Regarding delete operations, which are the only exception in my opinion, I use form submission to indicate delete confirmation and it can only happen once - so, again, the threat of multiple submission is not a problem.
Re: Advantages of RESTful URI's
On the other hand, I just don't want my user to get a prompt. Plus, what will happen during a form post will vary from application to application, module to module.
"We're talking about form validation errors" - ( both of us? cuz like I said I was under the presumption we were talking about something different, we were talking about 2 different things AFAIK).
Anyways Zend is implementing it, you dont have to use it if you dont want!
http://framework.zend.com/issues/browse/ZF-1705
"We're talking about form validation errors" - ( both of us? cuz like I said I was under the presumption we were talking about something different, we were talking about 2 different things AFAIK).
Anyways Zend is implementing it, you dont have to use it if you dont want!
http://framework.zend.com/issues/browse/ZF-1705
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Advantages of RESTful URI's
I am a little confused from reading this who does what. I assumed that the usual practice was that a form action submits to itself until all fields are valid data. On success it redirects to a success action which eliminates reposting and back button problems. The success action could be a text message, the next step in a sequence or some other page (like a listing of records to edit).
(#10850)
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Advantages of RESTful URI's
That is my understanding and I think everyone agrees -- otherwise you would need to implement some complex postback system to persist form values, no?I am a little confused from reading this who does what. I assumed that the usual practice was that a form action submits to itself until all fields are valid data. On success it redirects to a success action which eliminates reposting and back button problems.
Upon success, a redirect is executed, so there is no success action (at least in my framework). Upon success, you set an message and away you go. That message is either shown or not depending on what the designer determines.The success action could be a text message, the next step in a sequence or some other page (like a listing of records to edit).
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Advantages of RESTful URI's
When you redirect, you to redirect to a URL. So there is a request made back to the server. I assume that there is a controller/method to accept that request (and generate a response). I call that an action.PCSpectra wrote:Upon success, a redirect is executed, so there is no success action (at least in my framework). Upon success, you set an message and away you go. That message is either shown or not depending on what the designer determines.
(#10850)
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Advantages of RESTful URI's
Yes, in that case, that is how it works. Not sure what I thought you meant, but I figured sucessful actions somehow forwarded to a "success" action first prior to redirection, in which case, I seen an extra step which confused me a little.
Cheers,
Alex
Cheers,
Alex