jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kehoe <ke...@fortuity.com>
Subject best practices discussion: tag attribute versus pageContext
Date Fri, 15 Dec 2000 21:37:58 GMT
I'm working on a reporting application that uses a model-view-controller 
architecture. I'd like some "best practices" advice.

My Model sets text in a Results bean that becomes a Request attribute:
resultsBean.setText("some string");
request.setAttribute("results", resultsBean)

First question (more to follow):

In a tag handler class I can obtain the text from the Results bean through 
the pageContext property:
pageContext.getRequest().getAttribute("results").getText()
in which case the page can use the simple tag:
<mytags:displayText />

or I can expose the Results bean in the page and pass the text as an 
attribute of the tag:
<jsp:useBean id="results" class="Results" scope="request" />
<mytags:displayText text="<%= results.getText() %>" />

The first option makes the tag handler dependent on knowing that there is a 
results attribute in the request with a getText() method.

The second option adds clutter to the JSP.

What's best practice here? I'm tending to the latter because I get a more 
portable tag handler.

Daniel
kehoe@fortuity.com


Mime
View raw message