Building the hello application
Step 1: Directory Structure for Hello Application
Following is The Recommended Directory. This Structure Can Be ModiFied So Long As the include.php file contains the correct paths to the files needed.
/ Hello
/ actions
/ Forms
/ incrude
/ models
/ views
Step 2: Building the model
The first step in building an application in Phrame is to set up the data models. If errors are generated in the models, Phrame can be notified by registering an error handler in the options.php and triggering an error with the trigger_error () php method FOLLOWING IS The Person Class for the Hello Application:
phpdefine ('max "(20); class person {var $ _NAME; Function Person ($ this = null) {$ this -> _ name = $ name;} function getname () {Return $ this -> _ name; Function setName {$ isvalid = true; if (Strlen> Max) {Trigger_ERROR ('name>' .max. 'Characters'); $ isvalid = false;} else {$ this -> _ name = $ name;} RETURN $ isvalid;}}?>
Also, these Models That Are Created Could Make Connections To Whichever Database You Are Using. All Data Manipulation Methods As Well As Database Transaction Methods Should Be Owned by Thase Models.
Step 3: Building the Actions
THE NEXT Step in building the application. These actions. The application........................................ ..
Phpclass HelloAction extends Action {function perform ($ actionMapping, $ actionForm) {$ person = new Person (); $ name = $ actionForm-> get ( 'name'); // get ActionForward depending on if errors were generated if ($ Person-> SetName ($ name)) || ($ _SESSION [_ERRORS])) {$ actionforward = $ actionmapping-> get ('index');} else {$ actionforward = $ actionmapping-> Get 'Hello'); // Put Person in The session $ _SESSION ['Person'] = $ Person;}}}}}}?> Step 4: Building the views
This step in building the application is setting up the views for your application. This should include all of the forms that you will need for your application. These can be written using XML / XSLT, PHP, Flash, etc. All views should have a Hidden Element Called Action So That The Controller Knows What Action To Take WHEN A User Does Something On a View Rendered In Xslt for the Hello Application:
FileName: index.xsl
View Description: This is the view that is initially displayed It's a basic form that allows you to enter a name If an error occurs when you submit, this view is shown again with the existing errors shown above the form...
XML Version = "1.0"?>