Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Passing data around within CGI::Prototypeby lhoward (Vicar) |
on Mar 16, 2006 at 16:21 UTC ( [id://537190]=perlquestion: print w/replies, xml ) | Need Help?? |
lhoward has asked for the wisdom of the Perl Monks concerning the following question:
I am writing my first application with CGI::Prototype. I am trying to use the "call yourself until the form in right, and once its ok send you over to the you_did_it_right page" approach shown in Merlyn's Introduction to CGI::Prototype (part 2) article. I am getting hung up about how to pass data between slots (either within one package or between different packages).
I am doing most of my heavy lifting in the respond slot (is this where I am going wrong?). If there are errors in the form submission, I want to include some helpful text about what the problems were and display it in the template when I redisplay the form. Similarly, I want to do some computations on the submitted data in the respond slot and then use the results of that computation (which may be as simple as a scalar, or could be a more complicated datastructure) in the current (or another) package's template. The best method that I have found so far is to add slots in app_enter to hold the values I want to pass around. However, I can't help but think there is a better way to approach this issue. I have a simplified example (written from my head, so it my be a little off) that shows this approach. Am I trying to force CGI::Prototype to work the way I want to work when instead I should be freeing my mind and working with it the way it wants to be used? How should I be going about passing my data around within the application? L
Back to
Seekers of Perl Wisdom
|
|