Terry.Li-彬

          虛其心,可解天下之問;專其心,可治天下之學;靜其心,可悟天下之理;恒其心,可成天下之業(yè)。

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            143 隨筆 :: 344 文章 :: 130 評論 :: 0 Trackbacks
           

          如何在portal中增加一個portlet (非content_portlet)。

          通過分析知道,在Add Content中點擊某個portlet的add按鈕后,服務器會收到一個/c/portal/update_layout...的請求(這里與生成 Add Content Portlet有區(qū)別,在前面文章中提到,那時的請求是一個/c/portal/render_portlet...),服務器在收到請求后前面的步驟同上面分析add content portlet的過程一樣。

          PortalRequestProcess.process()

          String path = processPath(request, response);
          //這里path = “/portal/update_layout”.

          ActionMapping mapping = processMapping(request, response, path);
          //這里找到在struts-config.xml中定義的關(guān)于上面path的mapping.

          Action action = processActionCreate(request, response, mapping);
          //這里生成了UpdateLayoutAction.

          ActionForward forward = processActionPerform(request, response, action, form, mapping);

          processForwardConfig(request, response, forward);

          在struts-config.xml中有定義:
          <action path="/portal/update_layout" type="com.liferay.portal.action.UpdateLayoutAction" />

          UpdateLayoutAction.execute()

          LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

          String cmd = ParamUtil.getString(req, Constants.CMD);

          String portletId = ParamUtil.getString(req, "p_p_id");

          if (cmd.equals(Constants.ADD))
          {  portletId = layoutTypePortlet.addPortletId(userId, portletId); }
          else if (cmd.equals(Constants.DELETE)) { layoutTypePortlet.removePortletId(portletId); }
          else if (cmd.equals("drag")) { }
          else if (cmd.equals("minimize")) { }
          else if (cmd.equals("move")) { layoutTypePortlet.movePortletId(userId, portletId, columnId, columnPos); }
          else if (cmd.equals("template")) { }

          if (ParamUtil.getBoolen(req, "refresh")) {}
          else {
            if (cmd.equals(Constants.ADD) && (portletId != null)) {
            Action renderPortletAction = (Action)InstancePool.get(RenderPortletAction.class.getName());
            renderPortletAction.execute(mapping, form, dynamicReq, res);
          }

          因為cmd=add,所以調(diào)用LayoutTypePortlet.addPortletId()來將portletId加入到Layout中,而且最后調(diào)用RenderPortletAction.execute()來將這個portlet最終render出來,具體過程如上面關(guān)于content portlet的分析。

           

          Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2177387

          posted on 2008-03-14 14:13 禮物 閱讀(705) 評論(0)  編輯  收藏 所屬分類: Liferay
          主站蜘蛛池模板: 德江县| 运城市| 信宜市| 承德县| 封开县| 长岭县| 樟树市| 琼海市| 应城市| 大宁县| 赫章县| 明水县| 宁强县| 上饶县| 营山县| 长兴县| 沁阳市| 江华| 花莲市| 诸暨市| 吉林省| 光山县| 吉木乃县| 剑阁县| 周至县| 甘肃省| 随州市| 尼木县| 石河子市| 阳曲县| 治多县| 贵州省| 易门县| 衡阳市| 育儿| 澎湖县| 宁都县| 肃北| 喀喇| 枣庄市| 玛曲县|