You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by vi...@wipro.com on 2005/10/03 12:54:43 UTC

ValueChange events for the group field widget

Hi,

Can somebody point out how to set ValueChange events for a Field Widget
defined inside groups (fd:group)

I have defined <fd:value-on-changed>..listener inside definition file,
but that's not getting fired..

Thanks in advance,
 Vijay

flowscript: -
=============

cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/v2/Form.
js");

function showGroupFields() {
  var form = new Form("forms/group-test-def.xml");
  var wid = form.getWidget();
  wid.lookupWidget('description_c').setValue('visible');
  form.showForm("forms/group-test.html");
}


function descriptionValueChanged(id, src) {
  print("id: " + id + "src:"  + src);
}


Defintion file :-
=================

<?xml version="1.0" encoding="utf-8"?>

<fd:form xmlns=" <http://apache.org/cocoon/forms/1.0#definition>
http://apache.org/cocoon/forms/1.0#definition"
      xmlns:i18n=" <http://apache.org/cocoon/i18n/2.1>
http://apache.org/cocoon/i18n/2.1"
      xmlns:fd=" <http://apache.org/cocoon/forms/1.0#definition>
http://apache.org/cocoon/forms/1.0#definition">
     
  <fd:widgets>

    <fd:field id="description_c" required="true">
      <fd:datatype base="string" /> 
    </fd:field>
      
    <fd:union id="description_u" case="description_c">
      <fd:widgets>
        <fd:group id="visible">
          <fd:widgets>
            <fd:field id="description">
              <fd:datatype base="string" />
              <fd:label>
                <i18n:text>description </i18n:text>
              </fd:label>
              <fd:on-value-changed>
               <javascript>

descriptionValueChanged(event.source.id,event.source.parent);
               </javascript>
              </fd:on-value-changed>
            </fd:field>
          </fd:widgets> 
        </fd:group>
        <fd:group id="disabled">
          <fd:widgets></fd:widgets>
        </fd:group>
        <fd:group id="hidden">
          <fd:widgets></fd:widgets>
        </fd:group>
      </fd:widgets>
    </fd:union>
   </fd:widgets>
</fd:form>


Template file:-
===============

<?xml version="1.0" encoding="UTF-8"?>

<html xmlns:ft=" <http://apache.org/cocoon/forms/1.0#template>
http://apache.org/cocoon/forms/1.0#template"
      xmlns:fi=" <http://apache.org/cocoon/forms/1.0#instance>
http://apache.org/cocoon/forms/1.0#instance"
      xmlns:i18n=" <http://apache.org/cocoon/i18n/2.1>
http://apache.org/cocoon/i18n/2.1">

  <head><title>Group Test</title></head>
  <body>
    <ft:form-template action="#{$cocoon/continuation/id}.continue"
method="POST">
      <ft:union id="description_u">
        <ft:case id="visible">
          <ft:group id="visible">
            <ft:widget id="description">
              <fi:styling submit-on-change="true" />
            </ft:widget>
          </ft:group>
        </ft:case>
        <ft:case id="disabled">
          <ft:group id="disabled">
            <p>enter a description value first.</p>
          </ft:group>
        </ft:case>
        <ft:case id="hidden"> </ft:case>
      </ft:union>
    </ft:form-template>
  </body>
</html>






Confidentiality Notice

The information contained in this electronic message and any attachments to this message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged information. If
you are not the intended recipient, please notify the sender at Wipro or Mailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.