java从Struts操作的钩子更改表单值(Liferay 6.2)
我只是想改变一个来自表单的值。我挂接了一个Struts Action
来更改该值,然后继续使用默认的processAction
。但它没有应用这些变化
这是我的钩子代码:
public class EditRecordDisplayPortletAction extends BaseStrutsPortletAction {
...
public void processAction(
StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse)
throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
...
//Stuff that is working here ...
...
//Here I change the value that is comming from the form that should be used later:
DynamicActionRequest dynamicActionRequest = null;
Map<String, String[]> params = new HashMap();
String observationInputKey = getObservationInputKey();
params.put(observationInputKey, new String[]{"Here goes some text I have calculated in the hook."});
dynamicActionRequest = new DynamicActionRequest(actionRequest, params, false);
//Continues with the normal operation, but it's not using the new values:
originalStrutsPortletAction.processAction(
originalStrutsPortletAction, portletConfig, dynamicActionRequest,
actionResponse);
}
...
我正在使用DynamicActionRequest
,因为我无法更改__actionRequest__
。想了解更多信息,这里有人解释了一些类似的东西,应该是有效的:
Wrap actionRequest with a DynamicActionRequest
# 1 楼答案
按照您链接的论坛帖子的示例,您可以更简单地创建DynamicActionRequest。请尝试一下:
当然,javadoc for DynamicActionRequest只包含方法名,但是您将布尔参数
inherit
指定给构造函数作为false
。那可能是你唯一的问题