[richfaces-svn-commits] JBoss Rich Faces SVN: r11993 - in trunk/ui/columns/src/main: java/org/richfaces/taglib and 1 other directory.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Dec 23 09:26:05 EST 2008


Author: alevkovsky
Date: 2008-12-23 09:26:04 -0500 (Tue, 23 Dec 2008)
New Revision: 11993

Modified:
   trunk/ui/columns/src/main/config/component/columns.xml
   trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsHandler.java
   trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java
Log:
https://jira.jboss.org/jira/browse/RF-4292

Modified: trunk/ui/columns/src/main/config/component/columns.xml
===================================================================
--- trunk/ui/columns/src/main/config/component/columns.xml	2008-12-23 13:21:19 UTC (rev 11992)
+++ trunk/ui/columns/src/main/config/component/columns.xml	2008-12-23 14:26:04 UTC (rev 11993)
@@ -81,5 +81,13 @@
 				Binding attribute
 			</description>
 		</property>
+		<property>
+			<name>rendered</name>
+			<classname>boolean</classname>
+			<description>
+				Attribute defines if component should be rendered. Default value is &quot;true&quot;.
+			</description>
+			<defaultvalue>true</defaultvalue>
+		</property>
 	</component>
 </components>

Modified: trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsHandler.java
===================================================================
--- trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsHandler.java	2008-12-23 13:21:19 UTC (rev 11992)
+++ trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsHandler.java	2008-12-23 14:26:04 UTC (rev 11993)
@@ -95,6 +95,9 @@
 
     /** end attribute */
     private TagAttribute end;
+    
+    /** rendered attribute */
+    private boolean rendered = true;
 
     class IterationContext {
     
@@ -400,12 +403,32 @@
 	}
     }
     
-    /* (non-Javadoc)
-     * @see org.richfaces.taglib.ComponentHandler#apply(com.sun.facelets.FaceletContext, javax.faces.component.UIComponent)
-     */
+    private void initRendered(FaceletContext ctx) {
+		TagAttribute renderedAttribute = getAttribute("rendered");
+		if (renderedAttribute != null) {
+			try {
+				this.rendered = (Boolean) renderedAttribute.getObject(ctx);
+			} catch (ClassCastException e) {
+				this.rendered = true;
+			}
+		}
+	}
+    
+    /*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.richfaces.taglib.ComponentHandler#apply(com.sun.facelets.FaceletContext,
+	 *      javax.faces.component.UIComponent)
+	 */
     //@Override
     public void apply(FaceletContext ctx, UIComponent parent)
 	    throws IOException, FacesException, ELException {
+    
+    initRendered(ctx);
+    if(!rendered){
+    	return;
+    }
+    
     IterationContext iterationContext = new IterationContext();
     iterationContextLocal.set(iterationContext);
     	

Modified: trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java
===================================================================
--- trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java	2008-12-23 13:21:19 UTC (rev 11992)
+++ trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java	2008-12-23 14:26:04 UTC (rev 11993)
@@ -241,6 +241,14 @@
 	 * width Attribute defines width of column. Default value is "100px".
 	 */
 	private ValueExpression _width;
+	
+	/**
+	 * Attribute defines if component should be rendered.
+	 */
+	private ValueExpression _rendered;
+	
+	/** boolean value of rendered attr */
+	private boolean rendered = true;
 
 	/**
 	 * SortOrder is an enumeration of the possible sort orderings. Setter for
@@ -282,7 +290,10 @@
 	 */
 	@Override
 	public int doStartTag() throws JspException {
-
+		initRendered();
+		if(!rendered){
+			return SKIP_BODY;
+		}
 		prepare();
 
 		if (hasNext()) {
@@ -329,6 +340,9 @@
 	 */
 	@Override
 	public int doEndTag() throws JspException {
+		if(!rendered){
+			return EVAL_PAGE;
+		}
 		if (!atFirst()) {
 			return super.doEndTag();
 		}
@@ -672,7 +686,21 @@
 			// TODO: handle exception
 		}
 	}
+	
+	/**
+	 * Extracts boolean value from index rendered
+	 */
+	private void initRendered() {
+		if (_rendered != null) {
+			try {
+				rendered = (Boolean) _rendered.getValue(getELContext());
+			} catch (ClassCastException e) {
+				rendered = true;
+			}
 
+		}
+	}
+
 	/**
 	 * Return true if we didn't complete column's count
 	 * 
@@ -1109,4 +1137,14 @@
 	public void setSortExpression(ValueExpression __sortExpression) {
 		this._sortExpression = __sortExpression;
 	}
+	
+	/**
+	 * Attribute defines whether to render component or not
+	 * Setter for rendered
+	 * 
+	 * @param __rendered - new value
+	 */
+	public void setRendered(ValueExpression __rendered) {
+		this._rendered = __rendered;
+	}
 }




More information about the richfaces-svn-commits mailing list