|
List Info
Thread: Enable/Disable Editing of Form Fields based on User Roles
|
|
| Enable/Disable Editing of Form Fields
based on User Roles |

|
2007-01-31 14:21:56 |
|
I know JSF/MyFaces has disable attribute but wondering how do i enable/disable based on user roles . My other question is how do i pass userId from JSF page to Backing Bean. Here is the situation The JSF page has userId available from Single Sign On application. Now i wanna pass this userId to the Backing Bean so that i can retrieve user roles from the database based on userId. Back to JSF form based on user roles i would like to enable/disable editing of certain form fields Any pointers/suggestion on how to do this will be highly appreciated. I am using MyFaces 1.1.4, Tomahawk 1.1.3, Sanbox, Facelets 1.1.12, Ajax4JSF 1.04, Spring, Hibernate Regards Bansi ;
We won't tell. Get more on shows you hate to love (and love to hate): Yahoo! TV's Guilty Pleasures list. |
| RE: Enable/Disable Editing of Form
Fields based on User Roles |

|
2007-01-31 19:37:05 |
|
There are many ways to attack this
problem, and I’m sure someone will have a more elegant solution,
but here’;s what I do.
I assume your userId is available as a
request parameter or attribute. If so you an initialize role
properties in the backing bean constructor, by that I mean look them up
based on the user id and cache them in member variables, or a map. On
your backing bean provide access to these roles with property getters, for
example
public boolean isSomethingAllowed();
public Boolean isAnotherThingAllowed();
etc
In the jsf bean selectively enable/disable
components based on these properties using expression language, for
example <h:outputText disabled=”#{!bean.somethingAllowed}8221;/>.
Alternatively your bean can return the users
role itself as a string and the logic for what’;s allowed put in the jsf
public String
getRole(); à <h:outputText disabled=”#{!bean.role ==
‘;superUser’}R21;/>
Hope that is helpful.
Jim
From: Bansilal
Haudakari [mailto:mail2bansi yahoo.com]
Sent: Wednesday, January 31, 2007
3:22 PM
To: users facelets.dev.java.net
Subject: Enable/Disable Editing of
Form Fields based on User Roles
I know JSF/MyFaces has disable attribute but wondering how do i
enable/disable based on user roles .
My other question is how do i pass userId from JSF page to Backing Bean.
Here is the situation
The JSF page has userId available from Single Sign On application. Now i wanna
pass this userId to the Backing Bean so that i can retrieve user roles from the
database based on userId.
Back to JSF form based on user roles i would like to enable/disable editing of
certain form fields
Any pointers/suggestion on how to do this will be highly appreciated.
I am using MyFaces 1.1.4, Tomahawk 1.1.3, Sanbox, Facelets 1.1.12, Ajax4JSF
1.04, Spring, Hibernate
Regards
Bansi
We won't tell. Get more on shows
you hate to love
(and love to hate): Yahoo!
TV's Guilty Pleasures list.
|
[1-2]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|