commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: [jelly] Using BeanTagLibrary for "action" tags
Date Mon, 03 Mar 2003 18:05:31 GMT
 From: "Thomas Nichols" <>
> Hi James,
> At 22:54 25/02/2003 +0000, James Strachan wrote:
> >I've just patched the Bean tag library so that you can register a Method
> >method name) which can be passed into the BeanTagLibrary.registerBean()
> >method or used by the <beandef/> tag to specify a zero argument 'doit'
> >method. So this method could be run() for Runnable objects or execute()
> >Ant like tasks etc.
> >
> >James
> This is excellent - thanks very much, I can successfully trigger
> on a beantag with an "execute" method, the child beantags get processed
> first and addFoo methods ensure they get registered with their parent.
> I'm not sure I yet understand fully how BeanTagLibrary works.


> Within the
> root (level0) "j:jelly" tag I want to have a sequence of level1
> "action"  tags (e.g. "blah:sync") and beneath each of those a
> "data-assembly" hierarchy of beans. Astonishingly, this actually works:
> <j:jelly xmlns:j.... xmlns:bean... xmlns:blah... >
>    <bean:sync>
>      <bean:customer ...>
>        <bean:order>
>          <bean:product .../>
>        </bean:order>
>      ...
>      </bean:customer>
>      ...
>    </bean:sync>
> </j:jelly>
> However ... :-)
> The current impl assumes that a bean either has a name
> ("var"), or can be added to its parent (which needs an addFoo() method),
> that its parent is a collection. This is not true for my "bean"
> -- which isn't really a bean at all, I just need to register it in the
> MyOwnBeanTagLibrary ctor.

I've just patched the code so that this warning will no longer appear if a
BeanTag has either an 'execute' method or a variable name.

> Now, if I register Sync with
> registerBean ("sync", Sync.class, "execute");
> all is hunky dory - but I get a warning from BeanTag.processBean(), lines
> 174-176:
>                  else if(var == null) { //warn if the bean gets lost in
>                      log.warn( "Could not add bean to parent for bean: " +
> bean );
>                  }
> If I register the sync tag (bean:sync) with registerTag() instead of
> registerBean(), and give it a doTag(), then the data-assembly logic does
> not get invoked. The doTag() gets invoked fine, but the beans aren't
> So...
> 1. Can I have the "sync" tag registered with a vanilla TagSupport-derived
> class, but have the beans still processed? I'd like to keep a single
> if possible.
> 2. Is my use case general enough to warrant taking out that "Could not add
> bean to parent" warning, or at least making the trigger different?
> 3. If #2 == false, how can I programmatically assign a (meaningless) 'var'
> name to the sync tag, to suppress that message?
> Not particularly keen on ice cream, but I do like jelly.
> Onwards and upwards,


So #2 has been done. You can now create your own TagLibrary implementation
(derived from BeanTagLibrary) to register your tags or beans etc.


Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts

View raw message