Tony Nelson wrote:
> Hi All,
>
> I'm relatively new to DisplayTag but I'm finding it pretty easy to 
> work with.  For one particular table, I need to display a column that 
> can actually be one of three different database columns, and it varies 
> per row.
>
> In an attempt to clarify this, assume that in addition to the rest of 
> the data I have colums A, B and C.
>
> For each row, I need to determine which value to display, A, B or C 
> (and format properly).  In order to determine which value is 
> appropriate I have to call business methods provided by my system.  
> These methods require as inputs, the business object (table row 
> object) and the user viewing the table as inputs.  The current user 
> can of course be retrieved from the Session.
>
> I'd like to do this in my TableDecorator, but I don't see any way to 
> get access to the HttpSession, or alternately pass the User object 
> into the decorator.

        this.getPageContext().getSession(); // should do the trick

>
> I don't think doing it in my (Stripes) ActionBean is the best place to 
> do it, as that doesn't seem to encourage reusability.  I also am not 
> actually sure how my action bean would get access to the current row 
> object.

Well you must be getting the data from somewhere to send it to 
DisplayTag so at some point you must have access to both the business 
objects and the user. As you titled your mail "Best Practice" I'd 
suggest that DisplayTag is a part of the View and should only be 
responsible for displaying the data and not for deciding which data to 
display. Also by putting the decision making process in the View you're 
calling it every time the view changes (sorting, paging) rather than 
just once when the data is retrieved.

Ed!

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to