| 3.3.4 automatic form validation |
除了上面描述的,struts 提供了额外的校验form输入域的机制。使用这个机制,你需要重载actionform 类的下面这个方法:
public actionerrors validate(actionmapping mapping, httpservletrequest request);
the validate() method is called by the controller servlet after the bean properties have been populated, but before the corresponding action classs perform() method is invoked. the validate() method has the following options: |
| 3.4 other presentation techniques |
| 虽然,你的应用程序的look and feel 可以完全基于标准jsp和struts custom tag构建,你还是应该考虑使用其他的有利于组件重用的技术,减少维护的精力,减少错误。几个可能的选择在下面的章节中被讨论。 |
| 3.4.1 application-specific custom tags |
|
处理使用struts库提供的custom tags 外,你可以轻松的创建特定于你自己应用程序的tags来帮助你创建用户界面。示例程序创建了几个自己的tags: · checklogon – 检查某个会话对象是否存在,如果没有则将控制传递到登录页面。this is used to catch cases where a user has bookmarked a page in the middle of your application and tries to bypass logging on, or if the users session has been timed out. · linksubscription – generates a hyperlink to a details page for a subscription, which passes the required primary key values as request attributes. this is used when listing the subscriptions associated with a user, and providing links to edit or delete them. · linkuser – generates a hyperlink to a details page for a user, which passes the required primary key values as request attributes. |
