本文整理汇总了Java中com.liferay.portal.model.LayoutTypePortlet.addPortletId方法的典型用法代码示例。如果您正苦于以下问题:Java LayoutTypePortlet.addPortletId方法的具体用法?Java LayoutTypePortlet.addPortletId怎么用?Java LayoutTypePortlet.addPortletId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.model.LayoutTypePortlet
的用法示例。
在下文中一共展示了LayoutTypePortlet.addPortletId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPortletToPage
import com.liferay.portal.model.LayoutTypePortlet; //导入方法依赖的package包/类
public static String addPortletToPage(Layout layout, String portletId, E_ContextPath path, long userId) {
String result = null;
try {
LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();
// count all portlets currently registered for this column
List<Portlet> portlets = layoutTypePortlet.getAllPortlets(path.getColumnId());
int colSize = portlets != null ? portlets.size() : 0;
// add new portlet at the very end
result = layoutTypePortlet.addPortletId(userId, portletId, path.getColumnId(), colSize, false);
// update the layout
LayoutLocalServiceUtil.updateLayout(layout.getGroupId(),
layout.isPrivateLayout(),
layout.getLayoutId(),
layout.getTypeSettings());
} catch (Throwable t) {
m_objLog.warn(t);
}
return result;
}
示例2: addLayoutColumnPortlet
import com.liferay.portal.model.LayoutTypePortlet; //导入方法依赖的package包/类
protected void addLayoutColumnPortlet(
Layout layout, String columnId, JSONObject portletJSONObject)
throws Exception {
LayoutTypePortlet layoutTypePortlet =
(LayoutTypePortlet)layout.getLayoutType();
String rootPortletId = portletJSONObject.getString("portletId");
if (Validator.isNull(rootPortletId)) {
throw new ImporterException("portletId is not specified");
}
String portletId = layoutTypePortlet.addPortletId(
userId, rootPortletId, columnId, -1, false);
JSONObject portletPreferencesJSONObject =
portletJSONObject.getJSONObject("portletPreferences");
if ((portletPreferencesJSONObject == null) ||
(portletPreferencesJSONObject.length() == 0)) {
return;
}
PortletPreferences portletSetup =
PortletPreferencesFactoryUtil.getLayoutPortletSetup(
layout, portletId);
Iterator<String> iterator = portletPreferencesJSONObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
String value = portletPreferencesJSONObject.getString(key);
if (rootPortletId.equals(PortletKeys.JOURNAL_CONTENT) &&
key.equals("articleId")) {
value = getJournalId(value);
}
portletSetup.setValue(key, value);
}
portletSetup.store();
if (rootPortletId.equals(PortletKeys.NESTED_PORTLETS)) {
JSONArray columnsJSONArray =
portletPreferencesJSONObject.getJSONArray("columns");
StringBundler sb = new StringBundler(4);
sb.append(StringPool.UNDERLINE);
sb.append(portletId);
sb.append(StringPool.DOUBLE_UNDERLINE);
sb.append(LayoutTypePortletConstants.COLUMN_PREFIX);
addLayoutColumns(layout, sb.toString(), columnsJSONArray);
}
}