Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.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相关字段查找_Xpages - Fatal编程技术网

Xpages相关字段查找

Xpages相关字段查找,xpages,Xpages,我无法在Xpages中获得一个简单的双字段依赖项 Field1是一个组合框,其选项来自DBLookup Field2是一个组合框,其选择来自DBLookup,该DBLookup使用Field1中的值来子集选择 我的代码如下: <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xp_1="http://www.ib

我无法在Xpages中获得一个简单的双字段依赖项

Field1是一个组合框,其选项来自DBLookup

Field2是一个组合框,其选择来自DBLookup,该DBLookup使用Field1中的值来子集选择

我的代码如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <xp:view xmlns:xp="http://www.ibm.com/xsp/core"
        xmlns:xp_1="http://www.ibm.com/xsp/coreex">
        <xp:this.data>
            <xp:dominoDocument var="document1" formName="timeEntry"></xp:dominoDocument>
        </xp:this.data>

        <xp:comboBox id="comboBox1">
            <xp:this.defaultValue><![CDATA[#{javascript:""}]]></xp:this.defaultValue>
            <xp:selectItems>
                <xp:this.value><![CDATA[#{javascript:var db = new Array(@DbName()[0], 'TSCTT.nsf'); 
    @DbColumn(db, "workCategoryView", 1)}]]></xp:this.value>
            </xp:selectItems>
            <xp:eventHandler event="onchange" submit="true"
                refreshMode="complete">
            </xp:eventHandler>
            </xp:comboBox>
        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:comboBox id="comboBox2">
            <xp:selectItems>
                <xp:this.value><![CDATA[#{javascript:var db = new Array(@DbName()[0], 'TSCTT.nsf'); 
    var key:String = document1.getItemValueString("comboBox1");
    @DbLookup(db,"(DBLookupWorkSubCategoryView)",key,2);}]]></xp:this.value>
            </xp:selectItems>
        </xp:comboBox>
        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:selectItems>
                <xp:this.value><![CDATA[#{javascript:var db = new Array(@DbName()[0], 'TSCTT.nsf'); 
    var key:String = document1.getItemValueString("djFilteringSelect1");
    @DbLookup(db,"(DBLookupWorkSubCategoryView)",key,2);}]]></xp:this.value>
            </xp:selectItems>
我按照你的建议更新了代码,但仍然不起作用

    <?xml version="1.0" encoding="UTF-8"?>
    <xp:view xmlns:xp="http://www.ibm.com/xsp/core"
        xmlns:xp_1="http://www.ibm.com/xsp/coreex">
        <xp:this.data>
            <xp:dominoDocument var="document1" formName="timeEntry"></xp:dominoDocument>
        </xp:this.data>

        <xp:comboBox id="comboBox1" value="#{document1.workCategory}">
            <xp:selectItems>
                <xp:this.value><![CDATA[#{javascript:var db = new Array(@DbName()[0], 'TSCTT.nsf'); 
    @DbColumn(db, "workCategoryView", 1)}]]></xp:this.value>
            </xp:selectItems>
            <xp:eventHandler event="onchange" submit="true"
                refreshMode="partial" refreshId="comboBox2">
            </xp:eventHandler>
        </xp:comboBox>
        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:br></xp:br>
        <xp:comboBox id="comboBox2" value="#{document1.workSubCategory}">
            <xp:selectItems>
                <xp:this.value><![CDATA[#{javascript://var db = new Array(@DbName()[0], 'TSCTT.nsf'); 
    var key:String = document1.getItemValueString("comboBox1");
    //@DbLookup(db,"(DBLookupWorkSubCategoryView)",key,2);
    //var key = document1.getItemValue("comboBox1");
    //var key = currentDocument.getItemValueString("comboBox1")
    key

    //var item = document1.getValue("comboBox1");
    //return item;}]]></xp:this.value>
            </xp:selectItems>
        </xp:comboBox>
        <xp:br></xp:br>
        <xp:selectItems>
                <xp:this.value><![CDATA[#{javascript:var db = new Array(@DbName()[0], 'TSCTT.nsf'); 
    var key:String = document1.getItemValueString("djFilteringSelect1");
    @DbLookup(db,"(DBLookupWorkSubCategoryView)",key,2);}]]></xp:this.value>
            </xp:selectItems></xp:view>
需要改变的事情:

将onChange事件更改为第二个组合框的部分刷新

将组合框绑定到document1上的字段。现在它们没有绑定,因此您无法使用document1.getItemValueString获取所选值

删除放置在组合框外的第三个selectItems标记

需要改变的事情:

将onChange事件更改为第二个组合框的部分刷新

将组合框绑定到document1上的字段。现在它们没有绑定,因此您无法使用document1.getItemValueString获取所选值

删除放置在组合框外的第三个selectItems标记


我注意到value attribute中的代码计算了2次,所以我更喜欢对事件进行查找或计算:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:this.data>
        <xp:dominoDocument var="document1"
            formName="TestComboDependency">
        </xp:dominoDocument>
    </xp:this.data>

    <xp:this.beforePageLoad><![CDATA[#{javascript:
        viewScope.choiceList1 = @DbColumn("", "($LkpChoiceList1)", 1);
        viewScope.choiceEmpty2 = " --- Select a value for combo1 before --- ";
        viewScope.choiceList2 = null;
    }]]></xp:this.beforePageLoad>

    <xp:comboBox id="comboBox1" value="#{document1.Combo1}">
        <xp:selectItem
            itemLabel=" --- Select a value --- "
            itemValue=""
            id="selectItem1" />
        <xp:selectItems
            value="#{viewScope.choiceList1}"
            id="selectItems1" />
        <xp:eventHandler event="onchange" submit="true"
            refreshMode="partial" refreshId="comboBox2"
            disableValidators="true">
            <xp:this.action><![CDATA[#{javascript:
                var sKey:string = document1.getItemValueString("Combo1");
                viewScope.choiceEmpty2 = " --- Select a value --- ";
                viewScope.choiceList2 = @DbLookup("", "($LkpChoiceList2)", sKey, 2);
            }]]></xp:this.action>
        </xp:eventHandler>
    </xp:comboBox>

    <xp:comboBox id="comboBox2" value="#{document1.Combo2}">
        <xp:selectItem
            itemLabel="#{viewScope.choiceEmpty2}"
            itemValue=""
            id="selectItem2" />
        <xp:selectItems
            value="#{viewScope.choiceList2}"
            id="selectItems2" />
    </xp:comboBox>

