How do I create Variable Fields in Struts View?

Discussions

Web tier: servlets, JSP, Web frameworks: How do I create Variable Fields in Struts View?

  1. How do I create Variable Fields in Struts View? (2 messages)

    I'm building an application that will have multiple security roles. I've accomplished the task with a single role with "Read Only" access. The question I have is if I designate a role to have "Read/Write" access, how do I convert the fields in JSP from <Bean:Write>'s to <input> so they can edit the fields?

    I currently have the Role's security Bean in the session and can pull it from the .JSP. I have "0" = "No Access", "1" = "Read" access, and "2" = "Write" access. I can currently use the <logic:equal> tag to determine that they do not have "0" to display the table row with the field in it. However, I would rather not use this method (<logic:equal> tags) to determine if they have read access then show this line, if they have write access, then show this line...

    I was hoping for a solution that would allow me to minimize duplication of effort so it's not a nightmare to add or remove fields or move them to another page in the application (which has 6 HTML pages of information).

    Can someone point me in the right direction? I'm sure I'm not the only one with this situation.

    Thanks,
    Chris
  2. If I understand correctly, you probably need a JSP tag to handle this. You could very easily extend the Struts tag and override the output based on a request attribute that stores whether the user can edit or read. Maybe set the readonly property for simplicity. Let me know if you need more information on how to accomplish this.
  3. Thanks!
    Chris