-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
In my application user will log in, and then, depending on its rights, he should be able to see or not some part of GUI. For example for normal user change password button should not exists, when for admin user it should be on page. I thing will be great if I could do this in this way:
<button if="${loggedUser.rights.changePassword}"/>
So I will have User class that will contain rights class, and this class contains changePassword variable that contains bool information has this user rights to change password or not.
When this value (loggedUser.rights.changePassword) changes from false to true, button should be automatically added to page, because now "if" parameter equals to true. How to do this?
Thanks, but this not solves my problem.
When I use "visible" attribute, page on browser side contains element. I prefer situation when such components are not on browser side at all if there is "if" element set to false. This is safer.
So it looks "if" attribute is executed only on page loading? Maybe then better is to create 2 pages? First with login form, second with main application?
The "if" attribute is absolutely only used in the rendering phase. That is its purpose. I'm not sure what safety you're referring to...
But, if you are using a GFC controller, hook the doBeforeCompose(...) method and set some variable that can be accessed by the "if". You can also use the "unless" in partnership with the "if" if you have 2 different UI elements to display (e.g. a label and list).
Sorry, for my English. I will try to describe it as simple as I can. Maybe better I will write what I want to achieve.
I'm going to create such web application:
1. Application starts and shows login form.
2. User writes its name and password and clicks "Login" button.
3. "Login form" drops out of sight.
4. "Main application form" shows.
5. If logged user is John, he will be able to change his own name using textbox on "Main application form".
6. If logged user is Jack, he will not be able to change his own name. He doesn't have textbox on page and when he opens HTML page source code, he doesn't have this textbox there. This means, Jack doesn't know, that if he was John, he would had this option.
So now, should I make "Login" and "Main application" different web pages or is there any way to dynamically add "Main application form" after login to the same page?
"So now, should I make "Login" and "Main application" different web pages "
That's the way I organize my projects. The main app can be created with Executions.createComponents(...). If you've set a value in some scope after the login to tell whether to put out a textbox or a label(or maybe nothing), this should work.
Asked: 2011-09-07 11:54:11 +0800
Seen: 247 times
Last updated: Sep 09 '11