Win a copy of Terraform in Action this week in the Cloud forum!

Daniel Almeida

Greenhorn
+ Follow
since Mar 16, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Almeida

Tim Holloway wrote:I don't generally find it necessary to get that complicated. Usually it's sufficient for me to add boolean render methods to the backing bean for the activity I want to constrain.



Hi, thanks.

We are in a research in college with the objective of to know whether is possible to have something intercepting the renderization of the pages and recognizing the elements those possibly will have some restriction.

We do this so we take the responsibility to choose what should or should not be protected for the right person: an administrator access and not the programmer. So we can leave the code of pages and the MB's cleaner, without references to resources and roles and thus accelerate the development.

Daniel Almeida
11 years ago
JSF
I resolve this with a custom ViewHandler:

[url=https://coderanch.com/t/487645/JSF/java/Authorization-over-UIComponents-with-JSF]
https://coderanch.com/t/487645/JSF/java/Authorization-over-UIComponents-with-JSF
[/url]

[]s

Daniel Almeida
11 years ago
JSF
I resolved this decorating the ViewHandler.

1. Extend the ViewHandlerWrapper abstract class;
2. Declare a private ViewHandler for the viewHandler that we decorates;
3. Create a constructor with a ViewHandler parameter;
4. Override the renderView method with the authorization logic;
5. Declare the decorating ViewHandler in faces-config.xml

ViewHandler


faces-config.xml
11 years ago
JSF

Victor Dolirio wrote:Daniel,

Thanks for regards. Could I call this method without an user action? i.e. When the user enter the url in browser, before it gets rendered?

[]s,
Victor Dolirio



Ok, you can implement a Phase Listener for intercept the life cycle render response phase, but I'm not sure this is the best option.



[]s

Daniel Almeida
11 years ago
JSF
Why get a new instance of the entire session bean? You can get new instances of the variables of your bean. Like this:



When you need to "restart the state" of your bean you only need to call the restart method.

Hope it's help,

[]

Daniel Almeida

11 years ago
JSF
Hi,

I'm want to access the components of a requested view and to alter the "rendered" attribute based on authorization rules.

Using a Phase Listener I got the components, but only after render response phase, where alterations don't make any effect because the outputStream has already been generated.

This "rendered" attribute need to be set before the render phase.

Is this possible?

Decorating the "HTML_BASIC" render kit? How?

Thanks,

Daniel Almeida
11 years ago
JSF

Benoît de Chateauvieux wrote:Hi Bauke,

In the Render Response phase, the afterPhase method will be executed after the page has been displayed.
That's why your change doesn't work.

I resolved this problem implementing a custom renderkit that decorates the renderkit of my JSF implementation.

Hope it helps !

Benoît



Hi, can you enter in more details about "decorating the renderkit"? I'm trying to alter components attributes before the renderization.

I have this in my faces-config.xml:


... And this is my custom render kit class:


Is everthing right? What i'm missing?

Sorry for english mistakes,

Thanks
11 years ago
JSF