W3C home > Mailing lists > Public > www-forms@w3.org > February 2007

Simple things First

From: Guntis Ozols <guntiso@latnet.lv>
Date: Wed, 21 Feb 2007 04:01:59 +0200
Message-ID: <1172023319.45dba817e927c@clients.latnet.lv>
To: www-forms@w3.org

Hi,

Thank you for an interesting discussion on "Readonly, relevant attributes for
trigger". This, however, is not the most painful issue with xforms, because
number of triggers is usually low compared to the number of inputs. The most
painful issue is (hush hush taboo) You-Know-Which-One... (see posts Monday, 12
February)

I've included an example (more or less typical), see below. The simplest of
forms, nothing special. Could I do better? Beautiful MVC to some, error-prone
bloated useless spaghetti to me. This problem has not been touched since 2002,
I am worried about the next five years.

The problem very simple, has number of simple solutions, and must be addressed
to add some value to the new spec. Are we all connected to the same reality? Do
you use xforms in production? What kind of forms do you design, if showing an
appropriate message is not important? Please respond, I won't be trolling
anymore.

    <xf:model id="data-model" schema="meta/elements/tyre-element.xsd">
      <xf:instance id="data" src="contextobject:$xf-instance"/>
      <xf:instance id="options" src="contextobject:$xf-options"/>
      <xf:bind readonly="@readonly = 'true'">
        <xf:bind id="b-id" nodeset="id" type="long"/>
        <xf:bind id="b-brand" nodeset="brand" required="true()"/>
        <xf:bind id="b-name" nodeset="name" required="true()"/>
        <xf:bind id="b-type" nodeset="type" required="true()"/>
        <xf:bind id="b-amount" nodeset="amount" required="true()" type="short"/>
        <xf:bind id="b-usage-start-date" nodeset="usage-start-date"
type="date"/>
        <xf:bind id="b-change-date" nodeset="change-date" type="date"/>
        <xf:bind id="b-test-date" nodeset="test-date" type="date"/>
        <xf:bind id="b-storage-address" nodeset="storage-address"/>
        <xf:bind id="b-supplier" nodeset="supplier"/>
        <xf:bind id="b-document-date" nodeset="document-date" required="true()"
type="date"/>
        <xf:bind id="b-document-number" nodeset="document-number"
required="true()"/>
        <xf:bind id="b-purchase-date" nodeset="purchase-date" required="true()"
type="date"/>
        <xf:bind id="b-price" nodeset="price" required="true()" type="float"/>
        <xf:bind id="b-protector-depth-mm" nodeset="protector-depth-mm"
type="float"/>
        <xf:bind id="b-protector-depth-test-date"
nodeset="protector-depth-test-date" type="date"/>
        <xf:bind id="b-size-width-mm" nodeset="size-width-mm" required="true()"
type="short"/>
        <xf:bind id="b-size-height-percent" nodeset="size-height-percent"
required="true()" type="short"/>
        <xf:bind id="b-size-diameter-inch" nodeset="size-diameter-inch"
required="true()" type="short"/>
        <xf:bind id="b-test-notes" nodeset="test-notes"/>
      </xf:bind>
      <xf:instance id="helper">
        <helper>
          <submitted/>
          <save/>
        </helper>
      </xf:instance>
      <xf:bind nodeset="instance('helper')">
        <xf:bind id="b-submitted" nodeset="submitted"/>
        <xf:bind id="b-save" nodeset="save" relevant="instance('data')/@readonly
!= 'true'"/>
      </xf:bind>

<!-- FUN BEGINS HERE -->
      <xf:instance id="alerts">
        <alerts>
          <on/>
          <id/>
          <brand/>
          <name/>
          <type/>
          <amount/>
          <usage-start-date/>
          <change-date/>
          <test-date/>
          <storage-address/>
          <supplier/>
          <document-date/>
          <document-number/>
          <purchase-date/>
          <price/>
          <protector-depth-mm/>
          <protector-depth-test-date/>
          <size-width-mm/>
          <size-height-percent/>
          <size-diameter-inch/>
          <test-notes/>
        </alerts>
      </xf:instance>

<!-- MORE FUN HERE -->
      <xf:bind nodeset="instance('alerts')">
        <xf:bind id="b-alerts" nodeset="on"
