Xpages 相关字段查找 [英] Xpages Dependent Field Lookups

查看:22
本文介绍了Xpages 相关字段查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I cannot get a simple two field dependency in Xpages to work.

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

Field1 is a combo box whose choices come from a DBLookup.

Field2 是一个组合框,其选择来自 DBLookup,该 DBLookup 使用来自 Field1 的值对选择进行子集化.

Field2 is a combo box whose choices come from a DBLookup that uses the value from Field1 to subset the selections.

我的代码如下:

    <?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>

    </xp:selectItems></xp:view>

我按照你的建议更新了代码,但它仍然不起作用.

I updated the code as you suggested but it STILL doesn't work.

    <?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 事件更改为第二个组合框的部分刷新

  • change your onChange event to a partial refresh of the 2nd combobox

将您的组合框绑定到 document1 上的字段.现在它们没有绑定,因此您无法使用 document1.getItemValueString()

bind your comboboxes to fields on document1. Right now they are not bound and you can therefore not get the selected value by using document1.getItemValueString()

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

remove the 3rd selectItems tag that you have placed outside of your comboboxes

这篇关于Xpages 相关字段查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