Yii Framework Forum: Stateful Forms enhanced? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Stateful Forms enhanced? Rate Topic: -----

#1 User is offline   Bergtroll 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 20-August 09

Posted 04 May 2010 - 08:11 AM

Hi there Yii community,

as you know one possibility to store page states is provided with Yii's stateful forms. Nevertheless it needs to have a page rendered containing a CHtml::StatefulForm. I was wondering if it could be possible to simulate Requests containing POST data for actions without attached views, that are only used for processing and redirecting somewhere else. It is possible to generate redirects setting GET Variables in the URL. How about using a library like cURL to generate a redirected site request with POST variables?

Background of this idea is, that I am currently building a form wizard based on an modified version of the CWizardBehavior supplied in topic http://www.yiiframew...-wizard-forms/. For reasons of code separation I'd like to some setup stuff in an register/onStart action that does not have any view attached. Instead this action finally redirects the user to the first 'real' wizard page and it would be very cool to have some POST variables prepared for this redirect call. But at least I think that it could be of advantage to generate redirects with POST variables setup not only for this purpose. What do you think? Possible?

Greets,
Bergtroll
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,338
  • Joined: 12-October 09
  • Location:Croatia

Posted 04 May 2010 - 08:38 AM

I'm not sure I understand your problem but can you use sessions?

I mean... instead of making a POST request... why not put needed data in the session (you can use setState())
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   Bergtroll 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 20-August 09

Posted 04 May 2010 - 11:05 AM

View Postmdomba, on 04 May 2010 - 08:38 AM, said:

I mean... instead of making a POST request... why not put needed data in the session (you can use setState())


Hi Mdomba, thanks for your suggestion, it seems to work this way. But on the other hand I do need the initialization value to get accessed globally and for a longer period of time, but only in the context of the wizard initialization. So I have to take care to unset it from the session right after the initialization step.

A main argument I feel it is difficult to estimate its seriousness is, that according to this IBM Tech Article (for java-driven webapps) HTTP Sessions are not thread safe. My apprehension is, that in coincidence of huge server load and delayed handling of requests (e.g. open in new tab twice) this could lead to a state, where two wizards are initialized identically. This would generate to a mixin of user input if they are both treated in parallel (e.g. to copy and paste in similiar workflows), leading to inappropriate results. With a volatile POST initialization I would evade such kind of trouble.

Is this apprehension realistic? Is the article only meaningful for java webapps? Does PHP or Yii cares for thread safety somehow? Is it possible that a CWebUser instance is accessed from different PHP Threads?

Thanks,
Bergtroll
0

#4 User is offline   Bergtroll 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 20-August 09

Posted 04 May 2010 - 12:27 PM

I just stumbled over another problem. If I provide the initial info with a session variable which I want to unset afterwards, the user is not able to use its browser back button to get back to the first page, because the wizardId is lost. I know, the user should not do it this way, but there are a lot of senior people who will do it nevertheless.
0

#5 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,338
  • Joined: 12-October 09
  • Location:Croatia

Posted 04 May 2010 - 02:44 PM

I don't know your situation... but if someone opens in new tab twice... thats always the same user... it's not two different users...

For the browser back problem... I think is't the same with the POST data...when hitting back button after some data is posted the browser asks to post again the POSTed data and you cannot go two pages back...

Again I don't understand exactly your need, but if session is not OK, you can maybe use the database to store the needed data but then you have in some way to distinguish different users...
Find more about me.... btw. Do you know your WAN IP?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users