</xp:view>

我注意到value attribute中的代码计算了2次,所以我更喜欢对事件进行查找或计算:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

    <xp:this.data>
        <xp:dominoDocument var="document1"
            formName="TestComboDependency">
        </xp:dominoDocument>
    </xp:this.data>

    <xp:this.beforePageLoad><![CDATA[#{javascript:
        viewScope.choiceList1 = @DbColumn("", "($LkpChoiceList1)", 1);
        viewScope.choiceEmpty2 = " --- Select a value for combo1 before --- ";
        viewScope.choiceList2 = null;
    }]]></xp:this.beforePageLoad>

    <xp:comboBox id="comboBox1" value="#{document1.Combo1}">
        <xp:selectItem
            itemLabel=" --- Select a value --- "
            itemValue=""
            id="selectItem1" />
        <xp:selectItems
            value="#{viewScope.choiceList1}"
            id="selectItems1" />
        <xp:eventHandler event="onchange" submit="true"
            refreshMode="partial" refreshId="comboBox2"
            disableValidators="true">
            <xp:this.action><![CDATA[#{javascript:
                var sKey:string = document1.getItemValueString("Combo1");
                viewScope.choiceEmpty2 = " --- Select a value --- ";
                viewScope.choiceList2 = @DbLookup("", "($LkpChoiceList2)", sKey, 2);
            }]]></xp:this.action>
        </xp:eventHandler>
    </xp:comboBox>

    <xp:comboBox id="comboBox2" value="#{document1.Combo2}">
        <xp:selectItem
            itemLabel="#{viewScope.choiceEmpty2}"
            itemValue=""
            id="selectItem2" />
        <xp:selectItems
            value="#{viewScope.choiceList2}"
            id="selectItems2" />
    </xp:comboBox>

</xp:view>

我真傻。我让它工作了。但是,如果字段是自定义控件的一部分,则它似乎不起作用。如果我把它们放在自己的XPage中,它们就可以工作,但如果它们在CC中,它们就不能工作。是这样吗?好吧,不是这样的。“我的工作子类别”字段已在验证属性中选中所需字段。如果检查了,它就不起作用了。这是一个奇怪的错误。但是谢谢你指出了其他的错误。我真傻。我让它工作了。但是,如果字段是自定义控件的一部分,则它似乎不起作用。如果我把它们放在自己的XPage中,它们就可以工作,但如果它们在CC中,它们就不能工作。是这样吗?好吧,不是这样的。“我的工作子类别”字段已在验证属性中选中所需字段。如果检查了,它就不起作用了。这是一个奇怪的错误。但是谢谢你指出了其他的错误。