File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes jsf and jstl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "jsf and jstl" Watch "jsf and jstl" New topic
Author

jsf and jstl

Predrag Ristic
Greenhorn

Joined: Dec 07, 2009
Posts: 28
I have a simple seam project created in Eclipse.All my web pages have extension xhtml and I access each of them by typing page_name.seam.I would like to restrict access to every other page other than login page if the user is not logged in.I tried to use <c:if> tag but it didn't work.Other c: tags won't work either.Can anyone tell me how to implement this login check?Thanks
Cristian Boariu
Greenhorn

Joined: Jul 04, 2009
Posts: 9
Hi Ristic,
You must make a pages.xml where you will have like:




check this out for more info:

http://docs.jboss.com/seam/1.1.5.GA/reference/en/html/security.html

Also note that you can add that role after login, like:
identity.addRole("ACCES_ALL_PAGES_ROLE");

Have fun.


Software Developer - Java
Predrag Ristic
Greenhorn

Joined: Dec 07, 2009
Posts: 28
I've added identity attribute in my LoginBean class and in method that is invoked when user clicks on the submit button there is line
identity.addRole("logged").This method is registered in components.xml.Your tip about restriction is used in pages.xml but but I always get rejected no matter what username I use.
Cristian Boariu
Greenhorn

Joined: Jul 04, 2009
Posts: 9
Hi,
Can youu paste some code?
Predrag Ristic
Greenhorn

Joined: Dec 07, 2009
Posts: 28
components.xml :


login.xhml:


pages.xml:

Cristian Boariu
Greenhorn

Joined: Jul 04, 2009
Posts: 9
After you have injected the identity component, have you checked with debug that after the login click, it has the new role?
Predrag Ristic
Greenhorn

Joined: Dec 07, 2009
Posts: 28
I could not find any property of identity in the Variables tab in the debug mode that could show if the role is set or not.This is the managed bean.I hope it can help you so you can help me
Cristian Boariu
Greenhorn

Joined: Jul 04, 2009
Posts: 9
Please notice that in jsf you have: register_bean and in the @Name of the seam component there is a missing "_"
Predrag Ristic
Greenhorn

Joined: Dec 07, 2009
Posts: 28
I think that I have written register_bean everywhere.Can you show more precisely what do you mean?
Cristian Boariu
Greenhorn

Joined: Jul 04, 2009
Posts: 9
my fault...i did not noticed it because of the the background.......however i recommend to use cammel case like registerBean...of course this is not the problem here but it's good for better practices
Cristian Boariu
Greenhorn

Joined: Jul 04, 2009
Posts: 9
Also try to use the instance of Identity..I think that is: Identity.instance().addRole
Predrag Ristic
Greenhorn

Joined: Dec 07, 2009
Posts: 28
I really don't understand why it doesn't work when I add the role with
this.identity.addRole("logged");
I thought that is all what is necessary
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsf and jstl