A long time ago, we had the exact same issue with the Struts
<html:form> tag, since the form element tags wanted to talk to the
form tag itself. The problem also manifests itself when using
<jsp:include>, as well as Tiles. The solution we chose was similar to
what you suggested, except that we didn't bother with the
findAncestorWithClass() step.

I would recommend that you do the same. Just have your 'document' tag
store itself in request scope. There's no advantage to looking for the
class directly using findAncestorWithClass(), and there is some
performance hit for doing so.

--
Martin Cooper


On Thu, 06 Jan 2005 19:20:06 +0100, luca <[EMAIL PROTECTED]> wrote:
> 
> Hallo everyone, I maintain and develop a tag-library
> (WALL: http://wurfl.sourceforge.net/java/tutorial.php).
> 
> Lately someone asked me if there is any way WALL can be used
> with tiles. My problem is that in order to do its magic
> WALL tags need to talk to one another. In particular, many
> tags communicate with the containing top-level wall:document tag.
> 
> When a tag in a tile does a findAncestorWithClass(this, WallDocument.class)
> to find the document tag, this obvously fails, because the tag is not there.
> I think I have a workaround to this, but since tiles are not my
> speciality and performance traps are always there,
> I am about to ask this honorable forum for advice.
> 
> My workaround would be to have the document tag perform:
> 
> pageContext.setAttribute("wall-doc-ref-key", this,PageContext.REQUEST_SCOPE)
> 
> all the tags which need to refer to 'wall:document', could get a reference
> to the tag through:
> 
>      WallDocument document = (WallDocument) findAncestorWithClass(this, 
> WallDocument.class);
>      if (document == null) {
>          document = 
> (WallDocument)pageContext.getAttribute("wall-doc-ref-key",PageContext.REQUEST_SCOPE));
>          if (document == null) {
>              throw new JspTagException("tag 'menu' must be nested inside a 
> 'document' tag");
>          }
>      }
> 
> Questions:
> 
> - Will this work, as far as you can tell?
> 
> - is there a performance hit in doing this?
> 
> - can someone think of other solutions?
> 
> Thank you
> 
> Luca
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

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

Reply via email to