You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by 許議中 <jo...@erp.tw> on 2007/03/02 10:07:39 UTC

muti-layer binding

Hi!

I've a form with muti-layer tables,

main is content1
sub is content2
and there're many sub table in content2 like type01
here is some code.

this is ok in form show and it's action, but how to binding type01.

Best Regards

johnson

<fd:widgets>
	<fd:field id="pageno"  required="true">
    <fd:label><i18n:text>pageno</i18n:text></fd:label>
    <fd:hint><i18n:text>pageno</i18n:text></fd:hint>
		<fd:datatype base="integer"/>
	</fd:field>
	
	<fd:repeater id="repeaterList" orderable="true">
		<fd:widgets>
			<fd:output id="itemno">
  			<fd:label><i18n:text>itemno</i18n:text></fd:label>
  			<fd:hint><i18n:text>itemno</i18n:text></fd:hint>
	  		<fd:datatype base="integer"/>
		  </fd:output>

      <fd:field id="itemtype">
        <fd:datatype base="string"/>
        <fd:selection-list>
          <fd:item value=""/>
					<fd:item value =
"01"><fd:label><i18n:text>item01</i18n:text></fd:label></fd:item>					
        </fd:selection-list>
      </fd:field>

      <fd:union id="item" case="itemtype">
        <fd:widgets>

          <fd:group id="01">
            <fd:widgets>
              <fd:field id="url">
                <fd:label><i18n:text>url</i18n:text></fd:label>
                <fd:hint><i18n:text>url</i18n:text></fd:hint>
                <fd:datatype base="string"/>
              </fd:field>
          </fd:group>

        </fd:widgets>
      </fd:union>
											  <fd:repeater-action id="addItem" action-command="add-row"
repeater="repeaterList">
    <fd:label><i18n:text>addItem</i18n:text></fd:label>
      <fd:on-action>
        <fd:javascript>
          var form = event.source.form;
          var count = new
java.lang.Integer(form.getAttribute("counter").intValue() + 1);
          form.setAttribute("counter", count);
          var repeater = form.getChild("repeaterList");
          repeater.getRow(repeater.getSize() -
1).getChild("itemno").setValue(count);
        </fd:javascript>
      </fd:on-action>
    </fd:repeater-action>

  <fd:repeater-action id="removeItem" action-command="delete-rows"
repeater="repeaterList" select="select">
    <fd:label><i18n:text>removeItem</i18n:text></fd:label>
  </fd:repeater-action>
	
</fd:widgets>

Here is the binding

<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" path="/" >
	<fb:value id="pageno" path="pageno"/>
  <fb:repeater id="repeaterList"
               parent-path="."
               row-path="content2List">

    <fb:identity>
      <fb:value id="itemno" path="itemno"/>
    </fb:identity>

    <fb:on-bind>
	    <fb:value id="itemtype" path="itemtype"/>
      <fb:union id="item" path=".">
        <fb:case id="01" path=".">
          <fb:group id="01" path="01">
            <fb:value id="url" path="url"/>
            <fb:value id="illustration" path="illustration"/>
          </fb:group>
        </fb:case>
      </fb:union>
    </fb:on-bind>

    <fb:on-delete-row>
      <fb:delete-node/>
    </fb:on-delete-row>

    <fb:on-insert-row>
      <fb:insert-bean
        classname="tw.mobi.bean.Content2"
        addmethod="addContent2"/>
    </fb:on-insert-row>
  </fb:repeater>
  	
</fb:context>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org