Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
xpages extlib breadcrumbs:如何让函数生成正确的链接_Xpages_Xpages Ssjs_Xpages Extlib - Fatal编程技术网

xpages extlib breadcrumbs:如何让函数生成正确的链接

xpages extlib breadcrumbs:如何让函数生成正确的链接,xpages,xpages-ssjs,xpages-extlib,Xpages,Xpages Ssjs,Xpages Extlib,我的文档有3个字段,可用于对文档进行“分类”。对于面包屑,我希望显示这些字段,链接将在“类别”级别打开一个视图(在视图中打开单个类别) 现在,文档中的所有“类别”字段都不是必需的。我想我应该编写一个SSJS函数,返回必要的对象来控制面包屑,但是我很难弄清楚该怎么做才能让链接真正工作 到目前为止,我的函数如下所示: function getBreadCrumbs(doc:NotesDocument) { var breadCrumbs=[]; //always add h

我的文档有3个字段,可用于对文档进行“分类”。对于面包屑,我希望显示这些字段,链接将在“类别”级别打开一个视图(在视图中打开单个类别)

现在,文档中的所有“类别”字段都不是必需的。我想我应该编写一个SSJS函数,返回必要的对象来控制面包屑,但是我很难弄清楚该怎么做才能让链接真正工作

到目前为止,我的函数如下所示:

function getBreadCrumbs(doc:NotesDocument) {
    var breadCrumbs=[];

        //always add home as first level
    var thisCrumb = {label:"Home", page:"/home"};
    breadCrumbs.push(thisCrumb);

    if(doc.hasItem("CategoryV2")) {
        var label:String = doc.getItemValueString('CategoryV2');
        if(label!="") {
            var thisCrumb = {label:label, page:"/home"};
            breadCrumbs.push(thisCrumb);
        }
    }

    if(doc.hasItem("SectionNameV2")) {
        var label:String = doc.getItemValueString('SectionNameV2');
        if(label!="") {
            var thisCrumb = {label:label, page:"/home"};
            breadCrumbs.push(thisCrumb);
        }
    }

    if(doc.hasItem("SubSectionNameV2")) {
        var label:String = doc.getItemValueString('SubSectionNameV2');
        if(label!="") {
            var thisCrumb = {label:label, page:"/home"};
            breadCrumbs.push(thisCrumb);
        }
    }

    if(doc.hasItem("Subject")) {
        var label:String = doc.getItemValueString('Subject');
        if(label!="") {
            var thisCrumb = {label:label};
            breadCrumbs.push(thisCrumb);
        }
    }

    return breadCrumbs;
}
链接实际工作需要什么:是否需要将“页面”对象命名为其他名称

谢谢你的帮助/提示

愚蠢的我

在breadcrumbs控件peoperties中,我忘记指定Href属性等于crumb.page。。。请注意.xsp也是链接实际工作所必需的

因此,起作用的函数如下所示:

function getBreadCrumbs(doc:NotesDocument) {
    var breadCrumbs=[];

        //always add home as first level
    var thisCrumb = {label:"Home", page:"/home.xsp"};
    breadCrumbs.push(thisCrumb);

    if(doc.hasItem("CategoryV2")) {
        var label:String = doc.getItemValueString('CategoryV2');
        if(label!="") {
            var thisCrumb = {label:label, page:"/home.xsp?category="+label};
            breadCrumbs.push(thisCrumb);
        }
    }

    if(doc.hasItem("SectionNameV2")) {
        var label:String = doc.getItemValueString('SectionNameV2');
        if(label!="") {
            var thisCrumb = {label:label, page:"/allDocs.xsp&section="+label};
            breadCrumbs.push(thisCrumb);
        }
    }

    if(doc.hasItem("SubSectionNameV2")) {
        var label:String = doc.getItemValueString('SubSectionNameV2');
        if(label!="") {
            var thisCrumb = {label:label, page:"/allDocs.xsp?subsection="+label};
            breadCrumbs.push(thisCrumb);
        }
    }

    if(doc.hasItem("Subject")) {
        var label:String = doc.getItemValueString('Subject');
        if(label!="") {
            var thisCrumb = {label:label};
            breadCrumbs.push(thisCrumb);
        }
    }

    return breadCrumbs;
}
自定义控件中的代码现在是:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom"
    xmlns:xe="http://www.ibm.com/xsp/coreex">

    <xe:breadCrumbs id="breadCrumbs1">
        <xe:this.treeNodes>
            <xe:repeatTreeNode indexVar="1" var="crumb">
                <xe:this.children>
                    <xe:basicLeafNode label="#{crumb.label}" href="#{javascript:crumb.page}">
                    </xe:basicLeafNode>
                </xe:this.children>
                <xe:this.value><![CDATA[#{javascript:getBreadCrumbs(document1.getDocument());}]]></xe:this.value>
            </xe:repeatTreeNode>
        </xe:this.treeNodes>
    </xe:breadCrumbs>
</xp:view>

我错过的是使用来自SSJS函数的值设置basicLeaNode的“Href”。我有标签,但是当我在SSJS函数中添加代码来构建fref时,我完全忘记了修改自定义控件来添加此属性

那是个糟糕的一天


仅供参考,allDocs.xsp页面会显示一个视图,我会使用URL参数过滤该视图。

您会用工作解决方案更新您的答案吗?