Friday, June 16, 2006

What is ActionForm? (4)

I explain the recommended procedure of ActionForm also today.


ActionForm does validity check inside it. For example, "email" is string which has the special pattern. ActionForm fetches the input value as string and validates it as email. In this case, string is the information at form property, and email is the information at field property.

Its validity check is worked with field property setting. XCube and Legacy has various field property. Of course, developers can add on their validation pattern as field property.

If values violate the validity check, ActionForm comes to keep error messages which is tied up with the check. And, the one time token (ticket) is also checked in this process. The one time token of XCube_ActionForm is a kind of transaction tokens. Developers can handle the one time token as validations.

Error Check

hasError() checks whether the ActionForm has errors. Developers can access error messages of the ActionForm through getErrorMessages() member function.

Cubson recommends changing the business logic by request kind. If it's GET or errors, display the input form any number of times until successful. If it's POST and no errors, go to next procedures. By this loop, a user doesn't lose his input values even if it's errors.

For example, in myaccount module, try to click "Submit" button without message value. One error message will be displayed. But, the subject is not lost. You can't go to next procedure until you fill the message form. Also this loop works also in the case of token errors.

No comments: