I need to display a view page in a tabular layout where the columns in the table differ from role to role. For instance, for a regular user i need to display the columns - id(this is a hyperlink), description, creation date, View & Create(hyperlinks)
and for a supervisor i need to display - Regular user name, id, creation date, description, comments, View (hyperlink)
The additional columns for a supervisor are user name and comments and the position of description and creation date columns are interchanged. Also, the supervisor has the option to only view the information created by the regular user whereas the regular user has the option to create as well as view information.
What would be a suitable design for generating role-based content. My constraints are: 1) I cannot create different JSPs - one for the supervisor and another for the regular user - since the number of roles may increase and i have many other views I need to create and I cannot afford to have multiple copies of each type of view. 2) I also need to avoid using conditional logic in my JSP such as <logic:equal name="role" value="supervisor"> then display or hide</logic:equal>
I have this half-baked solution but it seems to me that i might be making the problem more difficult than it really is. So this is what I have in mind: 1) Depending on the role and the URL request, the middle tier will return a map/collection of columns header that must be displayed. 2) It will also return a collection of Column objects Column name, column value, column type (is it a text, hyperlink,image,button),column width,column style (bold, italicised, etc) 3)the action class will use this information to construct the html content, set it as a request attribute and forward to the jsp. (Is it wise to embed html logic in the action class?)
Your inputs and solutions to this problem would be of great help.
As far as the rendering portion of your proposed solution goes, it sounds very similar to how "Predefined Column Lists" work in the DisplayTag tag library. DisplayTag Using predefined column lists This would seems to validate your proposal. I just looked and I did not offhand see support similar to what you are looking for in Apache DataGrid Taglib. -Jim
Joined: Jun 28, 2006
Thanks for this lead Jim. The displaytag does meet most of my needs and I have been trying to reinvent the wheel.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com