Postback Implementation
Moderator: General Moderators
Postback Implementation
Has anyone ever built a page state system for PHP? If so, what was your methodology for its operation? Right now I'm toying with the idea of creating a hidden field with the original control value for each control on the page - any thoughts? This is part of my grand design to create a light-weight framework for PHP that is similar to .NET.
Re: Postback Implementation
I don't know .net
What are you ACTUALLY trying to do? Page State?
What are you ACTUALLY trying to do? Page State?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Postback Implementation
Can you give us some example use cases of what you want the code that uses this Postback system to look like?
(#10850)
Re: Postback Implementation
Sorry, I guess I thought more people knew what it was off the top of their heads. I work in .NET just as much as I do PHP and so I hear "postback postback postback" all day long.
You have a form with several textboxes. Typically, you would post these textboxes to another page, or a different section of a page (from index.php?page=form gets posted to index.php?page=process_form). In my method, information is posted back to the same page along with an event to be fired (like btn_Submit) that handles the post data. The difference is that while the page is reloaded, it reloads to its original state so that even though you've reloaded, the values you had in your form persist.
I'm not explaining this well. Postback. This is just a theoretical question of implementation, ie: better to use sessions, cookies, post data, etc etc.
You have a form with several textboxes. Typically, you would post these textboxes to another page, or a different section of a page (from index.php?page=form gets posted to index.php?page=process_form). In my method, information is posted back to the same page along with an event to be fired (like btn_Submit) that handles the post data. The difference is that while the page is reloaded, it reloads to its original state so that even though you've reloaded, the values you had in your form persist.
I'm not explaining this well. Postback. This is just a theoretical question of implementation, ie: better to use sessions, cookies, post data, etc etc.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Postback Implementation
I think people know what "postback" means. But what specific style of form handling code are you looking for?JNettles wrote:Sorry, I guess I thought more people knew what it was off the top of their heads. I work in .NET just as much as I do PHP and so I hear "postback postback postback" all day long.
There are hundreds of forms managers that do this kind of thing in almost every way imaginable in PHP. Every major framework has an implementation too. So the question is -- what do you want your forms code to look like?JNettles wrote:You have a form with several textboxes. Typically, you would post these textboxes to another page, or a different section of a page (from index.php?page=form gets posted to index.php?page=process_form). In my method, information is posted back to the same page along with an event to be fired (like btn_Submit) that handles the post data. The difference is that while the page is reloaded, it reloads to its original state so that even though you've reloaded, the values you had in your form persist.
I'm not explaining this well. Postback. This is just a theoretical question of implementation, ie: better to use sessions, cookies, post data, etc etc.
(#10850)
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Postback Implementation
What framework are you using?
What you need to do is forward the event handling request back to the form controller and all GPC values are persisted. If your using something like CodeIgnitor (which I don't believe supports forwarding) than you need to persist using SESSION's or similar -- which is a hack if you ask me.
Cheers,
Alex
What you need to do is forward the event handling request back to the form controller and all GPC values are persisted. If your using something like CodeIgnitor (which I don't believe supports forwarding) than you need to persist using SESSION's or similar -- which is a hack if you ask me.
Cheers,
Alex
Re: Postback Implementation
already done about 5 years ago, http://pradosoft.com/ provides post back et. al.
Re: Postback Implementation
Thanks, but I've been using Prado for several years now. This is for my own custom framework - which is meant to be lightweight, superfast, and leaves little footprint on the server. Not that I don't find other frameworks like Zend, Prado, Joomla, and Cake to be fantastic options but all of them are rather bulky, have a medium to high learning curve, and are comparatively slow. Mine is a home-brew MVC implementation that I use for rapid small-scale development and is easily modified by my clients. Its a three file framework -> an index, a configuration, and a framework file that handle all operations. Its as easy as dump in a CSS, HTML markup files, PHP code-behinds and data models if you need them, and you're ready to go.
I'm working on a new version that is page-event based (ala Prado) and Postback is something I'm looking to fine-tune. I already have a working model using a special session manager but I was trying to entertain other ideas as I would like to stay out of the session altogether if I can but it doesn't look like it.
I'm working on a new version that is page-event based (ala Prado) and Postback is something I'm looking to fine-tune. I already have a working model using a special session manager but I was trying to entertain other ideas as I would like to stay out of the session altogether if I can but it doesn't look like it.
Re: Postback Implementation
You might have better luck when searching for their proper name "callback." MS have done their usual trick of taking an existing idea, rebranding it, then selling as a new innovation.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Postback Implementation
Callback? Seriously? I have no idea how MS implements a postback, but it's really not that complex of an operation with a properly designed framework. Zend for instance fully supports postback, via a forward, from within your actions.
A forward is like an internal redirect, so any POST data is not destroyed by the time the forward'ed action recevies the request, thus allowing you to re-populate the FORM with POST'ed data.
The reason you are running into this issue, is because you are using a custom built framework.
Bulky is a common complaint with full stack frameworks, and I can't argue otherwise, they are. But until you implement a proper front controller and actions, etc, you will continue running into architectural issues, such as postback, and re-inventing the wheel, likely with hackish solutions, like using SESSION for persisting data across POST requests.
Cheers,
Alex
A forward is like an internal redirect, so any POST data is not destroyed by the time the forward'ed action recevies the request, thus allowing you to re-populate the FORM with POST'ed data.
The reason you are running into this issue, is because you are using a custom built framework.
Bulky is a common complaint with full stack frameworks, and I can't argue otherwise, they are. But until you implement a proper front controller and actions, etc, you will continue running into architectural issues, such as postback, and re-inventing the wheel, likely with hackish solutions, like using SESSION for persisting data across POST requests.
Cheers,
Alex
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Postback Implementation
That's why I asked what he wanted the code that uses this "postback" system to look like. It might be an interesting discussion of some different ways to implement this in PHP.
(#10850)
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Postback Implementation
It could be, especially for multiple form submission wizard like interfaces.That's why I asked what he wanted the code that uses this "postback" system to look like. It might be an interesting discussion of some different ways to implement this in PHP.
Re: Postback Implementation
Haven't used it myself, but as it is based on Seaside (a Smalltalk web-framework that I use all the time) Phaux should have callbacks.
Re: Postback Implementation
ie: Why I asked for suggestions in the first place. I'm not happy with the way I currently am doing it, which is with a session, and I'm trying to keep the session free since my goal is for this to be as unobtrusive as possible. No possible interference or confliction from the framework.But until you implement a proper front controller and actions, etc, you will continue running into architectural issues, such as postback, and re-inventing the wheel, likely with hackish solutions, like using SESSION for persisting data across POST requests.
This is standard MVC pattern - controller up front grabbing pages, code-behind, DOM parsing, and rendering.
I suppose that since I control the HTML output I could have the DOM create hidden fields with callback data for all fields inside of a form......
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Postback Implementation
I'm just curious now, but how does ASP Implement POSTBACK?
They seem to use SESSION's and a _postbackID or something in the cookie to lookup the serialized data? How then does it handle clearing the cache when the form is successfully submitted or navigated away from?
Does anyone have intimate knowledge or insight into how ASP accomplishes this task? How about Prado?
They seem to use SESSION's and a _postbackID or something in the cookie to lookup the serialized data? How then does it handle clearing the cache when the form is successfully submitted or navigated away from?
Does anyone have intimate knowledge or insight into how ASP accomplishes this task? How about Prado?