calculate="instance('helper')/submitted = 'true' or instance('data')/id !=
''"/>
        <xf:bind id="b-alert-id" nodeset="id" calculate="if(../on != 'true', '',
'Provide correct long number')"/>
        <xf:bind id="b-alert-brand" nodeset="brand" calculate="if(../on !=
'true', '', if(normalize-space(instance('data')/brand) = '', 'Required input,
provide value', 'Provide correct value'))"/>
        <xf:bind id="b-alert-name" nodeset="name" calculate="if(../on != 'true',
'', if(normalize-space(instance('data')/name) = '', 'Required input, provide
value', 'Provide correct value'))"/>
        <xf:bind id="b-alert-type" nodeset="type" calculate="if(../on != 'true',
'', if(normalize-space(instance('data')/type) = '', 'Required input, provide
value', 'Provide correct value'))"/>
        <xf:bind id="b-alert-amount" nodeset="amount" calculate="if(../on !=
'true', '', if(normalize-space(instance('data')/amount) = '', 'Required input,
provide value', 'Provide correct integer number'))"/>
        <xf:bind id="b-alert-usage-start-date" nodeset="usage-start-date"
calculate="if(../on != 'true', '', 'Provide correct date')"/>
        <xf:bind id="b-alert-change-date" nodeset="change-date"
calculate="if(../on != 'true', '', 'Provide correct date')"/>
        <xf:bind id="b-alert-test-date" nodeset="test-date" calculate="if(../on
!= 'true', '', 'Provide correct date')"/>
        <xf:bind id="b-alert-storage-address" nodeset="storage-address"
calculate="if(../on != 'true', '', 'Provide correct value')"/>
        <xf:bind id="b-alert-supplier" nodeset="supplier" calculate="if(../on !=
'true', '', 'Provide correct value')"/>
        <xf:bind id="b-alert-document-date" nodeset="document-date"
calculate="if(../on != 'true', '',
if(normalize-space(instance('data')/document-date) = '', 'Required input,
provide value', 'Provide correct date'))"/>
        <xf:bind id="b-alert-document-number" nodeset="document-number"
calculate="if(../on != 'true', '',
if(normalize-space(instance('data')/document-number) = '', 'Required input,
provide value', 'Provide correct value'))"/>
        <xf:bind id="b-alert-purchase-date" nodeset="purchase-date"
calculate="if(../on != 'true', '',
if(normalize-space(instance('data')/purchase-date) = '', 'Required input,
provide value', 'Provide correct date'))"/>
        <xf:bind id="b-alert-price" nodeset="price" calculate="if(../on !=
'true', '', if(normalize-space(instance('data')/price) = '', 'Required input,
provide value', 'Provide correct decimal number'))"/>
        <xf:bind id="b-alert-protector-depth-mm" nodeset="protector-depth-mm"
calculate="if(../on != 'true', '', 'Provide correct decimal number')"/>
        <xf:bind id="b-alert-protector-depth-test-date"
nodeset="protector-depth-test-date" calculate="if(../on != 'true', '', 'Provide
correct date')"/>
        <xf:bind id="b-alert-size-width-mm" nodeset="size-width-mm"
calculate="if(../on != 'true', '',
if(normalize-space(instance('data')/size-width-mm) = '', 'Required input,
provide value', 'Provide correct integer number'))"/>
        <xf:bind id="b-alert-size-height-percent" nodeset="size-height-percent"
calculate="if(../on != 'true', '',
if(normalize-space(instance('data')/size-height-percent) = '', 'Required input,
provide value', 'Provide correct integer number'))"/>
        <xf:bind id="b-alert-size-diameter-inch" nodeset="size-diameter-inch"
calculate="if(../on != 'true', '',
if(normalize-space(instance('data')/size-diameter-inch) = '', 'Required input,
provide value', 'Provide correct integer number'))"/>
        <xf:bind id="b-alert-test-notes" nodeset="test-notes"
calculate="if(../on != 'true', '', 'Provide correct value')"/>
      </xf:bind>
<!-- OH, WHAT A FUN IT WAS... -->

      <xf:submission id="submission-save" method="post" replace="none"
action="save?refresh=true"/>
    </xf:model>

    <xf:group>
      <xf:label>Tyre</xf:label>
      <xf:output id="id" bind="b-id" class="hidden"/>
      <xf:input id="brand" bind="b-brand">
        <xf:label>Brand:</xf:label>
        <xf:alert bind="b-alert-brand"/>
      </xf:input>
      <xf:input id="name" bind="b-name">
        <xf:label>Name:</xf:label>
        <xf:alert bind="b-alert-name"/>
      </xf:input>
      <xf:input id="type" bind="b-type" length="10">
        <xf:label>Type:</xf:label>
        <xf:alert bind="b-alert-type"/>
      </xf:input>
      <xf:input id="amount" bind="b-amount" length="2">
        <xf:label>Amount:</xf:label>
        <xf:alert bind="b-alert-amount"/>
      </xf:input>
      <xf:input id="usage-start-date" bind="b-usage-start-date">
        <xf:label>Usage start date:</xf:label>
        <xf:alert bind="b-alert-usage-start-date"/>
      </xf:input>
      <xf:input id="change-date" bind="b-change-date">
        <xf:label>Change date:</xf:label>
        <xf:alert bind="b-alert-change-date"/>
      </xf:input>
      <xf:input id="test-date" bind="b-test-date">
        <xf:label>Test date:</xf:label>
        <xf:alert bind="b-alert-test-date"/>
      </xf:input>
      <xf:input id="storage-address" bind="b-storage-address" length="250">
        <xf:label>Storage address:</xf:label>
        <xf:alert bind="b-alert-storage-address"/>
      </xf:input>
      <xf:input id="supplier" bind="b-supplier" length="50">
        <xf:label>Supplier:</xf:label>
        <xf:alert bind="b-alert-supplier"/>
      </xf:input>
      <xf:input id="document-date" bind="b-document-date">
        <xf:label>Document date:</xf:label>
        <xf:alert bind="b-alert-document-date"/>
      </xf:input>
      <xf:input id="document-number" bind="b-document-number" length="30">
        <xf:label>Document number:</xf:label>
        <xf:alert bind="b-alert-document-number"/>
      </xf:input>
      <xf:input id="purchase-date" bind="b-purchase-date">
        <xf:label>Purchase date:</xf:label>
        <xf:alert bind="b-alert-purchase-date"/>
      </xf:input>
      <xf:input id="price" bind="b-price" length="8">
        <xf:label>Price:</xf:label>
        <xf:alert bind="b-alert-price"/>
      </xf:input>
      <xf:input id="protector-depth-mm" bind="b-protector-depth-mm" length="5">
        <xf:label>Protector depth mm:</xf:label>
        <xf:alert bind="b-alert-protector-depth-mm"/>
      </xf:input>
      <xf:input id="protector-depth-test-date"
bind="b-protector-depth-test-date">
        <xf:label>Protector depth test date:</xf:label>
        <xf:alert bind="b-alert-protector-depth-test-date"/>
      </xf:input>
      <xf:input id="size-width-mm" bind="b-size-width-mm" length="3">
        <xf:label>Size width mm:</xf:label>
        <xf:alert bind="b-alert-size-width-mm"/>
      </xf:input>
      <xf:input id="size-height-percent" bind="b-size-height-percent"
length="3">
        <xf:label>Size height percent:</xf:label>
        <xf:alert bind="b-alert-size-height-percent"/>
      </xf:input>
      <xf:input id="size-diameter-inch" bind="b-size-diameter-inch" length="2">
        <xf:label>Size diameter inch:</xf:label>
        <xf:alert bind="b-alert-size-diameter-inch"/>
      </xf:input>
      <xf:input id="test-notes" bind="b-test-notes" length="250">
        <xf:label>Test notes:</xf:label>
        <xf:alert bind="b-alert-test-notes"/>
      </xf:input>
    </xf:group>
    <xf:group id="buttons" appearance="minimal">
      <xf:trigger id="save" bind="b-save">
        <xf:label>Save</xf:label>
        <xf:action>
          <xf:setvalue bind="b-submitted" value="'true'"/>
          <xf:send submission="submission-save"/>
        </xf:action>
      </xf:trigger>
    </xf:group>

Guntis
Received on Wednesday, 21 February 2007 02:02:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:22:09 GMT