myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmarinsc...@apache.org
Subject svn commit: r375266 - in /myfaces/tomahawk/trunk/core/src/main: java/org/apache/myfaces/component/html/ext/ java/org/apache/myfaces/renderkit/html/ext/ java/org/apache/myfaces/taglib/html/ext/ tld/entities/
Date Mon, 06 Feb 2006 12:41:56 GMT
Author: mmarinschek
Date: Mon Feb  6 04:41:55 2006
New Revision: 375266

URL: http://svn.apache.org/viewcvs?rev=375266&view=rev
Log:
Patch by Claudio Tasso for MYFACES-1064. Thanks!

Modified:
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
    myfaces/tomahawk/trunk/core/src/main/tld/entities/extended_data_table_attributes.xml

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java?rev=375266&r1=375265&r2=375266&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlDataTable.java
Mon Feb  6 04:41:55 2006
@@ -19,12 +19,16 @@
 import java.sql.ResultSet;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.faces.component.NamingContainer;
+import javax.faces.component.UIColumn;
 import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
 import javax.faces.context.FacesContext;
 import javax.faces.el.ValueBinding;
 import javax.faces.model.DataModel;
@@ -45,6 +49,7 @@
  */
 public class HtmlDataTable extends HtmlDataTableHack implements UserRoleAware
 {
+  
     private static final Log log = LogFactory.getLog(HtmlDataTable.class);
 
     private static final int PROCESS_DECODES = 1;
@@ -71,8 +76,13 @@
     private String _rowOnKeyUp = null;
     private String _rowStyleClass = null;
     private String _rowStyle = null;
+    private String _varDetailToggler = null;
 
     private boolean _isValidChildren = true;
+
+    private Set _expandedNodes = new HashSet();
+
+	private UIColumn detailColumn;
     
     public String getClientId(FacesContext context)
     {
@@ -207,6 +217,11 @@
         {
             // no extended var attributes defined, no special treatment
             super.setRowIndex(rowIndex);
+        }        
+		if (_varDetailToggler != null)
+        {
+            Map requestMap = getFacesContext().getExternalContext().getRequestMap();
+            requestMap.put(_varDetailToggler, this);
         }
     }
 
@@ -841,7 +856,64 @@
     protected void setPreservedDataModel(_SerializableDataModel preservedDataModel) {
         _preservedDataModel = preservedDataModel;
     }
+    public String getDetailHeader() {
+    	if(detailColumn!=null){
+    		return (String) ((UIOutput)detailColumn.getHeader()).getValue();
+    	} else {
+    		return null;
+    	}
+	}
+
+	public void setDetailHeader(String header) {
+		if(detailColumn!=null){
+			((UIOutput)detailColumn.getHeader()).setValue(header);
+		}	
+	}
+    
+	
+	public boolean isCurrentDetailExpanded(){
+		return _expandedNodes.contains(new Integer(getRowIndex()));
+	}
+	
+	public void setVarDetailToggler(String varDetailToggler)
+    {
+		_varDetailToggler = varDetailToggler;
+		
+    }
+	
+    public HtmlDataTable()
+    {
+        setRendererType(DEFAULT_RENDERER_TYPE);
+    }
 
+	
+	/**
+	 * Change the status of the current detail row from collapsed to expanded or 
+	 * viceversa.
+	 *
+	 */ 
+	public void toggleDetail(){
+		Integer rowIndex = new Integer(getRowIndex());
+		
+		if(_expandedNodes.contains(rowIndex)){
+			_expandedNodes.remove(rowIndex);
+			
+		} else {
+			_expandedNodes.add(rowIndex);					
+		}		
+	}
+	
+	/**
+	 * Return true if the current detail row is expanded.
+	 * 
+	 * @return
+	 */
+	public boolean isDetailExpanded(){
+		Integer rowIndex = new Integer(getRowIndex());
+		
+		return _expandedNodes.contains(rowIndex);
+	}
+	
     //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
 
     public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlDataTable";
@@ -860,10 +932,7 @@
     private String _rowCountVar = null;
     private String _previousRowDataVar = null;
 
-    public HtmlDataTable()
-    {
-        setRendererType(DEFAULT_RENDERER_TYPE);
-    }
+  
 
     public void setPreserveDataModel(boolean preserveDataModel)
     {

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java?rev=375266&r1=375265&r2=375266&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
Mon Feb  6 04:41:55 2006
@@ -42,7 +42,45 @@
 public class HtmlTableRenderer extends HtmlTableRendererBase
 {
     //private static final Log log = LogFactory.getLog(HtmlTableRenderer.class);
+
+	/** DetailStamp facet name. */
+    public static final String DETAIL_STAMP_FACET_NAME = "detailStamp";
   
+    
+    protected void afterRow(FacesContext facesContext, UIData uiData) throws IOException
{
+		super.afterRow(facesContext, uiData);
+		
+		renderDetailRow(facesContext, uiData);
+	}
+
+	/**
+	 *  
+	 * @param facesContext
+	 * @param uiData
+	 * @throws IOException
+	 */
+	private void renderDetailRow(FacesContext facesContext, UIData uiData) throws IOException
{
+		UIComponent detailStampFacet = uiData.getFacet(DETAIL_STAMP_FACET_NAME);
+		
+		if(uiData instanceof HtmlDataTable ){
+			HtmlDataTable htmlDataTable = (HtmlDataTable)uiData;
+			
+			if(htmlDataTable.isCurrentDetailExpanded()){
+				ResponseWriter writer = facesContext.getResponseWriter();
+				writer.startElement(HTML.TR_ELEM,uiData);
+				writer.startElement(HTML.TD_ELEM,uiData);
+				writer.writeAttribute(HTML.COLSPAN_ATTR,new Integer(uiData.getChildren().size()) ,null);
+				
+				if(detailStampFacet!=null){
+					RendererUtils.renderChild(facesContext, detailStampFacet);
+				}
+				
+				writer.endElement(HTML.TD_ELEM);
+				writer.endElement(HTML.TR_ELEM);
+			}
+		}
+	}
+
     /**
      * @see org.apache.myfaces.renderkit.html.HtmlTableRendererBase#encodeBegin(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
      */

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java?rev=375266&r1=375265&r2=375266&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
(original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/taglib/html/ext/HtmlDataTableTag.java
Mon Feb  6 04:41:55 2006
@@ -64,6 +64,7 @@
     private String _rowOnKeyDown;
     private String _rowOnKeyUp;
     private String _rowId;
+    private String _varDetailToggler;
     
     private String _rowStyleClass;
     private String _rowStyle;
@@ -95,6 +96,7 @@
         _rowOnKeyDown=null;
         _rowOnKeyUp=null;
         _rowId=null;
+        _varDetailToggler=null;
 
         _rowStyleClass = null;
         _rowStyle = null;
@@ -126,7 +128,8 @@
         setStringProperty(component, "rowOnKeyPress", _rowOnKeyPress);
         setStringProperty(component, "rowOnKeyDown", _rowOnKeyDown);
         setStringProperty(component, "rowOnKeyUp", _rowOnKeyUp);
-        setStringProperty(component, JSFAttr.ROW_ID, _rowId);
+        setStringProperty(component, JSFAttr.ROW_ID, _rowId);        
+        setStringProperty(component,"varDetailToggler",_varDetailToggler);
         
         setStringProperty(component, JSFAttr.ROW_STYLECLASS_ATTR, _rowStyleClass);
         setStringProperty(component, JSFAttr.ROW_STYLE_ATTR, _rowStyle);
@@ -256,4 +259,13 @@
     {
       _rowStyle = rowStyle;
     }
+
+		
+	public String getVarDetailToggler() {
+		return _varDetailToggler;
+	}
+
+	public void setVarDetailToggler(String varDetailToggler) {
+		_varDetailToggler = varDetailToggler;
+	}
 }

Modified: myfaces/tomahawk/trunk/core/src/main/tld/entities/extended_data_table_attributes.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/tld/entities/extended_data_table_attributes.xml?rev=375266&r1=375265&r2=375266&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/tld/entities/extended_data_table_attributes.xml (original)
+++ myfaces/tomahawk/trunk/core/src/main/tld/entities/extended_data_table_attributes.xml Mon
Feb  6 04:41:55 2006
@@ -223,4 +223,13 @@
             <required>false</required>
             <rtexprvalue>false</rtexprvalue>
             <description>Corresponds to the HTML style attribute for the row tr tag.</description>
-        </attribute>
\ No newline at end of file
+        </attribute>        
+        <attribute>
+         <name>varDetailToggler</name>
+         <required>false</required>
+         <rtexprvalue>false</rtexprvalue>
+         <description>
+              This variable has the boolean property "detailExpanded" which is true if the
current detail row is expanded and the action method 
+              "toggleDetail" which expand/collapse the current detail row.
+         </description>
+      </attribute>



Mime
View raw message