You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2006/02/25 18:34:15 UTC
svn commit: r380958 - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/renderkit/html/ext/
examples/simple/src/main/java/org/apache/myfaces/examples/listexample/
examples/simple/src/main/webapp/
Author: imario
Date: Sat Feb 25 09:34:13 2006
New Revision: 380958
URL: http://svn.apache.org/viewcvs?rev=380958&view=rev
Log:
MYFACES-1146: supress header/footer if all facets within each of them have rendered="false" set
Added:
myfaces/tomahawk/trunk/examples/simple/src/main/webapp/optDataTable.jsp (with props)
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java
myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp
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=380958&r1=380957&r2=380958&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 Sat Feb 25 09:34:13 2006
@@ -479,4 +479,39 @@
}
return result;
}
+
+ /**
+ * Renders header or footer.
+ * Rendering will be supressed if all of the facet will have rendered="false"
+ */
+ protected void renderFacet(FacesContext facesContext, ResponseWriter writer, UIComponent component, boolean header) throws IOException
+ {
+ if (determineRenderFacet(component, header))
+ {
+ super.renderFacet(facesContext, writer, component, header);
+ }
+ }
+
+ /**
+ * determine if the header or footer should be rendered.
+ */
+ protected boolean determineRenderFacet(UIComponent component, boolean header)
+ {
+ for (Iterator it = getChildren(component).iterator(); it.hasNext();)
+ {
+ UIComponent uiComponent = (UIComponent) it.next();
+ if(uiComponent.isRendered() && determineChildColSpan(uiComponent) > 0)
+ {
+ UIComponent facet = header ? (UIComponent) uiComponent.getFacets().get(HEADER_FACET_NAME)
+ : (UIComponent) uiComponent.getFacets().get(FOOTER_FACET_NAME);
+
+ if (facet != null && facet.isRendered())
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
}
Modified: myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java?rev=380958&r1=380957&r2=380958&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/listexample/SimpleCountryForm.java Sat Feb 25 09:34:13 2006
@@ -26,6 +26,9 @@
*/
public class SimpleCountryForm
{
+ private boolean renderHeader = true;
+ private boolean renderFooter = true;
+
private long _id;
private String _name;
private String _isoCode;
@@ -75,7 +78,27 @@
return new SimpleCountry(_id, _name, _isoCode, null, null);
}
- public String save()
+ public boolean isRenderFooter()
+ {
+ return renderFooter;
+ }
+
+ public void setRenderFooter(boolean renderFooter)
+ {
+ this.renderFooter = renderFooter;
+ }
+
+ public boolean isRenderHeader()
+ {
+ return renderHeader;
+ }
+
+ public void setRenderHeader(boolean renderHeader)
+ {
+ this.renderHeader = renderHeader;
+ }
+
+ public String save()
{
getList().saveSimpleCountry(getSimpleCountry());
return "ok_next";
Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp?rev=380958&r1=380957&r2=380958&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp Sat Feb 25 09:34:13 2006
@@ -37,6 +37,7 @@
<h:outputLink value="pagedSortTable.jsf" ><f:verbatim>Paged and Sortable</f:verbatim></h:outputLink>
<h:outputLink value="openDataTable.jsf" ><f:verbatim>Paged and Sortable (dynamic number of columns; mouseover)</f:verbatim></h:outputLink>
<h:outputLink value="crossDataTable.jsf" ><f:verbatim>Dynamic number of columns, add a column</f:verbatim></h:outputLink>
+ <h:outputLink value="optDataTable.jsf" ><f:verbatim>Optional Header/Footer</f:verbatim></h:outputLink>
</h:panelGrid>
<h:outputLink value="selectbox.jsf" ><f:verbatim>Select boxes</f:verbatim></h:outputLink>
<h:outputLink value="fileupload.jsf" ><f:verbatim>File upload</f:verbatim></h:outputLink>
Added: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/optDataTable.jsp
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/optDataTable.jsp?rev=380958&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/optDataTable.jsp (added)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/optDataTable.jsp Sat Feb 25 09:34:13 2006
@@ -0,0 +1,115 @@
+<%@ page
+ session="false"
+ contentType="text/html;charset=utf-8"%>
+<%@ taglib
+ uri="http://java.sun.com/jsf/html"
+ prefix="h"%>
+<%@ taglib
+ uri="http://java.sun.com/jsf/core"
+ prefix="f"%>
+<%@ taglib
+ uri="http://myfaces.apache.org/tomahawk"
+ prefix="t"%>
+<html>
+
+<!--
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//-->
+
+<%@include file="inc/head.inc"%>
+
+<body>
+
+<f:view>
+
+ <f:loadBundle
+ basename="org.apache.myfaces.examples.resource.example_messages"
+ var="example_messages" />
+
+<h:form>
+ <h:panelGroup id="body">
+
+ <h:panelGrid columns="2">
+ <f:facet name="footer">
+ <h:commandButton value="Update Table" />
+ </f:facet>
+
+ <h:outputLabel for="renderHeader" value="Render Header"/>
+ <h:selectBooleanCheckbox id="renderHeader" value="#{countryForm.renderHeader}" />
+
+ <h:outputLabel for="renderFooter" value="Render Footer"/>
+ <h:selectBooleanCheckbox id="renderFooter" value="#{countryForm.renderFooter}" />
+ </h:panelGrid>
+
+ <f:verbatim>
+ <br>
+ </f:verbatim>
+
+ <t:dataTable
+ id="data"
+ styleClass="standardTable"
+ headerClass="standardTable_Header"
+ footerClass="standardTable_Header"
+ rowClasses="standardTable_Row1,standardTable_Row2"
+ columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column"
+ var="currentCountry"
+ value="#{countryList.countries}"
+ preserveDataModel="true">
+ <h:column>
+ <f:facet name="header">
+ <h:outputText
+ value="#{example_messages['label_country_name']}"
+ />
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText
+ value="#{example_messages['label_country_name']}"
+ rendered="#{countryForm.renderFooter}"/>
+ </f:facet>
+
+ <h:outputText value="#{currentCountry.name}" />
+ </h:column>
+
+ <h:column>
+ <f:facet name="header">
+ <h:outputText
+ value="#{example_messages['label_country_iso']}"
+ rendered="#{countryForm.renderHeader}"/>
+ </f:facet>
+ <f:facet name="footer">
+ <h:outputText
+ value="#{example_messages['label_country_iso']}"
+ rendered="#{countryForm.renderFooter}"/>
+ </f:facet>
+ <h:outputText value="#{currentCountry.isoCode}" />
+ </h:column>
+
+ </t:dataTable>
+
+ <f:verbatim>
+ <br>
+ </f:verbatim>
+
+ </h:panelGroup>
+</h:form>
+</f:view>
+
+<%@include file="inc/page_footer.jsp"%>
+
+</body>
+
+</html>
Propchange: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/optDataTable.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/optDataTable.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/optDataTable.jsp
------------------------------------------------------------------------------
svn:mime-type = text/plain