You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2005/12/19 23:44:14 UTC

svn commit: r357823 - in /myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet: Stylesheet.java StylesheetTag.java

Author: matzew
Date: Mon Dec 19 14:44:09 2005
New Revision: 357823

URL: http://svn.apache.org/viewcvs?rev=357823&view=rev
Log:
minor fix in stylesheet component

Modified:
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/Stylesheet.java
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/StylesheetTag.java

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/Stylesheet.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/Stylesheet.java?rev=357823&r1=357822&r2=357823&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/Stylesheet.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/Stylesheet.java Mon Dec 19 14:44:09 2005
@@ -15,14 +15,13 @@
  */
 package org.apache.myfaces.custom.stylesheet;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.util._ComponentUtils;
-
 import javax.faces.component.UIOutput;
 import javax.faces.context.FacesContext;
 import javax.faces.el.ValueBinding;
 
+import org.apache.myfaces.component.UserRoleUtils;
+import org.apache.myfaces.util._ComponentUtils;
+
 
 /**
  * @author mwessendorf (latest modification by $Author$)
@@ -34,11 +33,13 @@
 	public static final String COMPONENT_TYPE = "org.apache.myfaces.Stylesheet";
 	public static final String COMPONENT_FAMILY = "javax.faces.Output";
 	private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Stylesheet";
-	private static final Log log = LogFactory.getLog(Stylesheet.class);
 
     private String _path = null;
     private Boolean _inline = null;
     private String _media = null;
+    private String _enabledOnUserRole = null;
+    private String _visibleOnUserRole = null;
+
 
 
     // ------------------------------------------------------------ Constructors
@@ -97,6 +98,37 @@
     	this._media = media;  
     }
     
+    public void setEnabledOnUserRole(String enabledOnUserRole)
+    {
+        _enabledOnUserRole = enabledOnUserRole;
+    }
+
+    public String getEnabledOnUserRole()
+    {
+        if (_enabledOnUserRole != null) return _enabledOnUserRole;
+        ValueBinding vb = getValueBinding("enabledOnUserRole");
+        return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+    }
+
+    public void setVisibleOnUserRole(String visibleOnUserRole)
+    {
+        _visibleOnUserRole = visibleOnUserRole;
+    }
+
+    public String getVisibleOnUserRole()
+    {
+        if (_visibleOnUserRole != null) return _visibleOnUserRole;
+        ValueBinding vb = getValueBinding("visibleOnUserRole");
+        return vb != null ? _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
+    }
+
+    public boolean isRendered()
+    {
+        if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
+        return super.isRendered();
+    }
+
+    
     public void restoreState(FacesContext context, Object state) {
 
         Object values[] = (Object[]) state;
@@ -104,16 +136,20 @@
         _path = (String) values[1];
         _inline = (Boolean) values[2];
         _media = (String) values[3];
+        _enabledOnUserRole = (String) values[4];
+        _visibleOnUserRole = (String) values[5];
 
     }
 
     public Object saveState(FacesContext context) {
 
-        Object values[] = new Object[4];
+        Object values[] = new Object[6];
         values[0] = super.saveState(context);
         values[1] = _path;
         values[2] = _inline;
         values[3] = _media;
+        values[4] = _enabledOnUserRole;
+        values[5] = _visibleOnUserRole;
         return values;
 
     }

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/StylesheetTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/StylesheetTag.java?rev=357823&r1=357822&r2=357823&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/StylesheetTag.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/stylesheet/StylesheetTag.java Mon Dec 19 14:44:09 2005
@@ -17,6 +17,7 @@
 
 import javax.faces.component.UIComponent;
 
+import org.apache.myfaces.component.UserRoleAware;
 import org.apache.myfaces.taglib.html.HtmlOutputTextTagBase;
 
 /**
@@ -67,6 +68,8 @@
         setStringProperty(component, "path", _path);
         setStringProperty(component, "media", _media);
         setBooleanProperty(component, "inline", Boolean.toString(_inline));
+        setStringProperty(component, UserRoleAware.ENABLED_ON_USER_ROLE_ATTR, _enabledOnUserRole);
+        setStringProperty(component, UserRoleAware.VISIBLE_ON_USER_ROLE_ATTR, _visibleOnUserRole);
 
     }