设置值和绑定的问题:值设置为空值

时间:2014-07-30 17:42:53

标签: xpath bind xforms

我正在设计一个XForm搜索表单。这是我的代码

<?xml version="1.0" encoding="ASCII"?>
<xhtml:html xmlns:xhtml="http://www.w3.org/2002/06/xhtml2" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xforms:model id="auctionItems">
        <xforms:instance id="auctions">
            <foo>
                <request>
                    <criterias relation="AND">
                        <criteria name="CritCallCustomerLastName" operator="Equal" model="CustomerLastName" gui_display="Customer LastName"><value></value><value></value></criteria>
                    </criterias>
                </request>
                <dataStore>
                    <store name="CritCallCustomerLastName1"/>
                    <store name="CritCallCustomerLastName2"/>
                </dataStore>
            </foo>
        </xforms:instance>
        <xforms:bind id="bindCallCustomerLastName1" required="false()" type="xforms:string" nodeset="/foo/dataStore/store[@name='CritCallCustomerLastName1']"/>
        <xforms:bind id="bindCallCustomerLastName2" required="false()" type="xforms:string" nodeset="/foo/dataStore/store[@name='CritCallCustomerLastName2']"/>

        <xforms:submission id="search" ref="/foo" replace="none"/>
        <xforms:submission id="order" ref="/foo" replace="none"/>
    </xforms:model>

 <xhtml:body>   
    <xhtml:div class="form-horizontal">
        <xhtml:div style="margin-left: 10px">     
            <xhtml:fieldset>
                <xhtml:legend>Phone Calls</xhtml:legend>
                <xhtml:div class="control-group">
                    <xhtml:label class="control-label">Customer Last Name</xhtml:label>
                    <xhtml:div class="controls">
                        <xforms:input bind="bindCallCustomerLastName1" id="input_call_customer_last_name" class="input-large">
                            <xforms:hint>Customer Last Name 1</xforms:hint>
                        </xforms:input>
                        <xforms:input bind="bindCallCustomerLastName2" id="input_call_customer_last_name" class="input-large">
                            <xforms:hint>Customer Last Name 2</xforms:hint>
                        </xforms:input>
                    </xhtml:div>
                </xhtml:div>
            </xhtml:fieldset>
        </xhtml:div>

            <xforms:repeat nodeset="request/criterias/criteria" id="repeatAuctionItems">
                <xhtml:div class="form-actions">
                    <xhtml:span class="pull-right">
                        <xforms:trigger>
                            <xforms:label>Search</xforms:label>
                            <xforms:action ev:event="DOMActivate">                          
                                <xforms:send submission="search"/>
                                <xforms:setvalue ref="/value[1]" value="../../../dataStore/store[@name='CritCallCustomerLastName1']" /> 
                                <xforms:setvalue ref="/value[2]" value="../../../dataStore/store[@name='CritCallCustomerLastName2']" /> 
                            </xforms:action>
                        </xforms:trigger>

                        <xforms:submit submission="search">
                            <xforms:label>Submit</xforms:label>
                        </xforms:submit>
                    </xhtml:span>
                </xhtml:div>
            </xforms:repeat>    
    </xhtml:div>
</xhtml:body>
</xhtml:html>

表格大部分是按照书面形式进行的。我们在两个输入中输入输入,然后通过绑定设置dataStore中的两个存储节点。

然后我点击了搜索按钮,但似乎从未调用过setvalue,并且不会设置request / criterias / criteria中的值节点。

知道我做错了什么吗?

1 个答案:

答案 0 :(得分:1)

所以问题如下:

原始设定值:

<xforms:setvalue ref="/value[1]" value="../../../dataStore/store[@name='CritCallCustomerLastName1']" /> 
<xforms:setvalue ref="/value[2]" value="../../../dataStore/store[@name='CritCallCustomerLastName2']" /> 

修复方法是:

<xforms:setvalue ref="value[1]" value="../../../../dataStore/store[@name='CritCallCustomerLastName1']" /> 
<xforms:setvalue ref="value[2]" value="../../../../dataStore/store[@name='CritCallCustomerLastName2']" />

实例是条件节点,因此ref应该是&#34; value [*]&#34;并且值指向值节点,因此我们不得不提高额外水平