[b]
Portlet render请求解析[/b]
1、请求经过MainServlet,再转交PortalRequestProcessor
默认交给LayoutAction,由LayoutAction分发到render_portlet.jsp。
2、在render_portlet.jsp拿到portlet实例,开始portlet内部调用,通过invokerPortlet.render(...)执行portlet 的render方法。
3、LiferayPortlet.doDispatch根据PortletMode转发到具体执行方法,以view为例,将会调用StrtutsPortlet.doView
在StrtutsPortlet.include方法中通过PortletRequestProcessor.process找到请求的具体实现Action
并通过该Action的execute将请求交给render方法处理。
[b]
Portlet action请求解析[/b]
1、请求经过MainServlet,再转交PortalRequestProcessor
默认交给LayoutAction,由LayoutAction 的processLayout根据判定是Action请求后再调用
processPortletRequest方法创建invokerPortlet实例执行processAction方法。
2、StrutsPortlet的processAction方法调用PortletRequestProcessor.process方法找到请求的具体实现 Action并调用其processAction方法
3、若设置了actionResponse.sendRedirect(redirect),执行完processAction方法后在LayoutAction的 processLayout方法还会将请求重定向到redirect,到此为止,一次action请求已经完成,同时发起一次render请求,跳转页面。
由此可见LayoutAction在Liferay的请求解析中扮演着一个非常重要的角色。
Portlet render请求解析[/b]
1、请求经过MainServlet,再转交PortalRequestProcessor
默认交给LayoutAction,由LayoutAction分发到render_portlet.jsp。
protected ActionForward processLayout(
ActionMapping mapping, HttpServletRequest request,
HttpServletResponse response, long plid)
throws Exception {
// Include layout content before the page loads because
// portlets on the page can set the page title and page
// subtitle
includeLayoutContent(
request, response, themeDisplay, layout);
2、在render_portlet.jsp拿到portlet实例,开始portlet内部调用,通过invokerPortlet.render(...)执行portlet 的render方法。
if (portlet.isActive() && access && supportsMimeType) {
try {
invokerPortlet.render(renderRequestImpl, renderResponseImpl);
3、LiferayPortlet.doDispatch根据PortletMode转发到具体执行方法,以view为例,将会调用StrtutsPortlet.doView
protected void doDispatch(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, PortletException {
...
PortletMode portletMode = renderRequest.getPortletMode();
if (portletMode.equals(PortletMode.VIEW)) {
doView(renderRequest, renderResponse);
}
在StrtutsPortlet.include方法中通过PortletRequestProcessor.process找到请求的具体实现Action
public void process(
RenderRequest renderRequest, RenderResponse renderResponse)
throws IOException, ServletException {
HttpServletRequest request = PortalUtil.getHttpServletRequest(
renderRequest);
HttpServletResponse response = PortalUtil.getHttpServletResponse(
renderResponse);
process(request, response);
}
并通过该Action的execute将请求交给render方法处理。
else if (portletRequest instanceof RenderRequest) {
return render(
mapping, form, portletConfig, (RenderRequest)portletRequest,
(RenderResponse)portletResponse);
}
[b]
Portlet action请求解析[/b]
1、请求经过MainServlet,再转交PortalRequestProcessor
默认交给LayoutAction,由LayoutAction 的processLayout根据判定是Action请求后再调用
if (themeDisplay.isLifecycleAction()) {
Portlet portlet = processPortletRequest(
request, response, PortletRequest.ACTION_PHASE);
processPortletRequest方法创建invokerPortlet实例执行processAction方法。
if (lifecycle.equals(PortletRequest.ACTION_PHASE)) {
...
if (access) {
invokerPortlet.processAction(
actionRequestImpl, actionResponseImpl);
actionResponseImpl.transferHeaders(response);
}
2、StrutsPortlet的processAction方法调用PortletRequestProcessor.process方法找到请求的具体实现 Action并调用其processAction方法
PortletAction portletAction = (PortletAction)processActionCreate(
request, response, actionMapping);
...
portletAction.processAction(
actionMapping, actionForm, portletConfigImpl, actionRequest,
actionResponse);
3、若设置了actionResponse.sendRedirect(redirect),执行完processAction方法后在LayoutAction的 processLayout方法还会将请求重定向到redirect,到此为止,一次action请求已经完成,同时发起一次render请求,跳转页面。
if (Validator.isNotNull(redirectLocation)) {
response.sendRedirect(redirectLocation);
return null;
}
由此可见LayoutAction在Liferay的请求解析中扮演着一个非常重要的角色。