I ran into this problem a few days ago. I solved it by extending
UIComponentBase and UIComponentTag to create a hasRole tag.

<blah:hasRole role="ADMIN">
        <h:outputText="#{bundle.TopSecretAdminMessage}"/>
</blah:hasRole>

Here's the meat of the UIComponent....

    public void encodeBegin(FacesContext context) throws IOException {
        String role = (String)getAttributes().get("role");
        
                if (JAASUtils.hasRole(role)) {
                        this.setRendered(true);
                } else {
                        this.setRendered(false);
                }
        }

I'm new to JSF, so I don't know if this is the best/correct approach but it
does work. If anyone has a better solution, I'd be happy to hear about it.

--
Tom Cort
Systems Developer
Vermont Department of Taxes

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to