For my application I want to have users with different permissions. One permission would allow a user to view the data from my database, while another permission would allow them to edit the data. On log in I would check their permission to determine wether they can edit the data. I am looking for some way to disable the entirety of my page if the user has the read-only permission. Is there a simple way to disable everything within the <h:form> tag? I would need to be able to disable multiple pages, hopefully by just looking at one boolean in by backingbean. Any help would be greatly appreciated.
-EDIT-
Is there any containers or like that I could wrap around my inputs that could be set to disabled? This way I would only need to reference the diable in one place and could also leave each field to set its own disable property if that is needed in other logic I have?
You can disable the buttons, links, input fields (everything that allows editing) etc… pointing them all to the same value in the backing bean.
I don’t know any way to disable everything contained in a form, but you may not want to do that because you may want the user to submit search queries (i.e. a search box) withing the form.
Update: answering to the comment of Alex Larzelere.
IMHO in this case is better to use
disabledrather thanrenderedbecause you may want to display the value of a field to the user in aninputTextbox, but not let him to modify it. If you don’t render it, he can’t see it. You could useoutputTextas well to display it but then you have to maintain two elements instead of one.Update answering to the edit in the question:
You can wrap your components inside a
h:panelGroupfor example and render it or not depending on your logic, but you can’t disable the input fields that are inside from theh:panelGroup, you have to do it individually.