May 01
You can’t. But you can use <h:outputText> for read-only visitors and <rich:inplaceInput> for write-enabled logged-in users. Customize the inplaceInputTest.xhtml s:hasRole() parameter to give the proper boolean value on whether the logged-in user is an administrator or not of the field you want to control access of.
/resources/WEB-INF/web.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?xml version="1.0"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> . . . <context-param> <param-name>facelets.LIBRARIES</param-name> <param-value>/WEB-INF/compositions.taglib.xml</param-value> </context-param> </web-app> |
/resources/WEB-INF/compositions.taglib.xml
1 2 3 4 5 6 7 8 9 | <?xml version="1.0"?> <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "facelet-taglib_1_0.dtd"> <facelet-taglib> <namespace>http://mytaglib.com/jsf</namespace> <tag> <tag-name>inplaceInput</tag-name> <source>../compositions/inplaceInput.xhtml</source> </tag> </facelet-taglib> |
/view/compositions/inplaceInput.xhtml
1 2 3 4 5 6 7 8 9 | <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich"> <rich:inplaceInput value="#{value}" showControls="true" editEvent="ondblclick" layout="block" rendered="#{isManager}" /> <h:outputText value="#{value}" rendered="#{not isManager}" /> </ui:composition> |
/view/inplaceInputTest.xhtml
1 2 3 4 5 6 7 8 9 10 11 12 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:mytaglib="http://mytaglib.com/jsf"> <mytaglib:inplaceInput value="Example text" isManager="#{s:hasRole('module_manager')}" /> </ui:composition> |
