Terry.Li-彬

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

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

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

          通過分析知道,在Add Content中點擊某個portlet的add按鈕后,服務器會收到一個/c/portal/update_layout...的請求(這里與生成 Add Content Portlet有區別,在前面文章中提到,那時的請求是一個/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中定義的關于上面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,所以調用LayoutTypePortlet.addPortletId()來將portletId加入到Layout中,而且最后調用RenderPortletAction.execute()來將這個portlet最終render出來,具體過程如上面關于content portlet的分析。

           

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

          posted on 2008-03-14 14:13 禮物 閱讀(700) 評論(0)  編輯  收藏 所屬分類: Liferay
          主站蜘蛛池模板: 临江市| 石嘴山市| 灵台县| 玉龙| 桃江县| 大足县| 丁青县| 嵊州市| 河源市| 沾化县| 瑞金市| 彰武县| 苗栗县| 体育| 黑龙江省| 吐鲁番市| 颍上县| 麦盖提县| 泗水县| 南郑县| 博罗县| 托克托县| 灵石县| 墨脱县| 四子王旗| 宁河县| 绍兴市| 无锡市| 从江县| 丁青县| 天气| 吉安市| 莲花县| 读书| 黄龙县| 荥阳市| 云林县| 彝良县| 丹江口市| 白山市| 察隅县|