In ActionCommand derived class to get ActionRequest, ActionResponse
来源:互联网 发布:小鹰电视直播软件 编辑:程序博客网 时间:2024/04/27 23:05
When I refactor my controller, I separate CRUD in different classes by implementing ActionCommand, we need to do some preparations:
1. To take advantage of ActionCommands, add the following initialization parameter to our portlet.xml file:
<init-param>
<name>action.package.prefix</name>
<value>com.book.action</value>
</init-param>
2. create class, the class's name must end with ActionCommand, for example: UpdateBookActionCommand:
public class UpdateBookActionCommand implements ActionCommand {
BookManager bm = BookManager.getBookManager();
@Override
public boolean processCommand(PortletRequest actionRequest, PortletResponse portletResponse)
throws PortletException {
String id = actionRequest.getParameter("bookId");
Book book = bm.getBook(Integer.parseInt(id));
actionRequest.setAttribute("book", book);
ActionResponse actionResponse = (ActionResponse) portletResponse;
actionResponse.setRenderParameter("jspPage", "/update.jsp");
return true;
}
}
In the example, I need to redirect to update.jsp. Previously, the parameters in method are ActionRequest and ActionResponse, but in processCommand method, we just get PortletRequest, PortletResponse.
In my case, there's no setRenderParameter(String,String) method in PortletResponse. What I do is casting portletResponse to ActionResponse. It works well.
The difference between them are:
The PortletRequest is the parent of both. An ActionRequest and a RenderRequest are both different types of PortletRequest objects.
An ActionRequest is valid during the action processing phase of the portlet. During this phase, the portlet hasn't completely decided how it is going to render itself, be it minimized, maximized, in edit mode or in veiw mode, etc.
On the other hand, the RenderRequest is valid during the rendering phase of the portlet. At this point, the portlet knows how it is going to render itself, and certain changes such as window state, are not allowed.
- In ActionCommand derived class to get ActionRequest, ActionResponse
- Casting from a base class to a derived class
- OnDestroy or PostNcDestroy in derived class will not be called.
- How to Get a List of Class Attributes in Python
- How to initialize child controls in a derived CDialogBar
- How to initialize child controls in a derived CDialogBar
- C++ Template Class Derived
- Warning: calling DestroyWindow in CWnd::~CWnd OnDestroy or PostNcDestroy in derived class will not be called
- 解决 Warning: calling DestroyWindow in CWnd::~CWnd OnDestroy or PostNcDestroy in derived class will n
- warning :OnDestroy or PostNcDestroy in derived class will not be called
- warning :OnDestroy or PostNcDestroy in derived class will not be called
- Assert: Node still marked as running on node destruction! Was base class onExit() called in derived
- warning :OnDestroy or PostNcDestroy in derived class will not be called
- 出现“OnDestroy or PostNcDestroy in derived class will not be called.”问题
- Creating a CAknEnumeratedTextPopupSettingItem-derived class to use dynamic data at runtime
- derived class 的constructor 调用
- Static Member of Derived Class
- C++ derived class access specifier
- 世态炎凉的伤感爱情日志:爱情里的滋味,我尝遍了
- 《GOF设计模式》—工厂方法(Factory Method)—Delphi源码示例:基于工厂方法的迷宫
- django 1.4 利用jquery实现ajax ‘get|post’异步请求
- 分页 跳转
- 编解码、流、文件等相关概念
- In ActionCommand derived class to get ActionRequest, ActionResponse
- Android 高仿【优酷】圆盘旋转菜单的实现
- Android中Surface和SurfaceView的一些理解和总结
- 实务:撰写权利要求的基本思路
- 那些链接
- java中易出错的且常被面试的几点
- 在Linux下反编译Android .apk文件
- 音频编解码标准
- C# 伪随机数 随机数顺序排列 附带双色球机选程序