aspose file tools
The moose likes JSP and the fly likes JSF and role-based security Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "JSF and role-based security" Watch "JSF and role-based security" New topic
Author

JSF and role-based security

Yuri Sforza
Greenhorn

Joined: Apr 15, 2002
Posts: 15
Is it possible to make rendering of standard JSF html components role-dependent? Smth like disabling input for some fields in the form for some roles.
[ March 04, 2004: Message edited by: Yuri Sforza ]
Bill Dudney
Author
Ranch Hand

Joined: Sep 05, 2003
Posts: 234
That is a great question. I've not tried it myself but I expect you could do something like this
<h:commandButton ... id="1" rendered=#{securityBean.shouldRender["1"]} .../>
In the shouldRender method calculate the boolean value for each control and populate a map with these values. Then return the map. The EL stuff will evaluate it see true/false and the button will be rendered or not.
As I said I've not tried this and its a bit of a kludge since now the component knows its id as well as the security bean (info in two places is an invitation for bugs...). But I'm fairly sure this would work as a first approximation. I'll try to cook up an example and post it to my blog in the next couple of weeks.


TTFN,<br /> <br />-bd-<br /> <br /><a href="http://www.amazon.com/exec/obidos/ASIN/0471449156/qid=1064343733/sr=2-1/ref=sr_2_1/002-8375300-3666449" target="_blank" rel="nofollow">Jakarta Pitfalls</a> | <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0471146153/qid=1064343733/sr=1-2/ref=sr_1_2/002-8375300-3666449?v=glance&s=books" target="_blank" rel="nofollow">J2EE AntiPatterns</a> | <a href="http://www.amazon.com/exec/obidos/tg/detail/-/0471462071/qid=1064343733/sr=1-3/ref=sr_1_3/002-8375300-3666449?v=glance&s=books" target="_blank" rel="nofollow">Mastering JavaServer Faces</a> | <a href="http://bill.dudney.net/roller/page/bill" target="_blank" rel="nofollow">Blog</a> | <a href="http://www.jroller.com/page/BillDudney" target="_blank" rel="nofollow">Eclipse Blog</a> | <a href="http://www.sourcebeat.com/TitleAction.do?id=2" target="_blank" rel="nofollow">Eclipse 3 Live</a>
Yuri Sforza
Greenhorn

Joined: Apr 15, 2002
Posts: 15
Thanks. Seems to be enough direction to start experimenting.
Will also check your example when ready.
--
Y. Sforza
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JSF and role-based security
 
Similar Threads
Controlling Access to Form fields?
JSF security question
JAAS & JSF
Create a music player
Scrabble... it only takes a minute...