On Wed, Jun 11, 2003 at 10:48:24PM -0400, Ken Yee wrote:
> 
> Mike Cannon-Brookes wrote: 
> > Well, I use JSP conditional tags in my SiteMesh decorators
> > to do this personally? :)
> 
> I didn't see any special WW:ui tag that would make it obvious to
> use WW either :-P
> 
> Could you post an example of what you do w/ JSP conditional tags?
> Maybe it would be a good addition to WW's UI tags to encapsulate
> something like this...
> 
> 

Not really related to WW in any way, but the way I do it is by setting a
request attribute from the "body" JSP, and then use that attribute from
the "menu" JSP:

decorator.jsp:

<table>
  <tr>
    <td><%@ include file="../includes/menu.jsp"%></td>
    <td><decorator:body/></td>
  </tr>
</table>

some-page.jsp
  <%
    request.setAttribute("current_view_name", "some-page");
  %>
  <html>
    <yadda yadda />
  </html>

some-other-page.jsp
  <%
    request.setAttribute("current_view_name", "some-other-page");
  %>
  <html>
    <yadda again />
  </html>

menu.jsp
  <%!
    String buildLink(HttpServletRequest req, String name, String url, 
    String viewName)
    {
      boolean isCurrentPage =
      viewName.equals((String)req.getAttribute("current_view_name"));
      StringBuffer buff = new StringBuffer();
      if( !isCurrentPage ){
        buff.append("<a href=\"").append(url).append("\">");
      }
      buff.append(name);
      if( !isCurrentPage ){
        buff.append("</a>");
      }

      return buff.toString();
    }
  %>
  
  <ul>
    <li>
    <%=buildLink(request, "SomePage", "some.action", "some-page"%>
    </li>

    <li>
    <%=buildLink(request, "SomeOtherPage", "someother.action",
    "some-other-page)%>    
    </li>
  </ul>


The "strategy" can very likely be better encapsulated in custom taglibs
or ww-actions, but IMO it's not something that WW should provide.

//Anders

-- 
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. Anders Engström         [EMAIL PROTECTED]
. http://www.gnejs.net    PGP-Key: ED010E7F
. [Your mind is like an umbrella. It doesn't work unless you open it.]  

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to