• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts and role based content

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Anu Korah
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for this lead Jim. The displaytag does meet most of my needs and I have been trying to reinvent the wheel.

-Anu
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic