2016-02-16 29 views
1

的Portlet类简单的Liferay的ProcessAction不工作

public class AddRoomController extends MVCPortlet { 

    public void doView(RenderRequest renderRequest, RenderResponse renderResponse) 
      throws IOException, PortletException { 
     System.out.println("hu to call thau chu..."); 
     super.doView(renderRequest, renderResponse); 
    } 

    // @ProcessAction(name="addRooms")  //Adding this annotation also not solving the issue 
    public void addRooms(ActionRequest actionRequest, ActionResponse actionResponse) 
      throws IOException, PortletException { 
     System.out.println("Called"); 
     String locationName = actionRequest.getAttribute("locationName").toString(); 
     System.out.println("===> "+locationName); 
     actionResponse.sendRedirect("addRooms.jsp"); 
    } 
} 

view.jsp的

片段1

<body> 
<portlet:actionURL name="addRooms" var="addRoomsUrl"></portlet:actionURL> 
<form action="${addRoomsUrl}" method="post"> 
<!-- Custom Inputs -->  
</form> 
</body> 

片段2

<body> 
<portlet:actionURL name="addRooms" var="addRoomsUrl"></portlet:actionURL> 
<form action="<%=addRoomsUrl%>" method="post"> 
<!-- Custom Inputs -->  
</form> 
</body> 

我试图用调用操作方法上面的片段都没有,但没有他们工作。

在我的Portlet中doView()被调用,但是当我尝试调用processAction方法名称addRooms时,它给我带有空值的错误。 如果可能,我想避免使用合金。

任何帮助,将不胜感激......

+1

你得到的错误/行为是什么?对我来说,似乎'actionRequest.getAttribute(“locationName”)'解析为null,你正在调用toString它,它不喜欢:) –

回答

0

的错误得到了通过使用这些解决:

  1. 在窗体使用actionRequest.getParameter(PARAMNAME)
  2. 定义Portlet的命名空间参数名称