cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <va...@reverycodes.com>
Subject Re: Simple form event?
Date Thu, 27 Mar 2008 14:16:28 GMT
On Mar 27, 2008, at 3:43 AM, Derek Hohls wrote:
> Working with Cocoon 2.1.8
>
> I am trying to create a simple event that copies the value entered  
> in one
> field, into another.
>
> The form definition looks like:
>
> <fd:field id="SiteCode" required="true">
>  <fd:label>Site Code</fd:label>
>  <fd:datatype base="string"/>
>  <fd:on-value-changed>
>    <javascript>

Should be <fd:javascript>.


>      java.lang.System.err.println("Site Code changed from " +  
> event.oldValue + " to " + event.newValue);
>      var value = event.source.value;
>      var typewidget = event.source.lookupWidget("../SampleCode");
>      typewidget.setValue(value);
>    </javascript>
>  </fd:on-value-changed>
> </fd:field>
>
> <fd:field id="SampleCode" >
>  <fd:label>Sample Code</fd:label>
>  <fd:datatype base="string"/>
> </fd:field>
>
> ie. the intent is that when SiteCode is changed, this value
> becomes the default for the SampleCode.
>
> The above does not work.
>
> I am not sure where/how the system adds in this Javascript;
> the source code for the output web page does not look any
> different from before, so I am sure I am missing something
> obvious.

There should be onchange="" javascript event attached to the  
"SiteCode" field in the generated html. Like in these samples:

   http://cocoon.zones.apache.org/demos/21branch/samples/blocks/forms/countryselector
   http://cocoon.zones.apache.org/demos/21branch/samples/blocks/forms/carselector

It is added by the forms-field-styling.xsl stylesheet when widget has  
'listening' attribute, which is set if there are any listeners attached.

Vadim


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


Mime
View raw message