It's my personal opinion that presentation pages should be as dumb as possible. It should not have to "think" about the data, just render it as it has been given.
Conversely, the business layer should be as smart as possible, and provide whatever alternatives the rest of the application needs to do it job. If the dataset needs to be ordered in a certain way, then it is up to the business layer to provide that ordering. It wouldn't know how to write a HTML table, but it should now how to get the dataset ordered in the way the HTML table wants it. Ordering data is business logic, shoving in the <td>'s is the presentation's job. The critical question, I think, is to ask -- "OK, what if we wanted to do this with something other that a JSP. Say a printed report or another templating system, like Velocity? Do we have everything we need on the business tier to make this work?" If business logic, like the alternative ways data is ordered, is expressed in the tag extensions, then it is not available to another presentation system. Like say, a report rendered as a PDF. So, IMHO, ordering is not something the Action does, or something a tag extension does, is something the business layer does. The Action may select which ordering has been requested by the client, but when the data comes back, it just passes it along. Ordering data is business logic, and custom code that does that should not be in any framework component, including the tag extensions. It may be that you need another set of beans between the EJBs and the rest of your application. Many times EJBs end up representing the resource layer, and only partially represent the business layer. So the solution here may be a JavaBean wrapper that did the sorting, so all the presentation page need do is call an iterator. Which ordering to use would be a property on this (business layer) JavaBean, that the Action might set to the way to the page. And submitting a request for a different order would probably go back to the same Action (since it already knows how to select an order). If the data is being cached in the session, then it would be the Action's job to get it back, and maybe call a method to change to the default sort order. But the ordering would take place on the business layer, the Action would just known enough to call the right method. If the data need be presented to another device, like a PDF renderer, the same JavaBean could be passed to that component. This provides resuse not only between JavaServer Pages, but between all presentation components. In the end, pretty much the same code is going to get written either way. The question is whether it can get more reuse in a tag extension or in the JavaBean that the tag exposes. HTH, Ted. -- Ted Husted, Husted dot Com, Fairport NY USA. -- Custom Software ~ Technical Services. -- Tel +1 716 737-3463 -- http://www.husted.com/struts/ Abhishek Srivastava wrote: > > Hello All, > > I render a table through my jsp page. The user can sort the table by > clicking on each of the column headers. When the user clicks on the column > header, an Action is invoked and the data that is used to render the table > is sorted accordingly and placed back into the session. Now the control is > forwarded to the jsp that renders the table with sorted data/ > > I have got some feedback that using Action for things like sorting a table > is an overkill. what is suggested that each table column should point to a > jsp which should use a custom tag library to sort the table. > > I am unable to decide which approach to take and why. > > Can someone help me on this. > > regards, > Abhishek. > > A ship in harbor is safe, but that is not what ships are built for. > John A. Shedd > > ***** ***** Abhishek Srivastava > *** /_ __ *** Hewlett-Packard - Solutions Organization > ** / / /_/ ** 19 Cunningham Road. Bangalore -560052. > *** / *** phone +91 80 2251554 Extn:1532 > ***** ***** mailto:[EMAIL PROTECTED] > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>