cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <>
Subject [cforms] enabling all widgets to listen to value changed events
Date Wed, 14 Jul 2004 12:41:36 GMT
I have a form where for legal and natural persons different widgets have to be
presented. I implemented it using a union widget and storing the persontype on a
field with datatype ineger, the value is bound to a bean. To make this value
usable in the union's case widget it must be transformed into a string. So my
form definition looks like the following:

  <fd:field id="persontype" required="true">
    <fd:datatype base="integer"/>
    <fd:selection-list src="cocoon:/static/persontype.xml"/>
        var widget = event.source;
        var stringWidget = event.source.parent.getChild("persontypeString");
        if (widget.value == 0) {
            stringWidget.value = "naturalPerson";
        } else if (widget.value == 1) {
            stringWidget.value = "legalPerson";
  <fd:output id="persontypeString">
    <fd:datatype base="string"/>
  <fd:union id="person" case="persontypeString">
      <fd:struct id="naturalPerson">
      <fd:struct id="legalPerson">

Additionally I have a form where I only want to present the data, but not enable
the user to edit them. So I used output widgets. But: they are not
ValueChangedListenerEnabled, i.e. the above on-value-changed is not executed.

I wonder why we do not enable all widgets to listen to value changed events.
Though the user can not fire the event, it can happen programmatically like in
my use case above. Besides this one (which is more a work around of the union
widget's restriction) there are also other use cases imaginable, e.g. in a
simple game: one widget is "number of trial", another one is "trials left". The
second one is only updated if the first one has changed - of course the user
must not update them by hand, so they are output widgets.



View raw message