JBoss Rich Faces SVN: r756 - in trunk/richfaces/panelmenu: src/main/java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-14 15:20:28 -0400 (Mon, 14 May 2007)
New Revision: 756
Added:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java
Modified:
trunk/richfaces/panelmenu/pom.xml
Log:
Modified: trunk/richfaces/panelmenu/pom.xml
===================================================================
--- trunk/richfaces/panelmenu/pom.xml 2007-05-14 18:08:34 UTC (rev 755)
+++ trunk/richfaces/panelmenu/pom.xml 2007-05-14 19:20:28 UTC (rev 756)
@@ -44,5 +44,11 @@
</plugins>
</build>
<dependencies>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
+
</project>
\ No newline at end of file
Added: trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java (rev 0)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java 2007-05-14 19:20:28 UTC (rev 756)
@@ -0,0 +1,7 @@
+package org.richfaces.component.panelmenu;
+
+import org.richfaces.component.UISwitchablePanel;
+
+public class UIPanelMenu extends UISwitchablePanel{
+
+}
Property changes on: trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenu.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
17 years, 8 months
JBoss Rich Faces SVN: r755 - trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-14 14:08:34 -0400 (Mon, 14 May 2007)
New Revision: 755
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
Log:
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-05-14 18:07:18 UTC (rev 754)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-05-14 18:08:34 UTC (rev 755)
@@ -33,9 +33,11 @@
</head>
<body>
+ <f:view>
<h:form>
- <sg:scrollable-grid value="#{selectionBean.dataModel}" var="issues" first="0" rows="50">
- <sg:column style="width: 100px" frozen="true">
+
+ <sg:scrollable-grid value="#{selectionBean.dataModel}" var="issues" frozenColCount="2" first="0" rows="30">
+ <sg:column width="200px">
<f:facet name="header">
<h:outputText value="Key"></h:outputText>
</f:facet>
@@ -44,7 +46,7 @@
<h:outputText value="footer1"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 100px">
+ <sg:column width="200px">
<f:facet name="header">
<h:outputText value="Summary"></h:outputText>
</f:facet>
@@ -53,7 +55,7 @@
<h:outputText value="footer2"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 100px">
+ <sg:column width="200px">
<f:facet name="header">
<h:outputText value="Assignee"></h:outputText>
</f:facet>
@@ -62,16 +64,16 @@
<h:outputText value="footer3"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 100px">
+ <sg:column width="200px">
<f:facet name="header">
<h:outputText value="Status"></h:outputText>
</f:facet>
- <h:outputText value="#{issues.status}"></h:outputText>
+ <h:outputText value="#{issues.status.name}"></h:outputText>
<f:facet name="footer">
<h:outputText value="footer4"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 100px">
+ <sg:column width="200px">
<f:facet name="header">
<h:outputText value="Reporter"></h:outputText>
</f:facet>
@@ -80,7 +82,7 @@
<h:outputText value="footer5"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 100px">
+ <sg:column width="200px">
<f:facet name="header">
<h:outputText value="Created"></h:outputText>
</f:facet>
@@ -89,7 +91,7 @@
<h:outputText value="footer6"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 100px">
+ <sg:column width="200px">
<f:facet name="header">
<h:outputText value="Updated"></h:outputText>
</f:facet>
@@ -98,7 +100,7 @@
<h:outputText value="footer7"></h:outputText>
</f:facet>
</sg:column>
- <sg:column style="width: 100px">
+ <sg:column width="200px">
<f:facet name="header">
<h:outputText value="Resolution"></h:outputText>
</f:facet>
@@ -108,6 +110,8 @@
</f:facet>
</sg:column>
</sg:scrollable-grid>
+
</h:form>
+ </f:view>
</body>
</html>
\ No newline at end of file
17 years, 8 months
JBoss Rich Faces SVN: r754 - trunk/sandbox/scrollable-grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-14 14:07:18 -0400 (Mon, 14 May 2007)
New Revision: 754
Modified:
trunk/sandbox/scrollable-grid/pom.xml
Log:
Modified: trunk/sandbox/scrollable-grid/pom.xml
===================================================================
--- trunk/sandbox/scrollable-grid/pom.xml 2007-05-14 18:06:26 UTC (rev 753)
+++ trunk/sandbox/scrollable-grid/pom.xml 2007-05-14 18:07:18 UTC (rev 754)
@@ -112,7 +112,7 @@
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
- <version>1.1.6</version>
+ <version>1.1.12</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
17 years, 8 months
JBoss Rich Faces SVN: r753 - trunk/sandbox/scrollable-grid/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-14 14:06:26 -0400 (Mon, 14 May 2007)
New Revision: 753
Modified:
trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml 2007-05-14 18:06:16 UTC (rev 752)
+++ trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml 2007-05-14 18:06:26 UTC (rev 753)
@@ -49,7 +49,14 @@
<![CDATA[ Scrollable Grid custom column impl]]>
</description>
</tag>
+ <property>
+ <name>width</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue>"100px"</defaultvalue>
+ </property>
+
&ui_component_attributes;
&html_style_attributes;
</component>
17 years, 8 months
JBoss Rich Faces SVN: r752 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-14 14:06:16 -0400 (Mon, 14 May 2007)
New Revision: 752
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-05-14 18:05:06 UTC (rev 751)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-05-14 18:06:16 UTC (rev 752)
@@ -41,11 +41,11 @@
UIComponent kid = (UIComponent) iter.next();
if (kid.isRendered()) {
if (kid instanceof UIScrollableGridColumn){
+ visitor.visit(context, (UIScrollableGridColumn)kid, writer, state);
if(state.isFrozenColumn()){
- int i = state.getFrozenColumnCount() - 1;
- state.setFrozenColumnCount(i);
+ int i = state.getFrozenColumnCount();
+ state.setFrozenColumnCount(i-1);
}
- visitor.visit(context, (UIScrollableGridColumn)kid, writer, state);
}
}
}
@@ -56,38 +56,64 @@
}
static void iterateOverCells(FacesContext context, UIComponent component, ColumnVisitor visitor,
- ResponseWriter writer, GridRendererState state) throws IOException{
-
-
+ ResponseWriter writer, GridRendererState state) throws IOException{
+
+
+ if(context == null || component == null){
+ throw new NullPointerException();
+ }
+
+ if(!component.isRendered()){
+ return ;
+ }
+
+ if(component instanceof UIScrollableGrid){
+ for (Iterator iter = component.getChildren().iterator(); iter.hasNext(); ) {
+ UIComponent kid = (UIComponent) iter.next();
+ if (kid.isRendered()) {
+ if (kid instanceof UIScrollableGridColumn){
+ UIScrollableGridColumn column = (UIScrollableGridColumn)kid;
+ if(state.isFrozenColumn()){
+ int i = state.getFrozenColumnCount();
+ state.setFrozenColumnCount(i-1);
+ if(state.isFrozenPart()){
+ visitor.visit(context, column, writer,state);
+ }
+ }else if(!state.isFrozenColumn()&& !state.isFrozenPart()){
+ visitor.visit(context, column, writer,state);
+ }
+ state.nextCell();
+ }
+ }
+ }
+ state.setCellIndex(0);
+ }
+ }
+
+ static void iterateOverAjaxCells(FacesContext context, UIComponent component, ColumnVisitor visitor,
+ ResponseWriter writer, GridRendererState state) throws IOException{
+
if(context == null || component == null){
throw new NullPointerException();
}
-
+
if(!component.isRendered()){
return ;
}
-
+
if(component instanceof UIScrollableGrid){
for (Iterator iter = component.getChildren().iterator(); iter.hasNext(); ) {
UIComponent kid = (UIComponent) iter.next();
if (kid.isRendered()) {
if (kid instanceof UIScrollableGridColumn){
UIScrollableGridColumn column = (UIScrollableGridColumn)kid;
-
- if(state.isFrozenColumn()){
- int i = state.getFrozenColumnCount();
- i--;
- state.setFrozenColumnCount(i);
- visitor.visit(context, column, writer,state);
-
- } else if(!state.isFrozenColumn()){
- visitor.visit(context,column, writer, state);
- }
+ visitor.visit(context, column, writer,state);
state.nextCell();
- }
+ }
}
}
- state.setCellIndex(0);
}
+
+ state.setCellIndex(0);
}
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-05-14 18:05:06 UTC (rev 751)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-05-14 18:06:16 UTC (rev 752)
@@ -9,7 +9,9 @@
import javax.faces.FacesException;
import javax.faces.component.NamingContainer;
import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.apache.commons.digester.xmlrules.FromXmlRuleSet;
import org.richfaces.component.UIScrollableGrid;
@@ -33,8 +35,18 @@
private int _columns = 0;
+ private String _cell_id_prefix;
+
+ private String _column_type;
+
private int _frozenColumnCount = -1;
-
+
+ private AjaxContext ajaxContext;
+
+ private boolean _frozenPart = false;
+
+ private ResponseWriter writer;
+
private UIScrollableGrid _grid;
private String _cachedClientId;
@@ -203,6 +215,9 @@
* @return new row number.
*/
public int nextRow(){
+ if(_rowIndex > _grid.getRows())
+ _rowIndex = 0;
+
return ++_rowIndex;
}
@@ -262,7 +277,7 @@
}
public boolean isFrozenColumn() {
- return _frozenColumnCount < 0 ? false:true;
+ return _frozenColumnCount <= 0 ? false:true;
}
public void setFrozenColumnCount(int columnCount) {
@@ -273,4 +288,43 @@
return _frozenColumnCount;
}
+ public boolean isFrozenPart() {
+ return _frozenPart;
+ }
+
+ public void setFrozenPart(boolean part) {
+ _frozenPart = part;
+ }
+
+ public String getCellIdPrefix() {
+ return _cell_id_prefix;
+ }
+
+ public void setCellIdPrefix(String _id_prefix) {
+ this._cell_id_prefix = _id_prefix;
+ }
+
+ public String getColumnType() {
+ return _column_type;
+ }
+
+ public void setColumType(String _column_type) {
+ this._column_type = _column_type;
+ }
+
+ public AjaxContext getAjaxContext() {
+ return ajaxContext;
+ }
+
+ public void setAjaxContext(AjaxContext ajaxContext) {
+ this.ajaxContext = ajaxContext;
+ }
+
+ public ResponseWriter getWriter() {
+ return writer;
+ }
+
+ public void setWriter(ResponseWriter writer) {
+ this.writer = writer;
+ }
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-14 18:05:06 UTC (rev 751)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-14 18:06:16 UTC (rev 752)
@@ -34,10 +34,14 @@
private final String HEADER_PART = "header";
- private final RendererBase cellTemplate = TemplateLoader.loadTemplate("org.richfaces.renderkit.html.ScrollableGridCellRenderer");
+ private final String CELL_ID_PREFFIX ="bc_";
-
+ private final String COLUMN_FROZEN_TYPE = "frozen";
+ private final String COLUMN_NORMAL_TYPE = "normal";
+
+ private final RendererBase cellTemplate = TemplateLoader.loadTemplate("org.richfaces.renderkit.html.ScrollableGridCellRenderer");
+
private final ColumnVisitor headerRenderer = new ColumnVisitor(){
public void visit(FacesContext context, UIScrollableGridColumn column,
@@ -46,9 +50,8 @@
writer.startElement(HTML.td_ELEM, column);
String frozen = Boolean.toString(state.isFrozenColumn());
getUtils().writeAttribute(writer, "frozen",frozen );
- getUtils().writeAttribute(writer, "style",column.getAttributes().get("style"));
+ getUtils().writeAttribute(writer, "width",column.getAttributes().get("width"));
writer.writeText("\n", null);
-
if(column.getFacet(HEADER_PART) != null){
UIComponent component = column.getFacet(HEADER_PART);
renderChild(context, component);
@@ -83,30 +86,65 @@
ResponseWriter writer, GridRendererState state) throws IOException {
ComponentVariables variables = ComponentsVariableResolver.getVariables(cellTemplate, column);
- variables.setVariable("row_index",Integer.valueOf(state.getRowIndex()));
- variables.setVariable("cell_index",Integer.valueOf(state.getCellIndex()));
+ variables.setVariable("cell_index",state.getColumnType()+ ":" + state.getRowIndex()+ ":" + state.getCellIndex());
cellTemplate.encodeBegin(context, column);
renderChildren(context, column);
cellTemplate.encodeEnd(context, column);
}
};
-
+
private final DataVisitor rowsRenderer = new DataVisitor(){
public void process(FacesContext context, Object rowIndex, Object argument) throws IOException {
- GridRendererState state = (GridRendererState)argument;
- UIScrollableGrid grid = state.getGrid();
- int index = ((Integer)rowIndex).intValue();
+ GridRendererState state = (GridRendererState)argument;
+ UIScrollableGrid grid = state.getGrid();
+ ResponseWriter writer = context.getResponseWriter();
grid.setRowKey(rowIndex);
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.TR_ELEMENT, grid);
- getUtils().writeAttribute(writer, "id","row_"+ index);
- getUtils().writeAttribute(writer, "class","ClientUI_Grid_BR");
- ColumnWalker.iterateOverCells(context, grid, cellRenderer, writer, state);
+
+ if(grid.isRowAvailable()){
+ int index = ((Integer)rowIndex).intValue();
+ state.setRowIndex(index);
+
+ writer.startElement(HTML.TR_ELEMENT, grid);
+ state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
+ getUtils().writeAttribute(writer, "id","row_" + state.getColumnType() + ":" + index);
+ getUtils().writeAttribute(writer, "class","ClientUI_Grid_BR");
+ ColumnWalker.iterateOverCells(context, grid, cellRenderer, writer, state);
+ }
+
writer.endElement(HTML.TR_ELEMENT);
}
};
+
+ private final ColumnVisitor ajaxCellRenderer = new ColumnVisitor(){
+ public void visit(FacesContext context, UIScrollableGridColumn column, ResponseWriter writer, GridRendererState state) throws IOException {
+
+ writer.startElement(HTML.SPAN_ELEM, column);
+ String cell_index = state.getCellIdPrefix() + ":" + state.getRowIndex()+":" + state.getCellIndex();
+ getUtils().writeAttribute(writer, "id",cell_index);
+ renderChildren(context, column);
+ writer.endElement(HTML.SPAN_ELEM);
+ AjaxContext ajaxContext = state.getAjaxContext();
+ ajaxContext.addRenderedArea(cell_index);
+
+ }
+ };
+
+ private final DataVisitor ajaxRowsRenderer = new DataVisitor(){
+
+ public void process(FacesContext context, Object rowKey, Object argument) throws IOException {
+
+ GridRendererState state = (GridRendererState)argument;
+ UIScrollableGrid grid = state.getGrid();
+ grid.setRowKey(rowKey);
+ ResponseWriter writer = context.getResponseWriter();
+ state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
+ ColumnWalker.iterateOverAjaxCells(context, grid, ajaxCellRenderer, writer, state);
+ state.nextRow();
+ }
+ };
+
protected String getJavaScriptVarName(FacesContext context, UIScrollableGrid grid) {
String id = grid.getBaseClientId(context);
return "Richfaces_ScrollableGrid_" + id.replaceAll("[^A-Za-z0-9_]", "_");
@@ -134,9 +172,8 @@
final GridRendererState state = GridRendererState.getRendererState(context);
ComponentVariables variables = ComponentsVariableResolver.getVariables(this, component);
-// variables.setVariable("column_count", variable);
- variables.setVariable("rows_count", new Integer(component.getRows()));
-
+// variables.setVariable("rows_count", new Integer(component.getRows()));
+
writer.startElement(HTML.DIV_ELEM, grid);
getUtils().writeAttribute(writer, "class","GridDataColumns");
getUtils().writeAttribute(writer, "id","FrozenBox");
@@ -149,24 +186,11 @@
getUtils().writeAttribute(writer, "style","position: absolute; left: 0px; top: 0px; display: block; width: 100%");
writer.writeText("\n", null);
writer.startElement("tbody", grid);
-// state.setGrid(grid);
+ state.setGrid(grid);
- DataVisitor rowsRenderer = new DataVisitor(){
-
- public void process(FacesContext context, Object rowIndex, Object argument) throws IOException {
-
- int index = ((Integer)rowIndex).intValue();
- grid.setRowKey(rowIndex);
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.TR_ELEMENT, grid);
- getUtils().writeAttribute(writer, "id","row_"+ index);
- getUtils().writeAttribute(writer, "class","ClientUI_Grid_BR");
- ColumnWalker.iterateOverCells(context, grid, cellRenderer, writer, state);
- writer.endElement(HTML.TR_ELEMENT);
- }
- };
- state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
+ state.setFrozenPart(true);
+ state.setColumType(COLUMN_FROZEN_TYPE);
grid.walk(context, rowsRenderer, state);
@@ -186,8 +210,8 @@
getUtils().writeAttribute(writer, "style","position: absolute; left: 0px; top: 0px; display: block; width: 100%");
writer.writeText("\n", null);
- state.setFrozenColumnCount(-1);
-
+ state.setColumType(COLUMN_NORMAL_TYPE);
+ state.setFrozenPart(false);
grid.walk(context, rowsRenderer, state);
writer.endElement("tbody");
writer.endElement("table");
@@ -245,9 +269,10 @@
if(parameters.containsKey(clientId)){
String submitedState = (String)parameters.get(clientId);
String [] values = submitedState.split(",");
- grid.setRow_count(Integer.getInteger(values[0]));
- grid.setDataIndex(Integer.getInteger(values[1]));
- grid.setStartRow(Integer.getInteger(values[2]));
+
+ grid.setRow_count(new Integer(Integer.parseInt(values[0])));
+ grid.setDataIndex(new Integer(Integer.parseInt(values[1])));
+ grid.setStartRow(new Integer(Integer.parseInt(values[2])));
grid.queueEvent(new AjaxEvent(grid));
}
@@ -255,38 +280,32 @@
}
public void renderAjaxChildren(FacesContext context, UIComponent component)throws IOException{
+
UIScrollableGrid grid = (UIScrollableGrid)component;
grid.setFirst(grid.getDataIndex().intValue());
grid.setRows(grid.getRow_count().intValue());
+ int start_row = grid.getStartRow().intValue();
+
GridRendererState state = GridRendererState.getRendererState(context);
- grid.walk(context, rowsRenderer, state);
+ state.setAjaxContext(AjaxContext.getCurrentInstance(context));
+ state.setRowIndex(start_row);
+ state.setFrozenPart(true);
+ state.setCellIdPrefix(CELL_ID_PREFFIX + COLUMN_FROZEN_TYPE);
+ grid.walk(context, ajaxRowsRenderer, state);
+
+ state.setRowIndex(start_row);
+ grid.setFirst(grid.getDataIndex().intValue());
+ grid.setRows(grid.getRow_count().intValue());
+ state.setFrozenPart(false);
+ state.setCellIdPrefix(CELL_ID_PREFFIX + COLUMN_NORMAL_TYPE);
+ grid.walk(context, ajaxRowsRenderer, state);
}
-
-// for benchmark
-// public void encodeBegin(FacesContext context, UIComponent component
-// ) throws IOException {
-//
-// if(AjaxContext.getCurrentInstance().isAjaxRequest()){
-// }else{
-// super.encodeBegin(context, component);
-// }
-// }
-//
-// public void encodeEnd(FacesContext context, UIComponent component
-// ) throws IOException {
-//
-// if(AjaxContext.getCurrentInstance().isAjaxRequest()){
-// }else{
-// super.encodeEnd(context, component);
-// }
-// }
-
public void encodeChildren(FacesContext context, UIComponent component
) throws IOException {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
if(ajaxContext.isAjaxRequest()){
-// renderAjaxChildren(context, component);
+ renderAjaxChildren(context, component);
}else{
super.encodeChildren(context, component);
}
17 years, 8 months
JBoss Rich Faces SVN: r751 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-14 14:05:06 -0400 (Mon, 14 May 2007)
New Revision: 751
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js 2007-05-14 18:04:27 UTC (rev 750)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js 2007-05-14 18:05:06 UTC (rev 751)
@@ -170,6 +170,7 @@
}
}
+ this.getBody().adjustColumnWidth(index, width);
this.updateLayout();
if(ClientUILib.isIE) {
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-14 18:04:27 UTC (rev 750)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-14 18:05:06 UTC (rev 751)
@@ -94,7 +94,7 @@
}
*/
- ClientUILib.log(ClientUILogger.WARNING, "data for "+options.count+" rows loaded over: " + ((new Date()).getTime() - currTime) + " miliseconds.");
+ ClientUILib.log(ClientUILogger.ERROR, "data for "+options.count+" rows loaded over: " + ((new Date()).getTime() - currTime) + " miliseconds.");
ClientUILib.log(ClientUILogger.WARNING, "start index: " + options.index + ", and startRow: " + options.startRow);
ClientUILib.log(ClientUILogger.WARNING, "load data delta time: " + (this.taskStartTime - this.taskDefineTime));
ClientUILib.log(ClientUILogger.WARNING, "data prepare time: " + (this.taskStartLoadingTime - this.taskStartTime));
@@ -187,26 +187,21 @@
templFrozen.rows[i].index = i;
templNormal.rows[i].index = i;
}
+ this.helpObj = new ClientUI.common.box.Box(templFrozen, null, true);
this.countToLoad = 0;
this.startRow = 0;
- this.startIndex = 0;
+ this.startIndex = 0;
+ this.currRange = $R(0,this.rowsCount);
return true;
},
updateColumns: function() {
var width = 0;
var columns = this.grid.getHeader().getColumns();
- for(var i=0; i<columns.lenght; i++) {
- width = columns[i].width;
- if(ClientUILib.isGecko) {
- width -= this.getBorderWidth("lr") + this.getPadding("lr");
- }
- this.adjustColumnWidth(i, width);
+ for(var i=0; i<columns.length; i++) {
+ this.adjustColumnWidth(i, columns[i].width);
}
},
- adjustColumnWidth: function(column, width) {
- // TODO: implement adjustColumnWidth!!!
- },
getColumns: function() {
return this._columns;
},
@@ -544,11 +539,6 @@
task.timer = setTimeout(function() {
this.taskStartTime = (new Date()).getTime();
- // 1. get previous range
- if(!this.currRange) {
- this.currRange = $R(-this.rowsCount,-1);
- }
-
var range = $R(task.from, task.to);
// if we have intersepted ranges than rearrange rows
@@ -571,15 +561,13 @@
this.templNormal.moveToY(pos);
}
else {
- var i, row, rownew;
+ var i, row, rownew, cloned;
this.countToLoad = 0;
- var frozenTbl = this.templFrozen.getElement().tBodies[0];
- var normalTbl = this.templNormal.getElement().tBodies[0];
+ var frozenTbl = this.templFrozen.getElement();
+ var normalTbl = this.templNormal.getElement();
if(range.start > this.currRange.start
&& range.start < this.currRange.end) {
- // TODO: get rows from this.currRange.start to range.start
- // and move them to end of table
- // then move table to correct position
+
this.countToLoad = range.start - this.currRange.start;
this.startRow = frozenTbl.rows[0].index;
@@ -588,14 +576,16 @@
for(i=0; i<this.countToLoad; i++) {
row = frozenTbl.rows[0];
- frozenTbl.deleteRow(row);
+ cloned = row.cloneNode(true);
+ frozenTbl.deleteRow(row.rowIndex);
rownew = frozenTbl.insertRow(this.rowsCount-1);
- rownew.parentNode.replaceChild(row,rownew);
+ rownew.parentNode.replaceChild(cloned,rownew);
row = normalTbl.rows[0];
- normalTbl.deleteRow(row);
+ cloned = row.cloneNode(true);
+ normalTbl.deleteRow(row.rowIndex);
rownew = normalTbl.insertRow(this.rowsCount-1);
- rownew.parentNode.replaceChild(row,rownew);
+ rownew.parentNode.replaceChild(cloned,rownew);
}
this.templFrozen.moveToY(visibleRowPos);
@@ -629,59 +619,49 @@
*/
}
else {
- // TODO: get rows from range.end to this.currRange.end
- // and move them to begin of table
- // then move table to correct position
+ this.countToLoad = this.currRange.start - range.start;
+
+ // store visible row pos to restore after rows reerrange
+ var visibleRowPos = this.templFrozen.getY() - this.countToLoad * this.defaultRowHeight;
+ var frows = [], nrows = [];
+ for(i=this.rowsCount-1; i>=this.rowsCount - this.countToLoad; i--) {
+ row = frozenTbl.rows[i];
+ cloned = row.cloneNode(true);
+ frows.push(cloned);
+ frozenTbl.deleteRow(row.rowIndex);
+
+ row = normalTbl.rows[i];
+ cloned = row.cloneNode(true);
+ nrows.push(cloned);
+ normalTbl.deleteRow(row.rowIndex);
+ }
+
+ for(i=0; i<frows.length; i++) {
+ row = frows[i];
+ rownew = frozenTbl.insertRow(0);
+ rownew.parentNode.replaceChild(row, rownew);
+
+ row = nrows[i];
+ rownew = normalTbl.insertRow(0);
+ rownew.parentNode.replaceChild(row, rownew);
+ }
+
+ this.templFrozen.moveToY(visibleRowPos);
+ this.templNormal.moveToY(visibleRowPos);
+ this.startRow = frozenTbl.rows[0].index;
}
}
-
- /*
- // 1. hide invisible rows
- this.dataViewHash = [];
- var newDataView = [];
- var count = this.dataView.length;
- for(var i=0; i<count; i++) {
- var row = this.dataView[i];
- if(!range.include(row.rowindex)) {
- this.deleteRow(row);
- }
- else {
- this.dataViewHash[row.rowindex] = this.dataView[i];
- newDataView.push(row);
- }
- }
- this.dataView = newDataView;
-
- // 2. show empty rows
- var rowsToLoad = [];
- var rowsToLoadIdx = [];
- var row, i;
- for(i=task.from; i<=task.to; i++) {
- if(!this.dataViewHash[i]) {
- row = this.getRow();
- row.setRowIndex(i);
- row.showEmpty();
- this.dataView.push(row);
- this.dataViewHash[i] = row;
- rowsToLoadIdx.push(i);
- rowsToLoad.push(row.getCellsToUpdate());
- }
- }
this.taskStartLoadingTime = (new Date()).getTime();
+
// 4. start data loading
- this.grid.dataModel.loadRows({
- indexes: rowsToLoadIdx,
- ids: rowsToLoad});
- */
+ if(this.countToLoad > 0) {
+ this.grid.dataModel.loadRows({
+ index: this.startIndex,
+ count: this.countToLoad,
+ startRow: this.startRow});
+ }
- this.taskStartLoadingTime = (new Date()).getTime();
- // 4. start data loading
- this.grid.dataModel.loadRows({
- index: this.startIndex,
- count: this.countToLoad,
- startRow: this.startRow});
-
clearTimeout(task.timer);
task.timer = null;
task.from = 0;
@@ -706,5 +686,36 @@
// this.rowsCount
//this.templFrozen.moveToY(pos);
//this.templNormal.moveToY(pos);
- }
+ },
+ adjustColumnWidth: function(column, width) {
+ var w = width, ch;
+ var frozenColumns = this.templFrozen.getElement().rows[0].cells.length;
+ var realColumn = column;
+ var table = null;
+ if(column < frozenColumns) {
+ table = this.templFrozen.getElement();
+ }
+ else {
+ table = this.templNormal.getElement();
+ realColumn -= frozenColumns;
+ }
+
+ for(var i=0; i<this.rowsCount; i++) {
+ var childs = table.rows[i].cells[realColumn].childNodes;
+ for (var j=0; j<childs.length; j++) {
+ ch = childs[j];
+ if(ch.tagName && ch.tagName.toLowerCase() == "span") {
+
+ w = width;
+ if(ClientUILib.isGecko) {
+ this.helpObj.element = ch.parentNode;
+ w -= this.helpObj.getBorderWidth("lr") + this.helpObj.getPadding("lr");
+ }
+ this.helpObj.element = $(ch);
+ this.helpObj.setWidth(w);
+ break;
+ }
+ }
+ }
+ }
});
17 years, 8 months
JBoss Rich Faces SVN: r750 - trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-14 14:04:27 -0400 (Mon, 14 May 2007)
New Revision: 750
Modified:
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx 2007-05-14 17:59:39 UTC (rev 749)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx 2007-05-14 18:04:27 UTC (rev 750)
@@ -11,8 +11,8 @@
component="javax.faces.component.UIComponent"
>
- <td id="c_#{row_index}_#{cell_index}" class="ClientUI_Grid_BC">
- <span id="bc_#{row_index}_#{cell_index}" style="#{component.attributes['style']}" class="ClientUI_Grid_BCBody">
+ <td id="c_#{cell_index}" class="ClientUI_Grid_BC">
+ <span id="bc_#{cell_index}" style="#{component.attributes['style']}" class="ClientUI_Grid_BCBody">
<vcp:body/>
</span>
</td>
17 years, 8 months
JBoss Rich Faces SVN: r749 - trunk/richfaces/datascroller/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: SergeySmirnov
Date: 2007-05-14 13:59:39 -0400 (Mon, 14 May 2007)
New Revision: 749
Modified:
trunk/richfaces/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
Log:
dup for style and styleClass removed
Modified: trunk/richfaces/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
===================================================================
--- trunk/richfaces/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2007-05-14 14:36:24 UTC (rev 748)
+++ trunk/richfaces/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2007-05-14 17:59:39 UTC (rev 749)
@@ -21,9 +21,8 @@
<![CDATA[org.richfaces.component.util.FormUtil.throwEnclFormReqExceptionIfNeed(context,component);]]>
</jsp:scriptlet>
<div id="#{clientId}"
- x:passThruWithExclusions="value,name,type,id"
- class="dr-dscr rich-datascr #{component.attributes['styleClass']}"
- style="#{component.attributes['style']};">
+ x:passThruWithExclusions="value,name,type,id,styleClass"
+ class="dr-dscr rich-datascr #{component.attributes['styleClass']}">
<table id="#{clientId}_table" align="#{component.attributes['align']}" border="0" cellpadding="0" cellspacing="1" class="dr-dscr-t rich-dtascroller-table #{component.attributes['tableStyleClass']}">
<tbody>
<tr>
17 years, 8 months
JBoss Rich Faces SVN: r747 - trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-05-14 05:44:16 -0400 (Mon, 14 May 2007)
New Revision: 747
Modified:
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
Log:
tests fixed
Modified: trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
===================================================================
--- trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2007-05-14 09:17:50 UTC (rev 746)
+++ trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2007-05-14 09:44:16 UTC (rev 747)
@@ -43,7 +43,7 @@
static {
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
+ javaScripts.add("prototype.js");
javaScripts.add("org.ajax4jsf.framework.resource.SmartPositionScript");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/scriptaculo.js");
17 years, 8 months
JBoss Rich Faces SVN: r746 - trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-05-14 05:17:50 -0400 (Mon, 14 May 2007)
New Revision: 746
Modified:
trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
Log:
tests fixed
Modified: trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
===================================================================
--- trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-05-14 09:13:55 UTC (rev 745)
+++ trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-05-14 09:17:50 UTC (rev 746)
@@ -21,25 +21,9 @@
package org.richfaces.component;
-import java.awt.Dimension;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.html.HtmlCommandLink;
-import javax.faces.component.html.HtmlForm;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
-import javax.faces.el.ValueBinding;
-import javax.servlet.http.HttpServletResponse;
-
+import com.gargoylesoftware.htmlunit.KeyValuePair;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.*;
import org.ajax4jsf.framework.resource.InternetResource;
import org.ajax4jsf.framework.resource.InternetResourceBuilder;
import org.ajax4jsf.framework.resource.Java2Dresource;
@@ -52,17 +36,21 @@
import org.richfaces.renderkit.html.images.buttons.SpinnerButtonDown;
import org.richfaces.renderkit.html.images.buttons.SpinnerButtonUp;
-import com.gargoylesoftware.htmlunit.KeyValuePair;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlInput;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlCommandLink;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.*;
+import java.util.*;
+import java.util.List;
-/**
- * Unit test for simple Component.
- */
+/** Unit test for simple Component. */
public class InputNumberSpinnerComponentTest extends AbstractAjax4JsfTestCase {
private UIForm form = null;
@@ -71,158 +59,179 @@
private static Set javaScripts = new HashSet();
static {
- javaScripts.add("prototype.js");
+ javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org/richfaces/renderkit/html/script/SpinnerScript.js");
+ javaScripts.add("script/SpinnerScript.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/events.js");
}
-
+
/**
* Create the test case
- *
+ *
* @param testName name of the test case
*/
public InputNumberSpinnerComponentTest(String testName) {
- super(testName);
+ super(testName);
}
public void setUp() throws Exception {
- super.setUp();
+ super.setUp();
- form = new HtmlForm();
- facesContext.getViewRoot().getChildren().add(form);
+ form = new HtmlForm();
+ facesContext.getViewRoot().getChildren().add(form);
- command = new HtmlCommandLink();
- command.setId("command");
- form.getChildren().add(command);
-
- spinner = application.createComponent(UIInputNumberSpinner.COMPONENT_TYPE);
- spinner.setId("spinner");
- form.getChildren().add(spinner);
+ command = new HtmlCommandLink();
+ command.setId("command");
+ form.getChildren().add(command);
+
+ spinner = application.createComponent(
+ UIInputNumberSpinner.COMPONENT_TYPE);
+ spinner.setId("spinner");
+ form.getChildren().add(spinner);
}
public void tearDown() throws Exception {
- super.tearDown();
- this.form = null;
- this.spinner = null;
- this.command = null;
+ super.tearDown();
+ this.form = null;
+ this.spinner = null;
+ this.command = null;
}
/**
* Test component renders correctly
- *
+ *
* @throws Exception
*/
public void testComponent() throws Exception {
- HtmlPage renderedView = renderView();
+ HtmlPage renderedView = renderView();
- HtmlElement htmlSpinner = renderedView.getHtmlElementById(spinner.getClientId(facesContext));
+ HtmlElement htmlSpinner = renderedView.getHtmlElementById(
+ spinner.getClientId(facesContext));
- assertNotNull(htmlSpinner);
+ assertNotNull(htmlSpinner);
- assertTrue(htmlSpinner.getAttributeValue("class").contains("dr-spnr-c rich-spinner-c"));
-
- HtmlElement htmlSpinnerEdit = (HtmlElement) renderedView.getHtmlElementById(spinner.getClientId(facesContext) + "Edit");
- assertNotNull(htmlSpinnerEdit);
- assertTrue(htmlSpinnerEdit.getAttributeValue("class").contains("dr-spnr-e rich-spinner-input-container"));
-
- HtmlInput htmlSpinnerInput = (HtmlInput)htmlSpinnerEdit.getLastChild();
- assertNotNull(htmlSpinnerInput);
- assertTrue(htmlSpinnerInput.getAttributeValue("class").contains("dr-spnr-i rich-spinner-input"));
-
- HtmlElement buttonsContainer = (HtmlElement) renderedView.getHtmlElementById(spinner.getClientId(facesContext) + "Buttons");
- assertNotNull(buttonsContainer);
- Collection inputs = buttonsContainer.getHtmlElementsByTagName("input");
- for (Iterator iter = inputs.iterator(); iter.hasNext();){
- HtmlInput child = (HtmlInput)iter.next();
- assertTrue(child.getTypeAttribute().equals("image"));
- assertTrue(child.getAttributeValue("class").contains("dr-spnr-bn rich-spinner-button"));
- }
+ assertTrue(htmlSpinner.getAttributeValue("class").contains(
+ "dr-spnr-c rich-spinner-c"));
+
+ HtmlElement htmlSpinnerEdit = (HtmlElement) renderedView
+ .getHtmlElementById(spinner.getClientId(facesContext) + "Edit");
+ assertNotNull(htmlSpinnerEdit);
+ assertTrue(htmlSpinnerEdit.getAttributeValue("class").contains(
+ "dr-spnr-e rich-spinner-input-container"));
+
+ HtmlInput htmlSpinnerInput = (HtmlInput) htmlSpinnerEdit.getLastChild();
+ assertNotNull(htmlSpinnerInput);
+ assertTrue(htmlSpinnerInput.getAttributeValue("class").contains(
+ "dr-spnr-i rich-spinner-input"));
+
+ HtmlElement buttonsContainer = (HtmlElement) renderedView
+ .getHtmlElementById(spinner.getClientId(facesContext)
+ + "Buttons");
+ assertNotNull(buttonsContainer);
+ Collection inputs = buttonsContainer.getHtmlElementsByTagName("input");
+ for (Iterator iter = inputs.iterator(); iter.hasNext();) {
+ HtmlInput child = (HtmlInput) iter.next();
+ assertTrue(child.getTypeAttribute().equals("image"));
+ assertTrue(child.getAttributeValue("class").contains(
+ "dr-spnr-bn rich-spinner-button"));
+ }
}
-
+
public void testDisabledComponent() throws Exception {
- spinner.getAttributes().put("disabled", Boolean.TRUE);
- HtmlPage renderedView = renderView();
-
- HtmlElement buttonsContainer = (HtmlElement) renderedView.getHtmlElementById(spinner.getClientId(facesContext) + "Buttons");
- assertNotNull(buttonsContainer);
- Collection inputs = buttonsContainer.getHtmlElementsByTagName("input");
- for (Iterator iter = inputs.iterator(); iter.hasNext();){
- HtmlInput child = (HtmlInput)iter.next();
- assertTrue(child.getAttributeValue("onmouseup").equals(""));
- }
+ spinner.getAttributes().put("disabled", Boolean.TRUE);
+ HtmlPage renderedView = renderView();
+
+ HtmlElement buttonsContainer = (HtmlElement) renderedView
+ .getHtmlElementById(spinner.getClientId(facesContext)
+ + "Buttons");
+ assertNotNull(buttonsContainer);
+ Collection inputs = buttonsContainer.getHtmlElementsByTagName("input");
+ for (Iterator iter = inputs.iterator(); iter.hasNext();) {
+ HtmlInput child = (HtmlInput) iter.next();
+ assertTrue(child.getAttributeValue("onmouseup").equals(""));
+ }
}
-
+
public void testImages() throws Exception {
- InternetResource image = InternetResourceBuilder.getInstance().createResource(null, SpinnerFieldGradient.class.getName());
- Dimension imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
- assertTrue( imageDim.getWidth() == 30 && imageDim.getHeight() == 50);
-
- image = InternetResourceBuilder.getInstance().createResource(null, SpinnerButtonGradient.class.getName());
- imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
- assertTrue( imageDim.getWidth() == 30 && imageDim.getHeight() == 50);
+ InternetResource image = InternetResourceBuilder.getInstance()
+ .createResource(null, SpinnerFieldGradient.class.getName());
+ Dimension imageDim = ((Java2Dresource) image).getDimensions(
+ facesContext, null);
+ assertTrue(imageDim.getWidth() == 30 && imageDim.getHeight() == 50);
- image = InternetResourceBuilder.getInstance().createResource(null, SpinnerButtonDown.class.getName());
- imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
- assertTrue( imageDim.getWidth() == 14 && imageDim.getHeight() == 7);
+ image = InternetResourceBuilder.getInstance().createResource(null,
+ SpinnerButtonGradient.class.getName());
+ imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
+ assertTrue(imageDim.getWidth() == 30 && imageDim.getHeight() == 50);
- image = InternetResourceBuilder.getInstance().createResource(null, SpinnerButtonUp.class.getName());
- imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
- assertTrue( imageDim.getWidth() == 14 && imageDim.getHeight() == 7);
+ image = InternetResourceBuilder.getInstance().createResource(null,
+ SpinnerButtonDown.class.getName());
+ imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
+ assertTrue(imageDim.getWidth() == 14 && imageDim.getHeight() == 7);
+
+ image = InternetResourceBuilder.getInstance().createResource(null,
+ SpinnerButtonUp.class.getName());
+ imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
+ assertTrue(imageDim.getWidth() == 14 && imageDim.getHeight() == 7);
}
-
+
public void testRenderImages() throws Exception {
- renderView();
- InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
- InternetResource resource = builder.getResource("org/richfaces/renderkit/html/css/spinner.xcss");
- assertNotNull(resource);
- String uri = "http:" + resource.getUri(facesContext, null);
- Page page = webClient.getPage(uri);
- assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
+ renderView();
+ InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
+ InternetResource resource = builder.getResource("css/spinner.xcss");
+ assertNotNull(resource);
+ String uri = "http:" + resource.getUri(facesContext, null);
+ Page page = webClient.getPage(uri);
+ assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse
+ .SC_OK);
- String[] resources = new String[] {
- SpinnerButtonGradient.class.getName(),
- SpinnerFieldGradient.class.getName(),
- SpinnerButtonDown.class.getName(),
- SpinnerButtonUp.class.getName()
- };
-
- for (int i = 0; i < resources.length; i++) {
- resource = builder.getResource(resources[i]);
- assertNotNull(resource);
- uri = "http:" + resource.getUri(facesContext, null);
- page = webClient.getPage(uri);
- assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
- ImageInfo info = new ImageInfo();
- info.setInput(page.getWebResponse().getContentAsStream());
- //image recognizable?
- assertTrue(info.check());
- assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
- }
+ String[] resources = new String[]{
+ SpinnerButtonGradient.class.getName(),
+ SpinnerFieldGradient.class.getName(),
+ SpinnerButtonDown.class.getName(),
+ SpinnerButtonUp.class.getName()
+ };
+
+ for (int i = 0; i < resources.length; i++) {
+ resource = builder.getResource(resources[i]);
+ assertNotNull(resource);
+ uri = "http:" + resource.getUri(facesContext, null);
+ page = webClient.getPage(uri);
+ assertTrue(page.getWebResponse().getStatusCode()
+ == HttpServletResponse.SC_OK);
+ ImageInfo info = new ImageInfo();
+ info.setInput(page.getWebResponse().getContentAsStream());
+ //image recognizable?
+ assertTrue(info.check());
+ assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
+ }
}
-
+
public void testRenderStyle() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
List links = page.getDocumentElement().getHtmlElementsByTagName("link");
assertEquals(1, links.size());
HtmlElement link = (HtmlElement) links.get(0);
- assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/spinner.xcss"));
+ assertTrue(link.getAttributeValue("href").contains(
+ "css/spinner.xcss"));
}
public void testRenderScript() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List scripts = page.getDocumentElement().getHtmlElementsByTagName("script");
+ List scripts = page.getDocumentElement().getHtmlElementsByTagName(
+ "script");
for (Iterator it = scripts.iterator(); it.hasNext();) {
HtmlScript item = (HtmlScript) it.next();
String srcAttr = item.getSrcAttribute();
if (StringUtils.isNotBlank(srcAttr)) {
boolean found = false;
- for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
+ for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();)
+ {
String src = (String) srcIt.next();
found = srcAttr.contains(src);
@@ -237,98 +246,120 @@
}
public void testUpdate() throws Exception {
- //tests if component handles value bindings correctly
- HtmlPage renderedView = renderView();
-
- String value = "66";
-
- HtmlElement inputContainer = (HtmlElement) renderedView.getHtmlElementById(spinner.getClientId(facesContext)+"Edit");
- HtmlInput htmlSliderInput = (HtmlInput) inputContainer.getLastChild();
- htmlSliderInput.setValueAttribute(value);
-
- HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
- htmlLink.click();
+ //tests if component handles value bindings correctly
+ HtmlPage renderedView = renderView();
- List lastParameters = this.webConnection.getLastParameters();
- for (Iterator iterator = lastParameters.iterator(); iterator.hasNext();) {
- KeyValuePair keyValue = (KeyValuePair) iterator.next();
-
- externalContext.addRequestParameterMap((String) keyValue.getKey(), (String) keyValue.getValue());
- }
+ String value = "66";
- UIViewRoot root = facesContext.getViewRoot();
- root.processDecodes(facesContext);
- root.processValidators(facesContext);
- root.processUpdates(facesContext);
- root.processApplication(facesContext);
-
- renderedView = renderView();
- assertTrue( value.equals(((UIInputNumberSpinner)spinner).getValue()) );
+ HtmlElement inputContainer = (HtmlElement) renderedView
+ .getHtmlElementById(spinner.getClientId(facesContext) + "Edit");
+ HtmlInput htmlSliderInput = (HtmlInput) inputContainer.getLastChild();
+ htmlSliderInput.setValueAttribute(value);
+
+ HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(
+ command.getClientId(facesContext));
+ htmlLink.click();
+
+ List lastParameters = this.webConnection.getLastParameters();
+ for (Iterator iterator = lastParameters.iterator(); iterator.hasNext();)
+ {
+ KeyValuePair keyValue = (KeyValuePair) iterator.next();
+
+ externalContext.addRequestParameterMap((String) keyValue.getKey(),
+ (String) keyValue.getValue());
+ }
+
+ externalContext.addRequestParameterMap(spinner.getClientId(
+ facesContext), value);
+
+ spinner.processDecodes(facesContext);
+ spinner.processValidators(facesContext);
+ spinner.processUpdates(facesContext);
+
+ renderedView = renderView();
+ assertTrue(value.equals(((UIInputNumberSpinner) spinner).getValue()));
}
-
- public void testDecode() throws Exception{
- //Tests if component accepts request parameters and stores them in submittedValue().
- //If component is immediate, validation (possibly with conversion) should occur on that phase.
- final SpinnerBean bean = new SpinnerBean();
- ((UIInputNumberSpinner)spinner).setValueBinding("value",
- new ValueBinding() {
- public Class getType(FacesContext context) throws EvaluationException, PropertyNotFoundException {
- return String.class;
- }
- public Object getValue(FacesContext context) throws EvaluationException, PropertyNotFoundException {
- return bean.getValue();
- }
- public boolean isReadOnly(FacesContext context) throws EvaluationException, PropertyNotFoundException {
- return false;
- }
- public void setValue(FacesContext context, Object value) throws EvaluationException, PropertyNotFoundException {
- bean.setValue((String)value);
- }
- });
- HtmlPage renderedView = renderView();
- HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
- htmlLink.click();
- externalContext.addRequestParameterMap(spinner.getClientId(facesContext),"66");
- spinner.processDecodes(facesContext);
- assertTrue(bean.getValue().equals("66"));
-
- ((UIInputNumberSpinner)spinner).setImmediate(true);
- renderedView = renderView();
- htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
- htmlLink.click();
- externalContext.addRequestParameterMap(spinner.getClientId(facesContext),"wrong value");
- spinner.processDecodes(facesContext);
- assertTrue(facesContext.getMessages().hasNext());
+
+ public void testDecode() throws Exception {
+ //Tests if component accepts request parameters and stores them in submittedValue().
+ //If component is immediate, validation (possibly with conversion) should occur on that phase.
+ final SpinnerBean bean = new SpinnerBean();
+ ((UIInputNumberSpinner) spinner).setValueBinding("value",
+ new ValueBinding() {
+ public Class getType(FacesContext context) throws
+ EvaluationException,
+ PropertyNotFoundException {
+ return String.class;
+ }
+
+ public Object getValue(FacesContext context) throws
+ EvaluationException,
+ PropertyNotFoundException {
+ return bean.getValue();
+ }
+
+ public boolean isReadOnly(FacesContext context) throws
+ EvaluationException,
+ PropertyNotFoundException {
+ return false;
+ }
+
+ public void setValue(FacesContext context, Object value)
+ throws EvaluationException,
+ PropertyNotFoundException {
+ bean.setValue((String) value);
+ }
+ });
+ HtmlPage renderedView = renderView();
+ HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(
+ command.getClientId(facesContext));
+ htmlLink.click();
+ externalContext.addRequestParameterMap(spinner.getClientId(
+ facesContext), "66");
+ spinner.processDecodes(facesContext);
+ assertTrue(bean.getValue().equals("66"));
+
+ ((UIInputNumberSpinner) spinner).setImmediate(true);
+ renderedView = renderView();
+ htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(
+ command.getClientId(facesContext));
+ htmlLink.click();
+ externalContext.addRequestParameterMap(spinner.getClientId(
+ facesContext), "wrong value");
+ spinner.processDecodes(facesContext);
+ assertTrue(facesContext.getMessages().hasNext());
}
-
- public void testValidate() throws Exception{
- HtmlPage renderedView = renderView();
- HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
- htmlLink.click();
- externalContext.addRequestParameterMap(spinner.getClientId(facesContext),"wrong value");
- spinner.processDecodes(facesContext);
- spinner.processValidators(facesContext);
-
- assertTrue(facesContext.getMessages().hasNext());
-
+ public void testValidate() throws Exception {
+ HtmlPage renderedView = renderView();
+
+ HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(
+ command.getClientId(facesContext));
+ htmlLink.click();
+ externalContext.addRequestParameterMap(spinner.getClientId(
+ facesContext), "wrong value");
+ spinner.processDecodes(facesContext);
+ spinner.processValidators(facesContext);
+
+ assertTrue(facesContext.getMessages().hasNext());
+
}
-
- private class SpinnerBean {
-
- private String value;
-
- SpinnerBean (){
- this.value = "66";
- }
- public String getValue() {
- return value;
- }
+ private class SpinnerBean {
- public void setValue(String value) {
- this.value = value;
- }
-
+ private String value;
+
+ SpinnerBean() {
+ this.value = "66";
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
}
}
17 years, 8 months