如何在xpages中绑定计算字段中的数据

如何在xpages中绑定计算字段中的数据,xpages,xpages-extlib,xpages-ssjs,Xpages,Xpages Extlib,Xpages Ssjs,我正在尝试从计算字段将数据绑定到表单,该字段根据所选天数计算金额。请帮助我 我也有同样的问题。这可能不是解决这个问题的最有效的方法,但它是有效的 var cost1=getComponent('ItemCost1').getValue(); 文件1.replaceItemValue(“项目成本1”,成本1) 您可以将其放在QuerySave事件中&它工作得很好 我的首选是让计算字段完成工作,并将目标字段放在一个不向用户显示但在XPage上可见的位置。大概是这样的: <xp:table id

我正在尝试从计算字段将数据绑定到表单,该字段根据所选天数计算金额。请帮助我

我也有同样的问题。这可能不是解决这个问题的最有效的方法,但它是有效的

var cost1=getComponent('ItemCost1').getValue(); 文件1.replaceItemValue(“项目成本1”,成本1)


您可以将其放在QuerySave事件中&它工作得很好

我的首选是让计算字段完成工作,并将目标字段放在一个不向用户显示但在XPage上可见的位置。大概是这样的:

<xp:table id="dataTable">
    <xp:tr>
        <xp:td>
            <xp:label value="Price Per Day" id="label1"></xp:label>
            </xp:td>
        <xp:td>
            <xp:inputText id="PricePerDayEB1" value="#{document1.PricePerDay}" defaultValue="25">
                <xp:this.converter>
                    <xp:convertNumber type="currency"></xp:convertNumber>
                </xp:this.converter>
                <xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="dataTable">
                </xp:eventHandler>
            </xp:inputText>
        </xp:td>
    </xp:tr>
    <xp:tr>
        <xp:td>
            <xp:label value="Days" id="label2"></xp:label>
        </xp:td>
        <xp:td>
            <xp:inputText id="DaysEB1" value="#{document1.Days}" defaultValue="1">
                <xp:this.converter>
                    <xp:convertNumber type="number" integerOnly="true">
                    </xp:convertNumber>
                </xp:this.converter>
                <xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="dataTable">
                </xp:eventHandler>
            </xp:inputText>
        </xp:td>
    </xp:tr>
    <xp:tr>
        <xp:td>
            <xp:label value="Computed Total" id="label3"></xp:label>
        </xp:td>
        <xp:td>
            <xp:text escape="true" id="compTotalCF1">
                <xp:this.value><![CDATA[#{javascript:
var PricePerDayEB1:com.ibm.xsp.component.xp.XspInputText = getComponent("PricePerDayEB1");
var DaysEB1:com.ibm.xsp.component.xp.XspInputText = getComponent("DaysEB1");
var TotalEB1:com.ibm.xsp.component.xp.XspInputText = getComponent("TotalEB1");

var ppd = PricePerDayEB1.getValue();
var days = DaysEB1.getValue();
var total = ppd*days

TotalEB1.setValue(total);
return total;
}]]></xp:this.value>
            </xp:text>
        </xp:td>
    </xp:tr>
    <xp:tr style="display:none;">
        <xp:td>
            <xp:label value="Bound Total" id="label4"></xp:label>
        </xp:td>
        <xp:td>
            <xp:inputText id="TotalEB1" value="#{document1.Total}">
                <xp:this.converter>
                    <xp:convertNumber type="number"></xp:convertNumber>
                </xp:this.converter>
            </xp:inputText>
        </xp:td>
    </xp:tr>
    <xp:tr>
        <xp:td colspan="2">
            <xp:button value="Submit" id="button1">
            <xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true"></xp:eventHandler></xp:button>
        </xp:td>
    </xp:tr>
</xp:table>

快乐编码

/新员工

可能重复的