| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectHttpServlet
com.ibm.wps.pe.pc.legacy.cache.CacheablePortlet
org.apache.jetspeed.portlet.Portlet
org.apache.jetspeed.portlet.PortletAdapter
com.ibm.wps.portlets.menu.XMIMenuTreePortlet
public class XMIMenuTreePortlet
XMIMenuTreePortlet is a convenience implementation of a portlet that exposes a static portlet menu based on the content of an XMI file.
The XMIMenuTreePortlet is a default implementation for the Portlet interface. If a portlet uses a static XMI tree, IBM recommends that it derives from XMIMenuTreePortlet. The tree structure is completely defined in an XML file, e.g., menu-tree.xml. In the deployment descriptor portlet.xml, the configuration parameter XMIFilePath for the concrete portlet specifies the full path of this XML file relative to the directory <Portlet_HOME>/war. The method getMenu(com.ibm.wps.portlet.menu.MenuContext) does not have to be implemented any more.
The following example shows a section of portlet.xml including the configuration parameter for XMIFilePath.
<concrete-portlet href="#Portlet_1"> <portlet-name> ... </portlet-name> <config-param> <param-name>XMIFilePath</param-name> <param-value>menu-tree.xml</param-value> </config-param> </concrete-portlet>
The next example shows how menu-tree.xml can be implemented to create a menu tree with two nodes and two subnodes of the first node. Title and description are set in two different locales.
Code of menu-tree.xml:
<!DOCTYPE menu-tree PUBLIC "-//IBM//DTD Portlet Menu 1.0//EN" "menu-tree.dtd"> <!-- root node --> <menu-tree id="id0"> <!-- root node --> <menu-node id="rootId"> <display-info> <locale>en</locale> <title>XMI Test Portlet</title> <description>XMI Tree Description</description> </display-info> <display-info> <locale>fr</locale> <title>XMI Test Portlet</title> <description>XMI Tree Description</description> </display-info> <!-- node 1 --> <menu-node id="id1"> <display-info> <locale>en</locale> <title>Node 1</title> <description>Node 1 Description</description> </display-info> <display-info> <locale>fr</locale> <title>Noeud 1</title> <description>Noeud 1 Description</description> </display-info> <action-name>Node1Action</action-name> <param id="n1-pid1"> <param-name>Param1Name</param-name> <param-value>Node1Param1Value</param-value> </param> <param id="n1-pid2"> <param-name>Param2Name</param-name> <param-value>Node1Param2Value</param-value> </param> <!-- node 1.1 --> <menu-node id="id1_1"> <display-info> <locale>en</locale> <title>Node 1.1</title> <description>Node 1.1 Description</description> </display-info> </menu-node> <!-- node 1.2 --> <menu-node id="id1_2"> <display-info> <locale>en</locale> <title>Node 1.2</title> <description>Node 1.2 Description</description> </display-info> </menu-node> </menu-node> <!-- node 2 --> <menu-node id="id2"> <display-info> <locale>en</locale> <title>Node 2</title> <description>Node 2 Description</description> </display-info> <display-info> <locale>fr</locale> <title>Noeud 2</title> <description>Noeud 2 Description</description> </display-info> <action-name>Node2Action</action-name> <param id="n2-pid1"> <param-name>Param1Name</param-name> <param-value>Node2Param1Value</param-value> </param> <param id="n2-pid2"> <param-name>Param2Name</param-name> <param-value>Node2Param2Value</param-value> </param> </menu-node> </menu-node> </menu-tree>
Sample portlet source code:
import java.io.*; import org.apache.jetspeed.portlet.*; import org.apache.jetspeed.portlet.event.*; import com.ibm.wps.portlet.menu.*; import com.ibm.wps.portlets.menu.*; public class XMITestPortlet extends XMIMenuTreePortlet implements MenuProvider, ActionListener { public void doView(PortletRequest request, PortletResponse response) throws PortletException, IOException { // Invoke the JSP to render getPortletConfig().getContext().include("/jsp/View.jsp", request, response); } public void actionPerformed(ActionEvent event) throws PortletException { if (event != null) { String actionString = event.getActionString(); PortletRequest request = event.getRequest(); if (actionString != null) { request.setAttribute("ActionString", actionString); } } } }
with /jsp/View.jsp:
<%@ page contentType="text/html"%> <H3>Test of XMIMenuTree</H3> <UL> <LI>Expand root node and <CITE>Node 1</CITE>.<BR><BR> </LI> <LI>Click <CITE>Node 1</CITE> and <CITE>Node 2</CITE>. Check if action string and request parameters are displayed. <TABLE BORDER="0"> <TR> <TD>Action:</TD> <TD><%=request.getAttribute("ActionString")%></TD> </TR><TR> <TD>Param1:</TD> <TD><%=request.getParameter("Param1Name")%></TD> </TR><TR> <TD>Param2:</TD> <TD><%=request.getParameter("Param2Name")%></TD> </TR> </TABLE> <BR> </LI> </UL>
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.jetspeed.portlet.Portlet |
---|
Portlet.Mode, Portlet.ModeModifier |
Constructor Summary | |
---|---|
protected | XMIMenuTreePortlet()
Deprecated. Constructor. |
Method Summary | |
---|---|
MenuTree | getMenu(MenuContext menuContext)
Deprecated. Returns the menu tree containing the complete portlet menus configured in an XML file. |
Methods inherited from class org.apache.jetspeed.portlet.PortletAdapter |
---|
destroy, destroyConcrete, doConfigure, doEdit, doHelp, doView, getLastModified, getPortletConfig, getPortletLog, getVariable, init, initConcrete, login, logout, removeVariable, service, setVariable |
Methods inherited from class org.apache.jetspeed.portlet.Portlet |
---|
destroy, doGet, doPost, doPut, getId, getInitParameter, getInitParameterNames, getPortletSettings, getServletContext, getServletInfo |
Methods inherited from class com.ibm.wps.pe.pc.legacy.cache.CacheablePortlet |
---|
getSharingPolicy |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected XMIMenuTreePortlet()
Method Detail |
---|
public MenuTree getMenu(MenuContext menuContext) throws PortletException
| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |