Bryan Schmiedeler
Bryan Schmiedeler

Reputation: 3127

Xpages Navigator Menu

My database has a nice navigator that is dynamic (although it is not a dynamic navigator - I don't understand what that is).

I have some sessionScope variables that I load. The variables are driven by the user entering data in an administration page.

The user enters Apps (Application Bar), Titles (Title Bar) - tied to one or more Apps, and finally Pages, tied to one or more titles.

I use repeats in the nav control for the Pages, then a container node below that for the description, and then another repeat for the categories of the docs in the page, and then a basic node for the views. It works well.

What I want is for some sessionScope.page variables to have a special attribute to indicate that they will not be views of documents, but clicking on that page in the navigator will present one document to the user and they can edit or save it.

I cannot figure out how to do it. So in the screen shot below, if the user clicks "Best Practices" it should just open a doc in the middle pane, NOT an entry with "All" below it.

enter image description here

I think this might be easier in a repeat control, but an open to any suggestions.

Thanks!

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xe="http://www.ibm.com/xsp/coreex">
    <xp:this.resources>
        <xp:styleSheet href="/menus.css"></xp:styleSheet>
        <xp:styleSheet href="/buttons.css"></xp:styleSheet>
    </xp:this.resources>
    <xp:this.beforePageLoad><![CDATA[#{javascript:sessionScope.filterContent = "All";
setTags(sessionScope.selectedPage);}]]></xp:this.beforePageLoad>

    <xp:panel>
        <xe:navigator id="navigator1">
            <xe:this.treeNodes>
                <xe:repeatTreeNode var="entry" indexVar="index">
                    <xe:this.value><![CDATA[#{javascript:var tmpKey:String = sessionScope.selectedTitle;
sessionScope.render[tmpKey]}]]></xe:this.value>
                    <xe:this.children>
                        <xe:basicContainerNode
                            submitValue="#{javascript:entry}" style="font-size:10pt">
                            <xe:this.label><![CDATA[#{javascript:sessionScope.descriptions[entry]}]]></xe:this.label>
                            <xe:this.children>
                                <xe:repeatTreeNode var="entry2"
                                    indexVar="index2">
                                    <xe:this.value><![CDATA[#{javascript:var tmpArr = [];
tmpArr.unshift("All");
tmpArr2 = @Unique(@Trim(@DbColumn(@DbName(),sessionScope.selectedPage,1)));
if (tmpArr2.length == 0)
{var tmpArr3 = tmpArr}
else
{var tmpArr3 = tmpArr.concat(tmpArr2)}
tmpArr3}]]></xe:this.value>
                                    <xe:this.children>
                                        <xe:basicLeafNode
                                            label="#{javascript:entry2}"
                                            submitValue="#{javascript:entry2}" style="font-size:8pt">
                                            <xe:this.rendered><![CDATA[#{javascript:if (sessionScope.selectedPage == entry)
{return true}}]]></xe:this.rendered>
                                            <xe:this.selected><![CDATA[#{javascript:if (sessionScope.filterContent == entry2)
{return true}
else
{return false}}]]></xe:this.selected>
                                        </xe:basicLeafNode>
                                    </xe:this.children>
                                </xe:repeatTreeNode>
                            </xe:this.children>
                        </xe:basicContainerNode>
                    </xe:this.children>
                </xe:repeatTreeNode>
            </xe:this.treeNodes>
            <xp:eventHandler event="onItemClick" submit="true"
                refreshMode="complete">
                <xe:this.action><![CDATA[#{javascript:var tmpStr:String = context.getSubmittedValue(); 
var act:String;

if (tmpStr.substring(0,4) == "page")
{act = "page"}
if (tmpStr.substring(0,4) != "page")
{act = "cat"}

switch (act)
{
  case "page":
    // Do something
    sessionScope.selectedPage = tmpStr;
    sessionScope.filterType = "Categories";
    sessionScope.filterContent = "All";
    setTags(sessionScope.selectedPage);
    viewScope.tag = "";
    break;
  case "cat":
    // Do something else
    sessionScope.filterType = "Categories";
    sessionScope.filterContent = tmpStr; 
    viewScope.tag = "";
    break;
  default: 
    // Default case
    break;
}

</xp:view>

Upvotes: 1

Views: 655

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

Create a session scope variable "type". It defines for every entry a type "doc" or "view".

Depending on entry's type render a basicLeafNode for just the menu entry (in your example "Best Practices") or a basicContainerNode/basicLeafNode like before. Use property rendered:

<xp:panel>
    <xe:navigator id="navigator1">
        <xe:this.treeNodes>
            <xe:repeatTreeNode var="entry" indexVar="index"
                value="#{javascript:sessionScope.render[sessionScope.selectedTitle]}">
                <xe:this.children>
                    <xe:basicLeafNode
                       rendered="#{javascript:sessionScope.type[entry] === 'doc'}"
                       label="#{javascript:sessionScope.descriptions[entry]}"
                       submitValue="#{javascript:entry}">
                    </xe:basicLeafNode>
                    <xe:basicContainerNode
                       rendered="#{javascript:sessionScope.type[entry] === 'view'}"
                       label="#{javascript:sessionScope.descriptions[entry]}"
                       submitValue="#{javascript:entry}"
                       style="font-size:10pt">
                       <xe:this.children>
                          <xe:repeatTreeNode
                             var="entry2"

Upvotes: 1

Related Questions