Portal 8主题中的弹出窗口或菜单下拉菜单

时间:2014-03-23 12:50:13

标签: portal websphere-portal

我想知道是否有人成功创建和使用WebSphere Portal Server v8的弹出窗口或下拉菜单导航?

我们正在使用自定义主题。 我们想要做的是将主页保留在顶部导航栏中并使其具有以便当您将鼠标悬停/单击该页面/选项卡时,菜单(弹出窗口或下拉菜单)显示子页面及其子页面等等上。 欢迎任何建议和指示。 提前谢谢。

2 个答案:

答案 0 :(得分:0)

我做过的主题示例

1)简单下拉

enter image description here

2)多级下拉

enter image description here

我使用ul和li来制作下拉列表,你可以更新topnav.jsp。无法在此处粘贴代码,因为它无法正确显示。

祝你好运

答案 1 :(得分:0)

此示例生成ul-li两级菜单,当然您可以生成更多级别,如果需要,您需要插入html和javascript。将此JSP放到您的主题中,并将include包含到head.jsp中,例如或其他地方。

查看此字符串“your.main.page.unique.name”,将其更改为首页唯一名称。还有函数isHiddenPage,如果你想从菜单中隐藏页面,只需将属性设置为页面hide.from.menu = true

好的,老兄,如果你需要澄清,请告诉我

<%@page import="com.ibm.portal.model.*"%>
<%@page import="com.ibm.portal.navigation.*"%>
<%@page import="com.ibm.portal.identification.*"%>
<%@page import="com.ibm.portal.content.ContentNodeType"%>
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="com.ibm.portal.ModelException"%>
<%@page import="com.ibm.portal.ObjectNotFoundException"%>



<%!

public NavigationNode getNodeByName(NavigationModel nm, NavigationNode rootNode, String nodeUniqueName) throws ModelException {
    Iterator iter = nm.getChildren(rootNode);
    while(iter.hasNext()){
        NavigationNode node = (NavigationNode) iter.next();
        String uniqueName = node.getContentNode().getObjectID().getUniqueName();
        if (uniqueName!= null && uniqueName.equals(nodeUniqueName)) 
            return node;
    }
    return null;

}

public List<NavigationNode> getChildrenNodes(NavigationModel nm, NavigationNode parentNode) throws ModelException{
    List<NavigationNode> children = new ArrayList<NavigationNode>();
    Iterator iter = nm.getChildren(parentNode);
    while(iter.hasNext()){
        NavigationNode node = (NavigationNode) iter.next();
        children.add(node);
    }
    return children;
}

public String getId(Identification identification, NavigationNode node) throws com.ibm.portal.serialize.SerializationException{
    return identification.serialize( ( ( com.ibm.portal.Identifiable ) node ).getObjectID());
}

public boolean isHiddenPage(NavigationNode node){
    if (node instanceof com.ibm.portal.MetaDataProvider) {
        com.ibm.portal.MetaData iMetaData=((com.ibm.portal.MetaDataProvider) node).getMetaData();
        Object url=iMetaData.getValue("hide.from.menu");
        return (url != null && url.toString().equals("true"));
    }
    return false;
}

%>

<%
javax.naming.Context ctx = new javax.naming.InitialContext();
NavigationModelHome nmh = (NavigationModelHome) ctx.lookup("portal:service/model/NavigationModel");;
NavigationModel nm = nmh.getNavigationModelProvider().getNavigationModel(request, response);
NavigationSelectionModelHome nsmh = (NavigationSelectionModelHome) ctx.lookup("portal:service/model/NavigationSelectionModel");
NavigationSelectionModel nsmodel = nsmh.getNavigationSelectionModelProvider().getNavigationSelectionModel(request, response);

NavigationNode rootNode = (NavigationNode) nm.getRoot();
Identification identification = (Identification) ctx.lookup( "portal:service/Identification" );
try{
    if (rootNode != null && nm.hasChildren(rootNode)) {
        NavigationNode myRootNode = getNodeByName(nm, rootNode, "your.main.page.unique.name");
            %>
            <ul>    
            <%
                for (NavigationNode firstLevelPage: getChildrenNodes(nm, myRootNode )){

                String title = firstLevelPage.getTitle(getLocale(pageContext));
                String id = getId(identification, firstLevelPage);
                boolean isNodeSelected = nsmodel.isNodeSelected(firstLevelPage); // if node selected you can apply css class to selected menu item 
                boolean isHidden = isHiddenPage(firstLevelPage); // if node is hidden from menu just continue loop
                %>

                    <li>
                    <portal-navigation:urlGeneration contentNode="<%=id%>">
                           <a class="trigger" href="<% wpsURL.write(out);%>" ><c:out value="<%=title%>"/></a>  
                    </portal-navigation:urlGeneration>

                        <%if (getChildrenNodes(nm,firstLevelPage ).size() > 0){%>

                                    <ul>

                                        <% 
                                            for (NavigationNode secondLevelPage: getChildrenNodes(nm,firstLevelPage )){
                                            String childTitle = secondLevelPage.getTitle(getLocale(pageContext));
                                            String childId = getId(identification, secondLevelPage);
                                            %>

                                                <portal-navigation:urlGeneration contentNode="<%=childId%>">
                                                <li><a href="<% wpsURL.write(out);%>" ><c:out value="<%=childTitle%>"/></a></li>  
                                                </portal-navigation:urlGeneration>

                                        <%}%>   

                                    </ul>                               

                        <%} %>
                    </li>

            <%}%>
        </ul>           
<%          
    }

    }
}catch(ModelException e){
    e.printStackTrace();
}

%>                      

PS。也许我错了括号,检查它