使用ModelDriven action
来源:百度文库 编辑:神马文学网 时间:2024/10/02 18:43:08
Model-Driven vs. Field-Driven
two types of Actions possible:
1. Model-driven
Action has methods returning your model classes (myAction.getUser())
Fields in the view are fields of your model
Views refer directly to your model (property=‘user.name’)
Excellent because it allows model reuse
2. Field-driven
Action has fields of its own, which are fields in the view
execute() collates fields and interacts with the model
Views refer to action fields (property=‘daysTillNextBirthday’)
Useful where form is not parallel to model
As we can see in our Action, the two can be mixed
ModelDriven Interface
XWork / WebWork also supports modeldriven Actions more directly
The ModelDriven Interface has one method:
public Object getModel()
Properties of the model will be directly available, i.e. “name” instead of “user.name”
Applies to UI tags, form field names, etc.
步骤:
(1)Action implements ModelDriven接口
(2)实现getModel()方法:
public Object getModel() {
return user;
}
(3)将jsp页面上user.name 改成name
(4)在xwork.xml中,
extends="webwork-default"
/model/form.jsp
/model/success.jsp
/model/form.jsp
two types of Actions possible:
1. Model-driven
Action has methods returning your model classes (myAction.getUser())
Fields in the view are fields of your model
Views refer directly to your model (property=‘user.name’)
Excellent because it allows model reuse
2. Field-driven
Action has fields of its own, which are fields in the view
execute() collates fields and interacts with the model
Views refer to action fields (property=‘daysTillNextBirthday’)
Useful where form is not parallel to model
As we can see in our Action, the two can be mixed
ModelDriven Interface
XWork / WebWork also supports modeldriven Actions more directly
The ModelDriven Interface has one method:
public Object getModel()
Properties of the model will be directly available, i.e. “name” instead of “user.name”
Applies to UI tags, form field names, etc.
步骤:
(1)Action implements ModelDriven接口
(2)实现getModel()方法:
public Object getModel() {
return user;
}
(3)将jsp页面上user.name 改成name
(4)在xwork.xml中,
使用ModelDriven action
Struts2的使用注解配置Action
Struts2中使用注解 管理Action方法的权限
再谈使用UrlRewrite时修改form的action属性问题 - 狂人日记·技术版 -...
【Weblogic Security In Action】
After action reviews
《POJOS in Action》读书笔记
Android中常用Action
Webwork2之Action Result Type
Struts 2.0的Action讲解
Struts测试之action测试
project task action 的区别
JSF in Action读书笔记一
struts2怎么做forward-action?
Social Networking_Learning Theory in Action
Struts测试之action测试
行动学习法 Action learning
webwork中action result type
FLash高级ACTION编程视频教程
Action接收URL中的参数
Java in Action - Struts分页显示
Development Marketplace: Turning Ideas Into Action
Struts标签-Logic - Java in Action - BlogJav...
Fundamentals of Robotics: Linking Perception to Action