portletContextMenu.jsp
<%-- Licensed Materials - Property of IBM, 5724-E76, (C) Copyright IBM Corp. 2001, 2004, 2006 - All Rights reserved. NOTE: See notes in Default.jsp for information regarding editing theme JSP fragments. --%> <%@ page session="false"%> <%! private static com.ibm.portal.state.service.PortalStateManagerServiceHome portalStateManagerServiceHome; private static com.ibm.portal.identification.Identification identification; private static com.ibm.portal.model.NavigationSelectionModelHome nsmHome; private static final javax.portlet.PortletMode EDIT_DEFAULTS_MODE=new javax.portlet.PortletMode("edit_defaults"); private static final javax.portlet.PortletMode CONFIG_MODE=new javax.portlet.PortletMode("config"); public void jspInit() { try { /* only perform this JNDI lookup once as this is an expensive call performance wise */ javax.naming.Context ctx=new javax.naming.InitialContext(); portalStateManagerServiceHome=(com.ibm.portal.state.service.PortalStateManagerServiceHome) ctx.lookup("portal:service/state/PortalStateManager"); identification=(com.ibm.portal.identification.Identification) ctx.lookup("portal:service/Identification"); nsmHome=(com.ibm.portal.model.NavigationSelectionModelHome)ctx.lookup("portal:service/model/NavigationSelectionModel"); } catch (javax.naming.NamingException ne) { } } public com.ibm.portal.ObjectID deserializePortletID(String objectID) { com.ibm.portal.ObjectID result=null; try { result=identification.deserialize(objectID); } catch (com.ibm.portal.serialize.SerializationException se) { } return result; } %> <DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"/> <%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-core" prefix="portal-core" %> <%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-fmt" prefix="portal-fmt" %> <%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-navigation" prefix="portal-navigation" %> <%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-logic" prefix="portal-logic" %> <%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-showtools" prefix="portal-showtools" %> <%@ taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.0/portal-theme-ext" prefix="portal-theme-ext" %> <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt" %> <portal-core:defineObjects/><portal-theme-ext:initthemepolicy/><jsp:useBean id="themePolicy" class="com.ibm.portal.theme.policy.ThemePolicyBean" scope="page"/><% themePolicy.setValuesMap(portalThemePolicyMap); %> <html><body><% com.ibm.portal.model.NavigationSelectionModelProvider nsmProvider=nsmHome.getNavigationSelectionModelProvider(); com.ibm.portal.navigation.NavigationSelectionModel nsm=nsmProvider.getNavigationSelectionModel(request, response); String pageID=identification.serialize(((com.ibm.portal.Identifiable) nsm.getSelectedNode()).getObjectID()); String windowID=pageContext.getRequest().getParameter("windowID"); com.ibm.portal.state.service.PortalStateManagerService service=portalStateManagerServiceHome.getPortalStateManagerService(request, response); com.ibm.portal.state.accessors.portlet.PortletAccessorFactory paf=(com.ibm.portal.state.accessors.portlet.PortletAccessorFactory) service.getAccessorFactory(com.ibm.portal.state.accessors.portlet.PortletAccessorFactory.class); com.ibm.portal.state.accessors.StateAccessorFactory saf=(com.ibm.portal.state.accessors.StateAccessorFactory) service.getAccessorFactory(com.ibm.portal.state.accessors.StateAccessorFactory.class); com.ibm.portal.state.accessors.StateAccessor sa=saf.getStateAccessor(); com.ibm.portal.state.StateHolder state=sa.getStateHolder(request); com.ibm.portal.state.accessors.portlet.PortletAccessor pa=paf.getPortletAccessor(deserializePortletID(windowID), state); com.ibm.portal.state.accessors.solo.SoloAccessorFactory sac=(com.ibm.portal.state.accessors.solo.SoloAccessorFactory) service.getAccessorFactory(com.ibm.portal.state.accessors.solo.SoloAccessorFactory.class); com.ibm.portal.state.accessors.solo.SoloAccessor soloAcc=sac.getSoloAccessor(state); javax.portlet.PortletMode pMode=pa.getPortletMode(); javax.portlet.WindowState wState=pa.getWindowState(); boolean isSolo=false; if (soloAcc.getSoloPortlet() != null) { String soloPortletID=identification.serialize(soloAcc.getSoloPortlet()); if (soloPortletID.equals(windowID)) { isSolo=true; } } int menuItemCount=0; String bidiMoveLeftKey="move.left"; String bidiMoveRightKey="move.right"; %> <portal-fmt:bidi dir="rtl"><% bidiMoveLeftKey="move.right"; bidiMoveRightKey="move.left"; %> </portal-fmt:bidi><script type="text/javascript">function getMenuContents() { return [ <c-rt:if test='<%=!pMode.equals(javax.portlet.PortletMode.VIEW)%>' ><portal-navigation:urlGeneration contentNode="<%=pageID%>" layoutNode="<%=windowID%>" portletMode="view" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="back" /></c:set>"asynchDoFormSubmit('<% wpsURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-navigation:urlGeneration></c-rt:if><c-rt:if test='<%=!pMode.equals(javax.portlet.PortletMode.EDIT) && pMode.equals(javax.portlet.PortletMode.VIEW)%>' ><portal-navigation:urlGeneration contentNode="<%=pageID%>" layoutNode="<%=windowID%>" portletMode="edit" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="edit" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-navigation:urlGeneration></c-rt:if><c-rt:if test='<%=!pMode.equals(EDIT_DEFAULTS_MODE) && pMode.equals(javax.portlet.PortletMode.VIEW)%>' ><portal-navigation:urlGeneration contentNode="<%=pageID%>" layoutNode="<%=windowID%>" portletMode="edit_defaults" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="edit.defaults" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-navigation:urlGeneration></c-rt:if><c-rt:if test='<%=!pMode.equals(CONFIG_MODE) && pMode.equals(javax.portlet.PortletMode.VIEW)%>' ><portal-navigation:urlGeneration contentNode="<%=pageID%>" layoutNode="<%=windowID%>" portletMode="configure" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="configure" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-navigation:urlGeneration></c-rt:if><c-rt:if test='<%=!wState.equals(javax.portlet.WindowState.MINIMIZED) && !isSolo%>' ><portal-navigation:urlGeneration contentNode="<%=pageID%>" layoutNode="<%=windowID%>" portletWindowState="minimized" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="minimize" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-navigation:urlGeneration></c-rt:if><c-rt:if test='<%=!wState.equals(javax.portlet.WindowState.MAXIMIZED) && !isSolo%>' ><portal-navigation:urlGeneration contentNode="<%=pageID%>" layoutNode="<%=windowID%>" portletWindowState="maximized" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="maximize" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-navigation:urlGeneration></c-rt:if><c-rt:if test='<%=!wState.equals(javax.portlet.WindowState.NORMAL) && !isSolo%>' ><portal-navigation:urlGeneration contentNode="<%=pageID%>" layoutNode="<%=windowID%>" portletWindowState="normal" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="restore" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-navigation:urlGeneration></c-rt:if><portal-showtools:portletMoveUp contentNode="<%=pageID%>" layoutNode="<%=windowID%>" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="move.up" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsPortletMoveUpURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-showtools:portletMoveUp><portal-showtools:portletMoveDown contentNode="<%=pageID%>" layoutNode="<%=windowID%>" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="move.down" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsPortletMoveDownURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-showtools:portletMoveDown><portal-showtools:portletMoveLeft contentNode="<%=pageID%>" layoutNode="<%=windowID%>" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="<%=bidiMoveLeftKey%>" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsPortletMoveLeftURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-showtools:portletMoveLeft><portal-showtools:portletMoveRight contentNode="<%=pageID%>" layoutNode="<%=windowID%>" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="<%=bidiMoveRightKey%>" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"asynchDoFormSubmit('<% wpsPortletMoveRightURL.write(escapeXmlWriter); %>');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-showtools:portletMoveRight><portal-showtools:portletDelete contentNode="<%=pageID%>" layoutNode="<%=windowID%>" themeTemplate="" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="delete" /></c:set><c:set var="confirmMsg"><portal-fmt:text bundle="nls.titlebar" key="delete.confirm" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"if (confirm('<c-rt:out value="${confirmMsg}" escapeXml="true" />')) { asynchDoFormSubmit('<% wpsPortletDeleteURL.write(escapeXmlWriter); %>'); }","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-showtools:portletDelete><c-rt:if test='<%=!pMode.equals(javax.portlet.PortletMode.HELP)%>' ><portal-navigation:urlGeneration contentNode="<%=pageID%>" layoutNode="<%=windowID%>" portletWindowState="solo" portletMode="help" themeTemplate="" newWindow="true" ><c:set var="title"><portal-fmt:text bundle="nls.titlebar" key="help" /></c:set><% if (menuItemCount > 0) { %>,<% } %>"window.open('<% wpsURL.write(escapeXmlWriter); %>','','resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,width=800,height=600,screenX=10,screenY=10,top=10,left=10');","<c-rt:out value='${title}' escapeXml='true' />","" <% menuItemCount++; %> </portal-navigation:urlGeneration></c-rt:if><c-rt:if test="${themePolicy.renderExtensions}" ><portal-theme-ext:themeExtension id="com.ibm.portal.theme.plugin.PortletContextMenuItems" ><portal-theme-ext:themeExtensionLoop><c:set var="extensionTitle"><portal-fmt:title varname="<%=(com.ibm.portal.theme.plugin.ThemeItem) themeExtension%>" /></c:set><% if (menuItemCount > 0) { %>,<% } %> <% if (((com.ibm.portal.theme.plugin.ThemeLinkItem) themeExtension).isNewWindow()) { %> "window.open('<portal-theme-ext:themeExtensionItemUrl />','','resizable=yes,scrollbars=yes,menubar=no,toolbar=no,status=no,width=800,height=600,screenX=10,screenY=10,top=10,left=10');", <% } else { %> "asynchDoFormSubmit('<portal-theme-ext:themeExtensionItemUrl />');", <% } %> '<c-rt:out value="${extensionTitle}" escapeXml="true" />', '' </portal-theme-ext:themeExtensionLoop></portal-theme-ext:themeExtension></c-rt:if>]; } </script></body></html>