Author: svieujot
Date: Tue May 3 14:32:35 2005
New Revision: 168000
URL: http://svn.apache.org/viewcvs?rev=168000&view=rev
Log:
Add a renderFacetsIfSinglePage attribute & some bugfixes to x:dataScroller.
Modified:
myfaces/trunk/doc/release-notes.txt
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
myfaces/trunk/tlds/myfaces_ext.tld
Modified: myfaces/trunk/doc/release-notes.txt
URL:
http://svn.apache.org/viewcvs/myfaces/trunk/doc/release-notes.txt?rev=168000&r1=167999&r2=168000&view=diff
==============================================================================
--- myfaces/trunk/doc/release-notes.txt (original)
+++ myfaces/trunk/doc/release-notes.txt Tue May 3 14:32:35 2005
@@ -3,6 +3,7 @@
----------------------------------------------------------------------
Changes in Release 1.0.10
+* added renderFacetsIfSinglePage to x:dataScroller
* closed MYFACES-177
* closed MYFACES-199
* closed MYFACES-209
Modified:
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
URL:
http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java?rev=168000&r1=167999&r2=168000&view=diff
==============================================================================
---
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
(original)
+++
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
Tue May 3 14:32:35 2005
@@ -87,7 +87,7 @@
return (UIComponent)getFacets().get(FAST_REWIND_FACET_NAME);
}
- public void setPrevoius(UIComponent previous)
+ public void setPrevious(UIComponent previous)
{
getFacets().put(PREVIOUS_FACET_NAME, previous);
}
@@ -129,6 +129,7 @@
private String _paginatorColumnStyle = null;
private String _paginatorActiveColumnClass = null;
private String _paginatorActiveColumnStyle = null;
+ private Boolean _renderFacetsIfSinglePage = null;
public HtmlDataScroller()
{
@@ -359,11 +360,22 @@
return vb != null ? (String)vb.getValue(getFacesContext()) : null;
}
-
+ public void setRenderFacetsIfSinglePage(boolean renderFacetsIfSinglePage)
+ {
+ _renderFacetsIfSinglePage =
Boolean.valueOf(renderFacetsIfSinglePage);
+ }
+
+ public boolean isRenderFacetsIfSinglePage()
+ {
+ if (_renderFacetsIfSinglePage != null) return
_renderFacetsIfSinglePage.booleanValue();
+ ValueBinding vb = getValueBinding("renderFacetsIfSinglePage");
+ Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) :
null;
+ return v != null ? v.booleanValue() : true;
+ }
public Object saveState(FacesContext context)
{
- Object values[] = new Object[20];
+ Object values[] = new Object[21];
values[0] = super.saveState(context);
values[1] = _for;
values[2] = _fastStep;
@@ -384,6 +396,7 @@
values[17] = _paginatorColumnStyle;
values[18] = _paginatorActiveColumnClass;
values[19] = _paginatorActiveColumnStyle;
+ values[20] = _renderFacetsIfSinglePage;
return values;
}
@@ -410,6 +423,7 @@
_paginatorColumnStyle = (String)values[17];
_paginatorActiveColumnClass = (String)values[18];
_paginatorActiveColumnStyle = (String)values[19];
+ _renderFacetsIfSinglePage = (Boolean)values[20];
}
//------------------ GENERATED CODE END
---------------------------------------
}
Modified:
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml
URL:
http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml?rev=168000&r1=167999&r2=168000&view=diff
==============================================================================
---
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml
(original)
+++
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml
Tue May 3 14:32:35 2005
@@ -25,6 +25,10 @@
<type>java.lang.String</type>
</field>
<field>
+ <name>rowsCountVar</name>
+ <type>String</type>
+ </field>
+ <field>
<name>style</name>
<type>String</type>
</field>
@@ -63,5 +67,9 @@
<field>
<name>paginatorActiveColumnStyle</name>
<type>String</type>
+ </field>
+ <field>
+ <name>renderFacetsIfSinglePage</name>
+ <type>boolean</type>
</field>
</component>
Modified:
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
URL:
http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java?rev=168000&r1=167999&r2=168000&view=diff
==============================================================================
---
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
(original)
+++
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
Tue May 3 14:32:35 2005
@@ -36,7 +36,7 @@
/**
* @author Thomas Spiegl (latest modification by $Author$)
* @version $Revision$ $Date$
- * $Log$
+ * $Log: HtmlDataScrollerRenderer.java,v $
* Revision 1.19 2005/01/04 01:42:23 svieujot
* Bugfix for last page.
*
@@ -62,7 +62,7 @@
private static final Log log =
LogFactory.getLog(HtmlDataScrollerRenderer.class);
protected static final String FACET_FIRST = "first".intern();
- protected static final String FACET_PREVOIUS = "previous".intern();
+ protected static final String FACET_PREVIOUS = "previous".intern();
protected static final String FACET_NEXT = "next".intern();
protected static final String FACET_LAST = "last".intern();
protected static final String FACET_FAST_FORWARD = "fastf".intern();
@@ -96,7 +96,7 @@
{
uiData.setFirst(0);
}
- else if (param.equals(FACET_PREVOIUS))
+ else if (param.equals(FACET_PREVIOUS))
{
int previous = uiData.getFirst() - uiData.getRows();
if (previous >= 0)
@@ -161,22 +161,16 @@
}
}
-
- public void encodeChildren(FacesContext facescontext, UIComponent
uicomponent) throws IOException
+ protected void setVariables(FacesContext facescontext, HtmlDataScroller
scroller) throws IOException
{
- RendererUtils.checkParamValidity(facescontext, uicomponent,
HtmlDataScroller.class);
-
- Map requestMap = facescontext.getExternalContext().getRequestMap();
- HtmlDataScroller scroller = (HtmlDataScroller)uicomponent;
-
- UIData uiData = findUIData(scroller, uicomponent);
+ UIData uiData = findUIData(scroller, scroller);
if (uiData == null)
{
return;
}
-
-
-
+
+ Map requestMap =
facescontext.getExternalContext().getRequestMap();
+
String pageCountVar = scroller.getPageCountVar();
if (pageCountVar != null)
{
@@ -219,41 +213,65 @@
lastRowIndex = count;
requestMap.put(lastRowIndexVar, new Integer(lastRowIndex));
}
-
- RendererUtils.renderChildren(facescontext, uicomponent);
-
+ }
+
+ public void removeVariables(FacesContext facescontext, HtmlDataScroller
scroller) throws IOException
+ {
+ Map requestMap =
facescontext.getExternalContext().getRequestMap();
+
+ String pageCountVar = scroller.getPageCountVar();
if (pageCountVar != null)
{
requestMap.remove(pageCountVar);
}
+ String pageIndexVar = scroller.getPageIndexVar();
if (pageIndexVar != null)
{
requestMap.remove(pageIndexVar);
}
+ String rowsCountVar = scroller.getRowsCountVar();
if (rowsCountVar != null)
{
requestMap.remove(rowsCountVar);
}
+ String displayedRowsCountVar =
scroller.getDisplayedRowsCountVar();
if (displayedRowsCountVar != null)
{
requestMap.remove(displayedRowsCountVar);
}
+ String firstRowIndexVar = scroller.getFirstRowIndexVar();
if (firstRowIndexVar != null)
{
requestMap.remove(firstRowIndexVar);
}
+ String lastRowIndexVar = scroller.getLastRowIndexVar();
if (lastRowIndexVar != null)
{
requestMap.remove(lastRowIndexVar);
}
}
- public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
throws IOException
+ public void encodeBegin(FacesContext facesContext, UIComponent
uiComponent) throws IOException {
+ super.encodeBegin(facesContext, uiComponent);
+
+ RendererUtils.checkParamValidity(facesContext, uiComponent,
HtmlDataScroller.class);
+
+ HtmlDataScroller scroller = (HtmlDataScroller)uiComponent;
+
+ setVariables(facesContext, scroller);
+ }
+
+ public void encodeChildren(FacesContext facescontext, UIComponent
uicomponent) throws IOException
{
- RendererUtils.checkParamValidity(facesContext, uiComponent,
HtmlDataScroller.class);
+ RendererUtils.checkParamValidity(facescontext, uicomponent,
HtmlDataScroller.class);
+
+ RendererUtils.renderChildren(facescontext, uicomponent);
+ }
- ResponseWriter writer = facesContext.getResponseWriter();
- HtmlDataScroller scroller = (HtmlDataScroller)uiComponent;
+ public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
throws IOException{
+ RendererUtils.checkParamValidity(facesContext, uiComponent,
HtmlDataScroller.class);
+
+ HtmlDataScroller scroller = (HtmlDataScroller)uiComponent;
UIData uiData = findUIData(scroller, uiComponent);
if (uiData == null)
@@ -261,6 +279,17 @@
return;
}
+ renderPaginator(uiData, facesContext, scroller);
+ removeVariables(facesContext, scroller);
+ }
+
+ public void renderPaginator(UIData uiData, FacesContext facesContext,
HtmlDataScroller scroller) throws IOException
+ {
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ if (!scroller.isRenderFacetsIfSinglePage() &&
getPageCount(uiData)<=1)
+ return;
+
writer.startElement("table", scroller);
String styleClass = scroller.getStyleClass();
if (styleClass != null)
@@ -292,7 +321,7 @@
if (facetComp != null)
{
writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, FACET_PREVOIUS);
+ renderFacet(facesContext, scroller, facetComp, FACET_PREVIOUS);
writer.endElement("td");
}
if (scroller.isPaginator())
Modified:
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
URL:
http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java?rev=168000&r1=167999&r2=168000&view=diff
==============================================================================
---
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
(original)
+++
myfaces/trunk/src/components/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
Tue May 3 14:32:35 2005
@@ -23,7 +23,7 @@
/**
* @author Thomas Spiegl (latest modification by $Author$)
* @version $Revision$ $Date$
- * $Log$
+ * $Log: HtmlDataScrollerTag.java,v $
* Revision 1.11 2005/02/18 17:19:30 matzew
* added release() to tag clazzes.
*
@@ -93,6 +93,7 @@
private static final String PAGINATOR_COL_STYLE_ATTR =
"paginatorColumnStyle";
private static final String PAGINATOR_ACTCOL_CLASS_ATTR =
"paginatorActiveColumnClass";
private static final String PAGINATOR_ACTCOL_STYLE_ATTR =
"paginatorActiveColumnStyle";
+ private static final String RENDER_FACETS_IF_SINGLE_PAGE_ATTR =
"renderFacetsIfSinglePage";
private String _for;
private String _fastStep;
@@ -112,6 +113,7 @@
private String _paginatorColumnStyle;
private String _paginatorActiveColumnClass;
private String _paginatorActiveColumnStyle;
+ private String _renderFacetsIfSinglePage;
// User Role support
private String _enabledOnUserRole;
@@ -137,6 +139,7 @@
_paginatorColumnStyle=null;
_paginatorActiveColumnClass=null;
_paginatorActiveColumnStyle=null;
+ _renderFacetsIfSinglePage=null;
_enabledOnUserRole=null;
_visibleOnUserRole=null;
}
@@ -173,7 +176,8 @@
setStringProperty(component, PAGINATOR_COL_STYLE_ATTR,
_paginatorColumnStyle);
setStringProperty(component, PAGINATOR_ACTCOL_CLASS_ATTR,
_paginatorActiveColumnClass);
setStringProperty(component, PAGINATOR_ACTCOL_STYLE_ATTR,
_paginatorActiveColumnStyle);
-
+ setBooleanProperty(component,
RENDER_FACETS_IF_SINGLE_PAGE_ATTR, _renderFacetsIfSinglePage);
+
setStringProperty(component, UserRoleAware.ENABLED_ON_USER_ROLE_ATTR,
_enabledOnUserRole);
setStringProperty(component, UserRoleAware.VISIBLE_ON_USER_ROLE_ATTR,
_visibleOnUserRole);
}
@@ -267,6 +271,11 @@
public void setPaginatorActiveColumnStyle(String
paginatorActiveColumnStyle)
{
_paginatorActiveColumnStyle = paginatorActiveColumnStyle;
+ }
+
+ public void setRenderFacetsIfSinglePage(String renderFacetsIfSinglePage)
+ {
+ _renderFacetsIfSinglePage = renderFacetsIfSinglePage;
}
// userrole attributes
Modified: myfaces/trunk/tlds/myfaces_ext.tld
URL:
http://svn.apache.org/viewcvs/myfaces/trunk/tlds/myfaces_ext.tld?rev=168000&r1=167999&r2=168000&view=diff
==============================================================================
--- myfaces/trunk/tlds/myfaces_ext.tld (original)
+++ myfaces/trunk/tlds/myfaces_ext.tld Tue May 3 14:32:35 2005
@@ -758,7 +758,7 @@
</attribute>
</tag>
- <!-- dataTableScroller -->
+ <!-- dataScroller -->
<tag>
<name>dataScroller</name>
<tag-class>org.apache.myfaces.custom.datascroller.HtmlDataScrollerTag</tag-class>
@@ -913,6 +913,15 @@
<rtexprvalue>false</rtexprvalue>
<description>
style for paginator's column with pageIndex = currentPageIndex
+ </description>
+ </attribute>
+ <attribute>
+ <name>renderFacetsIfSinglePage</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <description>
+ If set to false, the facets aren't renderd if all the lines
are contained on a single page.
+ Default is true.
</description>
</attribute>
</tag>