我正在为 GateIn 3.6 开发 portlet。目前我已经创建了一个列出表中记录的页面。当用户单击任何行时,它将进入描述页面。
现在,当用户单击行时,它会加载详细信息页面,但值不可用。我在做什么细节在这里..
@RenderMode(name = "view")
public void display(RenderRequest request, RenderResponse response) throws PortletException, IOException, NamingException {
RecordsDAO recordsDAO = new RecordsDAOImpl();
// Records listing available on listing page
request.setAttribute("recordsList", recordsDAO.getAllRecords());
// tried to load record detail page when user click one row
if(actionJsp == null || actionJsp.equals("")){
getPortletContext().getRequestDispatcher("/jsp/ListRecords.jsp").
include(request, response);
} else {
getPortletContext().getRequestDispatcher("/jsp/DetailsBoxRecord.jsp").
include(request, response);
}
actionJsp = "";
}
并且过程动作是
@ProcessAction(name = "details")
public void details(ActionRequest request, ActionResponse response) throws PortletException, IOException {
RecordsDAO recordsDAO = new RecordsDAOImpl();
int id = Integer.parseInt(request.getParameter("id"));
RecordsForm recordsForm = recordsDAO.getRecord(id);
// way 1 set request attribute
request.setAttribute("details", recordsForm);
// way 2 set response attribute -- display error that cannot set Form type values
response.setRenderParameter("details", recordsForm);
actionJsp = "values";
}
选项1:我尝试在request.setAttribute中设置RecordsForm类型值,它完成了,但请求中的值在jsp页面中不可用。
选项 2:使用 response.setRenderParameter 我无法在 response.setRenderParameter 中设置 RecordsForm 类型值以在 jsp 页面中访问这些值。
谁能指导我在我的情况下哪种方法是正确的,以及这些值如何在 jsp 页面中可用,以便我可以加载详细信息页面。