I don't know how much thought has yet gone into how Struts and JSTL can work
together.  I haven't noticed much serious talk about this.  If these thoughts
are obvious or ignorant, I apologize.

It occurred to me that a straightforward interim solution would be to provide
tag libraries named "bean-el", "html-el", etcetera.  The actual tag classes
would just be subclasses of the Struts tags.  The way that the actual JSTL tag
classes are implemented makes this very easy to do.

In fact, I spent about an hour this afternoon implementing and verifying a
proof of concept (mostly spent updating my environment), adding a
"bean:el-message" tag to my local CVS of Struts.  For a P.O.C., it was easier
to add the tag to the existing tag library, but for a real implementation, I
would want a separate tag library.  The code for the tag is very
straightforward.  My test derived from "MessageTag", but it could just as
easily (I believe) derive from "NestedMessageTag".

Does anyone see value to this, or have any other relevant comments?

The tag class just looks like this:

--------------------------
public class ELMessageTag extends MessageTag
{
   public   ELMessageTag()
   {
      super();
      init();
   }

   private  void  init()
   {
      setArg0(null);
      setArg1(null);
      ...; // Others
   }

   public   void  release()
   {
      super.release();
      init();
   }

   public   int   doStartTag()
      throws JspException
   {
      evaluateExpressions();
      return (super.doStartTag());
   }

   private  void  evaluateExpressions()
      throws JspException
   {
      try
      {
         setArg0((String) ExpressionUtil.
                 evalNotNull("el-message", "arg0", getArg0(),
                             String.class, this, pageContext));
      }
      catch (NullAttributeException ex)
      { setArg0(null); }

      try
      {
         setArg1((String) ExpressionUtil.
                 evalNotNull("el-message", "arg1",getArg1(),
                             String.class, this, pageContext));
      }
      catch (NullAttributeException ex)
      { setArg1(null); }

      ...; // Others
   }
}
--------------------------

An example usage would be:

--------------------------
<bean:el-message key="main.totalAlbums.label" arg0="${mainForm.totalAlbumCount}"/>
--------------------------

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to