xforms:setvalue

Purpose

Associates a specific xforms:submit control with the value to be submitted when there are multiple submit buttons on a form.

Contained by

Attributes

Attribute Description Type Default Options Use
ev:event A global attribute defined within the XML Events namespace. The namespace declaration http://www.w3.org/2001/xml-events must be declared. The only value supported is 'DOMActivate'. xs:string   DOMAvtivate  required 
ref Identifies the request parameter xs:string none    optional 
value For WML devices, the value attribute may be used to differentiate the buttons. It specifies the value to set in the submitted form. If it is not present, then the content of the xforms:setvalue element is used as the value. If the content is empty, then it is equivalent to specifying a value attribute as an empty string. The content model for the xforms:setvalue element is PCDATA. For devices other than WML such as HTML, XHTML, XHTMLMobile, XHTMLBasic, etc., the content of the xforms:label element is used as the value of the ref attribute. xs:string none    optional 

Attribute groups

Examples

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:si="http://www.volantis.com/xmlns/2006/01/xdime2/si"
  xmlns:xforms="http://www.w3.org/2002/xforms"
  xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <title>xforms:setvalue</title>
    <xforms:model id="form">
      <xforms:instance>
        <si:instance>
          <si:item name="hidden">123</si:item>
        </si:instance>
      </xforms:instance>
      <xforms:submission action="response.jsp" id="submit"/>
    </xforms:model>
  </head>
  <body>
    <p>
      <xforms:submit submission="submit">
        <xforms:label>button1</xforms:label>
        <xforms:setvalue ev:event="DOMActivate" ref="btype" value="bt1"/>
      </xforms:submit>
      <xforms:submit submission="submit">
        <xforms:label>button2</xforms:label>
        <xforms:setvalue ev:event="DOMActivate" ref="btype" value="bt2"/>
      </xforms:submit>
    </p>
  </body>
</html>

For WML devices, if you press button1, then the btype=bt1 parameter will be added to the request, and the URL will have the following form:

http://localhost:8080/mcs/response.jsp?hidden=123&amp;vform=s0&amp;btype=bt1

If you press button2, then btype=bt2 will be added to the request. In this case the URL will be similar to the following example:

http://localhost:8080/mcs/response.jsp?hidden=123&amp;vform=s0&amp;btype=bt2

For devices other that WML, if you press button1, then the btype=button1 parameter will be added to the request, and the URL will have the following form:

http://localhost:8080/mcs/response.jsp?hidden=123&amp;vform=s0&amp;btype=button1

If you press button2, then btype=button2 will be added to the request, and the URL will look like this:

http://localhost:8080/mcs/response.jsp?hidden=123&amp;vform=s0&amp;btype=button2

It is also possible to discriminate on the basis of the ref attribute.

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:si="http://www.volantis.com/xmlns/2006/01/xdime2/si"
  xmlns:xforms="http://www.w3.org/2002/xforms"
  xmlns:ev="http://www.w3.org/2001/xml-events">
  <head>
    <title>xforms:setvalue</title>
    <xforms:model id="form">
      <xforms:instance>
        <si:instance>
          <si:item name="hidden">123</si:item>
        </si:instance>
      </xforms:instance>
      <xforms:submission action="response.jsp" id="submit"/>
    </xforms:model>
  </head>
  <body>
    <p>
      <xforms:submit submission="submit">
        <xforms:label>button3</xforms:label>
        <xforms:setvalue ev:event="DOMActivate" ref="btype3" value="1"/>
      </xforms:submit>
      <xforms:submit submission="submit">
        <xforms:label>button4</xforms:label>
        <xforms:setvalue ev:event="DOMActivate" ref="btype4" value="2"/>
      </xforms:submit>
    </p>
  </body>
</html>

For WML devices, if you press button3, then the btype3=1 parameter will be appended to the request. If button4 is pressed, then the btype4=2 parameter will be added to the request. For devices other than WML, the content of the xforms:label element will be used as the value of the ref attribute. In other words, the btype3=button3 or btype4=button4 parameter will be added to the request.

Related topics