[Hippo-cms7-user] Dropdowns listenening to each other's changes

Frank van Lankvelt f.vanlankvelt at onehippo.com
Sat May 29 08:50:53 CEST 2010

Hi Dennis,

interesting question; I'm assuming that you do not want to simply
merge the dropdowns in a single plugin, but that you want to create
some more generic framework where different dropdown plugins talk to
each other?

The observer pattern makes sense here, because you're actually
changing data in the repository and want plugins to respond to that.
But, from a plugin you should not directly use a JCR listener.
Instead, use the observation framework that is in the CMS.  That takes
care of cleaning up the listeners when the plugin is stopped,
re-registers a listener when the JCR session is renewed and
multiplexes multiple observers for the same data onto one JCR
listener.  Furthermore, you will receive in-session events, i.e.
before the session (or node) is saved.  Since there is the additional
indirection, other improvements are also imaginable; those can then be
made in the plugin framework itself without impacting backwards

A template plugin will get a model from the template engine.  This
model is, if provided by the template engine, will be IObservable.
This means that you can register an IObserver and thereby receive
events.  The plugin should subscribe to a number of (equivalent)
models and react appropriately.  A non-UI plugin can create the models
from the containing document or compound.  In the containing template
one then needs to link the models created by the second plugin to the
parameters for the dropdown template.

I hope that this makes sense to you.  The main challenge here, as I
see it, is to keep the complexity the plugin configuration to a
minimum.  Remember that, since templates are composed of a set of
plugins, one can always replace the complete set by one dedicated
plugin.  Then all complexity can be handled in java, sacrificing
flexibility and reusability for control and testability.

cheers, Frank

PS: You'll probably deal with JcrPropertyValueModel instances; those
are not yet IObservable.  Observing their JcrPropertyModel should be
good enough.  (so you'll need to do some casting and create some JIRA

On Fri, May 28, 2010 at 10:54 AM, Dennis Dam <d.dam at onehippo.com> wrote:
> Hi,
> I have the following feature request. We currently have 3 dropdowns in one
> document type, which happen to use the same list as input. Most of the time,
> the selected values of the dropdowns are the same. Right now, the user needs
> to select a value for each separate dropdown. This is repetitive work which
> we want to avoid as much as possible. That's we want to implement the
> following feature: if a user selects a value for one dropdown field, AND the
> other 2 dropdowns are still empty, then fill in the selected value for the
> other dropdowns automatically. In this way, the CMS user only needs to
> select the value once.
> So we need some kind of interaction between different field plugins in the
> same document. To solve this problem, I was thinking about implementing a
> custom dropdown class which listens to changes to other fields, using the
> JCR listener API. Am I on the right track, or is there another easier /
> recommended way to this? Can you give a short description of how to
> implement this?
> regards
> Dennis
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html

More information about the Hippo-cms7-user mailing list