# HG changeset patch # User paulb # Date 1122056820 0 # Node ID a7ea3c1684c1e479a71631fe955b26a31d02b15c # Parent 7e7d9dbcec620fdd8d93dfb675f98d49140de747 [project @ 2005-07-22 18:26:56 by paulb] Added usage of the child-element and child-attribute functions for coherent references to potentially non-existent nodes in the form data. diff -r 7e7d9dbcec62 -r a7ea3c1684c1 docs/in-page-updates.html --- a/docs/in-page-updates.html Fri Jul 22 18:26:38 2005 +0000 +++ b/docs/in-page-updates.html Fri Jul 22 18:27:00 2005 +0000 @@ -61,8 +61,8 @@
  • Inside this new options element, investigate the values associated with the type element.
  • If any of the selected type values is "Personal", make a new comment -element, then add any attributes that may be found on existing - comment elements within the current type +element, then add any attributes that may be found on +existing comment elements within the current type element.
  • @@ -128,7 +128,7 @@ added or removed, we add an event attribute on the form field responsible for displaying the type values:

      <p>
    Item type:
    <select template:element="type" name="{template:list-attribute('type-enum', 'value')}" multiple="multiple"
    onchange="requestUpdate('{$application-url}comments', '{template:list-attribute('type-enum', 'value')}',
     '{template:other-elements(../options)}', '{template:other-attributes('value', ../options/comment)}',
    '/structure/item/options')"
    >
    <option template:element="type-enum" template:expr="@value-is-set" template:expr-attr="selected"
    template:value="@value" value="{@value}" />
    </select>
    </p>
    + style="font-weight: bold;">onchange="requestUpdate('{$application-url}comments', '{template:list-attribute('type-enum', 'value')}',
     '{template:other-elements(../options)}',
    '{template:child-attribute('value', template:child-element('comment', 1, template:other-elements(../options)))}',
    '/structure/item/options')">
    <option template:element="type-enum" template:expr="@value-is-set" template:expr-attr="selected"
    template:value="@value" value="{@value}" />
    </select>
    </p>

    This complicated string calls a special update request JavaScript function which triggers the in-page update, and it specifies the following things:

    @@ -151,10 +151,15 @@ exposed comment field does not disappear (for example, if we already have "Personal" selected but select "Important" in addition), and so we need to provide the details of the field which holds the value of the -comment text. We find such details by referencing the comment -element from the type element and stating that we want the - value attribute on that comment -element. +comment text. We find such details by referencing the options +element from the type element and stating that we want +the value attribute on any comment +element that may exist. Note that we cannot reference the comment +element directly since it may not exist at first, but then come into +being after an update, but not be referenced here in this parameter; +therefore, we need to make up the final part of the reference using the +special template:child-attribute +and template:child-element functions.
  • Finally, we need to provide some context to the application to tell it something about where in the complete form data structure the updated information resides. 
  • diff -r 7e7d9dbcec62 -r a7ea3c1684c1 examples/Common/VerySimple/Resources/structure_multivalue_template.xhtml --- a/examples/Common/VerySimple/Resources/structure_multivalue_template.xhtml Fri Jul 22 18:26:38 2005 +0000 +++ b/examples/Common/VerySimple/Resources/structure_multivalue_template.xhtml Fri Jul 22 18:27:00 2005 +0000 @@ -22,7 +22,8 @@ Item type: