You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Hue Holleran <hu...@softwareskills.net> on 2002/11/06 19:01:34 UTC

[Tiles] Tiles vs. Custom Tag - anyone have a view?

We've been using tiles extensively in an app and it has been extremely
effective - as one might expect for including "tiles" of information on a
page and consolidating standard layout into templates - however I'm
concerned that we might be going too far in its use... and using it where we
might otherwise have used a custom tag:

For a single img that is used extensively in an app that has
mouseover/out/down behaviour, e.g. (in HTML - lots of code left out
deliberately here):

  <img src="/images/navigation/right.gif"
       onmouseover="javascript:setImg(this,'/images/right_hot.gif')"
       onmousedown="javascript:setImg(this,'/images/right_hot_down.gif')"
       onmouseout="javascript:setImg(this,'/images/right.gif')">

This can be much simplified to including a "tile" of just this control:

  <tiles:insert template="/tiles-components/controls/imgactive.jsp">
    <tiles:put imgName="/images/right" />
  </tiles:insert>

The alternative would be a custom tag, e.g:

  <sshtml:imgactive imgName="/images/navigation/right" />

Which is obviously much easier to include but so much less flexible -
requiring editing tag handler java code to edit html - and all of the issues
this entails - tiles allows us to edit the html in a nice easy jsp. This is
much more effective for complete chunks of html and has saved huge amounts
of time for large "composite controls" that we have everywhere.

I feel it is neater but am concerned we are introducing too much processing
for just producing the html for the control - does anyone else have a view
on this ... any comments appreciated (even "Stupid Idea" if this is).

(code for the template is included below).

Thanks,

Hue.

/tiles-components/controls/imgactive.jsp
----------------------------------------
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<img src="<tiles:getAsString name='imgName'/>.gif"
     onmouseover="javascript:setImg(this,'<tiles:getAsString
name='imgName'/>_hot.gif');"
     onmousedown="javascript:setImg(this,'<tiles:getAsString
name='imgName'/>_hot_down.gif')"
     onmouseout="javascript:setImg(this,'<tiles:getAsString
name='imgName'/>.gif')">


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: [Tiles] Tiles vs. Custom Tag - anyone have a view?

Posted by Andrew Hill <an...@gridnode.com>.
It is said (by Knuth originally I think) that "premature optimisation is the
root of all evil".
I would suggest to stick with tiles for now, and when you have the
application requirements nailed down good and tight and are in the
pre-delivery optimization phase, take a look at it again, and if you find
that you do need to squeeze out extra performance then use a custom tag, but
if the performance is ok leave it using tiles as it will make future
maintenaince easier...

-----Original Message-----
From: Hue Holleran [mailto:hueh@softwareskills.net]
Sent: Thursday, November 07, 2002 02:02
To: Struts Users Mailing List (E-mail)
Subject: [Tiles] Tiles vs. Custom Tag - anyone have a view?


We've been using tiles extensively in an app and it has been extremely
effective - as one might expect for including "tiles" of information on a
page and consolidating standard layout into templates - however I'm
concerned that we might be going too far in its use... and using it where we
might otherwise have used a custom tag:

For a single img that is used extensively in an app that has
mouseover/out/down behaviour, e.g. (in HTML - lots of code left out
deliberately here):

  <img src="/images/navigation/right.gif"
       onmouseover="javascript:setImg(this,'/images/right_hot.gif')"
       onmousedown="javascript:setImg(this,'/images/right_hot_down.gif')"
       onmouseout="javascript:setImg(this,'/images/right.gif')">

This can be much simplified to including a "tile" of just this control:

  <tiles:insert template="/tiles-components/controls/imgactive.jsp">
    <tiles:put imgName="/images/right" />
  </tiles:insert>

The alternative would be a custom tag, e.g:

  <sshtml:imgactive imgName="/images/navigation/right" />

Which is obviously much easier to include but so much less flexible -
requiring editing tag handler java code to edit html - and all of the issues
this entails - tiles allows us to edit the html in a nice easy jsp. This is
much more effective for complete chunks of html and has saved huge amounts
of time for large "composite controls" that we have everywhere.

I feel it is neater but am concerned we are introducing too much processing
for just producing the html for the control - does anyone else have a view
on this ... any comments appreciated (even "Stupid Idea" if this is).

(code for the template is included below).

Thanks,

Hue.

/tiles-components/controls/imgactive.jsp
----------------------------------------
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<img src="<tiles:getAsString name='imgName'/>.gif"
     onmouseover="javascript:setImg(this,'<tiles:getAsString
name='imgName'/>_hot.gif');"
     onmousedown="javascript:setImg(this,'<tiles:getAsString
name='imgName'/>_hot_down.gif')"
     onmouseout="javascript:setImg(this,'<tiles:getAsString
name='imgName'/>.gif')">


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>