Author: nbelaevski
Date: 2010-05-25 14:17:01 -0400 (Tue, 25 May 2010)
New Revision: 17238
Removed:
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java
Modified:
root/core/trunk/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java
Log:
https://jira.jboss.org/browse/RF-8682
Deleted: root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2010-05-25
18:10:36 UTC (rev 17237)
+++
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueBinding.java 2010-05-25
18:17:01 UTC (rev 17238)
@@ -1,197 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.component;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
-import javax.faces.el.ValueBinding;
-
-/**
- * Inner class for build event string for parent component.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:38 $ Disadvantages -
- * not rebuild event string setted as EL expression. TODO - save
- * expressions for build event string at render phase.
- */
-public class EventValueBinding extends ValueBinding implements StateHolder {
- private static final long serialVersionUID = -6583167387542332290L;
-
- /**
- * current update component. transient since saved state as component.
- */
- private transient AjaxSupport component = null;
- private String componentId;
-
- /**
- * Default constructor for restoreState.
- */
- public EventValueBinding() {
- }
-
- /**
- * Constructor for build from AjaxComponent.
- *
- * @param update
- */
- public EventValueBinding(AjaxSupport update) {
- component = update;
-
- // _componentId = string;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getType(javax.faces.context.FacesContext)
- */
- @Override
- public Class getType(FacesContext facesContext) throws EvaluationException,
PropertyNotFoundException {
- return String.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getValue(javax.faces.context.FacesContext)
- */
- @Override
- public Object getValue(FacesContext facesContext) throws EvaluationException,
PropertyNotFoundException {
- if (((UIComponent) getComponent(facesContext)).isRendered()) {
- return getComponent(facesContext).getEventString();
- } else {
- return null;
- }
- }
-
- private AjaxSupport getComponent(FacesContext facesContext) throws
EvaluationException {
- if (component == null) {
- UIComponent uiComponent =
facesContext.getViewRoot().findComponent(componentId);
-
- if ((null != uiComponent) && (uiComponent instanceof AjaxSupport)) {
- component = (AjaxSupport) uiComponent;
- } else {
- throw new
EvaluationException(Messages.getMessage(Messages.COMPONENT_NOT_FOUND, componentId));
- }
- }
-
- return component;
- }
-
- /**
- * @param component the component to set
- */
- public void setComponent(AjaxSupport component) {
- this.component = component;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#isReadOnly(javax.faces.context.FacesContext)
- */
- @Override
- public boolean isReadOnly(FacesContext facesContext) throws EvaluationException,
PropertyNotFoundException {
-
- // TODO Auto-generated method stub
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#setValue(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- @Override
- public void setValue(FacesContext facesContext, Object value)
- throws EvaluationException, PropertyNotFoundException {
-
- throw new EvaluationException(Messages.getMessage(Messages.EVENT_IS_READ_ONLY));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- if (null == component) {
- return componentId;
- } else {
- return AjaxRendererUtils.getAbsoluteId((UIComponent) getComponent(context));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
-
- // TODO Auto-generated method stub
- componentId = (String) state;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#isTransient()
- */
- public boolean isTransient() {
-
- // TODO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.StateHolder#setTransient(boolean)
- */
- public void setTransient(boolean newTransientValue) {
-
- // TODO Auto-generated method stub
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.el.ValueBinding#getExpressionString()
- */
- @Override
- public String getExpressionString() {
-
- // FacesContext context = FacesContext.getCurrentInstance();
- // UIComponent component = (UIComponent) getComponent(context);
- // return
"#{ajaxSupport["+component.getClientId(context)+"]}";
- return null;
- }
-}
Deleted:
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java 2010-05-25
18:10:36 UTC (rev 17237)
+++
root/core/trunk/impl/src/main/java/org/ajax4jsf/component/EventValueExpression.java 2010-05-25
18:17:01 UTC (rev 17238)
@@ -1,207 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.component;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Maksim Kaszynski
- */
-public class EventValueExpression extends ValueExpression implements StateHolder {
- private static final long serialVersionUID = -6583167387542332290L;
-
- /**
- * current update component. transient since saved state as component.
- */
- private transient AjaxSupport component = null;
- private String componentId;
-
- public EventValueExpression() {
-
- // TODO Auto-generated constructor stub
- }
-
- public EventValueExpression(AjaxSupport component) {
- super();
- this.component = component;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.Expression#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
-
- // TODO Auto-generated method stub
- return false;
- }
-
- private AjaxSupport getComponent(FacesContext facesContext) throws ELException {
- if (component == null) {
- UIComponent uiComponent =
facesContext.getViewRoot().findComponent(componentId);
-
- if ((null != uiComponent) && (uiComponent instanceof AjaxSupport)) {
- component = (AjaxSupport) uiComponent;
- } else {
- throw new ELException(Messages.getMessage(Messages.COMPONENT_NOT_FOUND,
componentId));
- }
- }
-
- return component;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#getExpectedType()
- */
- @Override
- public Class<?> getExpectedType() {
- return String.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.Expression#getExpressionString()
- */
- @Override
- public String getExpressionString() {
-
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#getType(javax.el.ELContext)
- */
- @Override
- public Class<?> getType(ELContext context) {
- return String.class;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#getValue(javax.el.ELContext)
- */
- @Override
- public Object getValue(ELContext context) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- AjaxSupport component = getComponent(facesContext);
-
- if (((UIComponent) component).isRendered()) {
- return component.getEventString();
- } else {
- return null;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.Expression#hashCode()
- */
- @Override
- public int hashCode() {
-
- // TODO Auto-generated method stub
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.Expression#isLiteralText()
- */
- @Override
- public boolean isLiteralText() {
-
- // TODO Auto-generated method stub
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
- */
- @Override
- public boolean isReadOnly(ELContext context) {
- return true;
- }
-
- public boolean isTransient() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
- * java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- componentId = (String) state;
- }
-
- public Object saveState(FacesContext context) {
- if (null == component) {
- return componentId;
- } else {
- return AjaxRendererUtils.getAbsoluteId((UIComponent) getComponent(context));
- }
- }
-
- /**
- * @param component the component to set
- */
- public void setComponent(AjaxSupport component) {
- this.component = component;
- }
-
- public void setTransient(boolean newTransientValue) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.el.ValueExpression#setValue(javax.el.ELContext,
- * java.lang.Object)
- */
- @Override
- public void setValue(ELContext context, Object value) {
- throw new ELException(Messages.getMessage(Messages.EVENT_IS_READ_ONLY));
- }
-}
Modified:
root/core/trunk/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java
===================================================================
---
root/core/trunk/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java 2010-05-25
18:10:36 UTC (rev 17237)
+++
root/core/trunk/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java 2010-05-25
18:17:01 UTC (rev 17238)
@@ -44,9 +44,7 @@
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.application.Application;
-import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIData;
import javax.faces.component.UIForm;
import javax.faces.component.UIOutput;
import javax.faces.component.UIViewRoot;
@@ -66,29 +64,30 @@
/**
* Tested view structure:
+ * <ul>
+ * <li>a4j:table is AjaxTableComponentImpl</li>
+ * </ul>
* <pre>
* <h:form id="myForm">
* <a4j:outputText id="outerOutput" />
*
- * <h:dataTable id="table" var="item"
value="['Item 0',... ,'Item 1']">
+ * <a4j:table id="table" var="item"
value="['Item 0',... ,'Item 1']">
* <f:facet name="header">
* <h:outputText id="theHeader" />
* </f:facet>
*
- * <h:column id="col">
- * <a4j:outputText id="nestedOutput"
value="#{item}" />
+ * <a4j:outputText id="nestedOutput"
value="#{item}" />
*
- * <h:outputText id="nestedText"
value="#{item}" />
+ * <h:outputText id="nestedText"
value="#{item}" />
*
- * <a4j:table id="nestedTable"
value="['Nested item 0',... ,'Nested item 2']"
var="nestedItem">
- * <f:facet name="footer">
- * <h:outputText id="nestedTableFooter"
value="#{item}" />
- * </f:facet>
+ * <a4j:table id="nestedTable"
value="['Nested item 0',... ,'Nested item 2']"
var="nestedItem">
+ * <f:facet name="footer">
+ * <h:outputText id="nestedTableFooter"
value="#{item}" />
+ * </f:facet>
*
- * <h:outputText id="nestedTableText"
value="#{nestedItem}" />
- * </a4j:table>
- * </h:column>
- * </h:dataTable>
+ * <h:outputText id="nestedTableText"
value="#{nestedItem}" />
+ * </a4j:table>
+ * </a4j:table>
* </h:form>
* </pre>
*
@@ -136,10 +135,8 @@
private AjaxOutputComponentImpl outerOutput;
- private UIData table;
+ private AjaxTableComponentImpl table;
- private UIColumn column;
-
private UIOutput dataHeader;
private AjaxOutputComponentImpl nestedOutput;
@@ -223,7 +220,7 @@
nestedText.setId("nestedText");
nestedText.setValueExpression("value",
createTableVarValueExpression());
- column.getChildren().add(nestedText);
+ table.getChildren().add(nestedText);
}
private void createNestedOutput() {
@@ -232,7 +229,7 @@
nestedOutput.setId("nestedOutput");
nestedOutput.setValueExpression("value",
createTableVarValueExpression());
- column.getChildren().add(nestedOutput);
+ table.getChildren().add(nestedOutput);
}
private void createOuterOutput() {
@@ -250,16 +247,6 @@
table.getFacets().put("header", dataHeader);
}
- private void createTableColumn() {
- column = (UIColumn) application.createComponent(UIColumn.COMPONENT_TYPE);
- column.setId("col");
-
- table.getChildren().add(column);
- createNestedOutput();
- createNestedText();
- createNestedTable();
- }
-
private void createNestedTable() {
nestedTable = new AjaxTableComponentImpl();
nestedTable.setId("nestedTable");
@@ -268,7 +255,7 @@
createNestedTableData();
nestedTable.setValue(nestedTableData);
- column.getChildren().add(nestedTable);
+ table.getChildren().add(nestedTable);
createNestedTableText();
createNestedTableFooter();
@@ -291,7 +278,7 @@
}
private void createTable() {
- table = (UIData) application.createComponent(UIData.COMPONENT_TYPE);
+ table = new AjaxTableComponentImpl();
table.setId("table");
table.setVar("item");
@@ -299,7 +286,9 @@
table.setValue(tableData);
form.getChildren().add(table);
- createTableColumn();
+ createNestedOutput();
+ createNestedText();
+ createNestedTable();
createTableHeader();
}
@@ -343,7 +332,6 @@
facesContext = null;
application = null;
- column = null;
table = null;
dataHeader = null;
form = null;
@@ -490,7 +478,7 @@
assertEqualSets(tableClientIds, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(tableIds, renderingContext.getDirectSubtreeIdsToVisit(table));
- table.setRowIndex(0);
+ table.setRowKey(Integer.valueOf(0));
Set<String> nestedTableClientIds =
asSet("myForm:table:0:nestedTable:1",
"myForm:table:0:nestedTable:nestedFooter");
@@ -499,7 +487,7 @@
assertEqualSets(nestedTableClientIds,
renderingContext.getSubtreeIdsToVisit(nestedTable));
assertEqualSets(nestedTableIds,
renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
- table.setRowIndex(-1);
+ table.setRowKey(null);
}
@Test
@@ -515,7 +503,7 @@
assertSame(VisitContext.ALL_IDS,
renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowIndex(i);
+ table.setRowKey(Integer.valueOf(i));
assertSame(VisitContext.ALL_IDS,
renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedText", "nestedTable",
"nestedOutput"),
@@ -525,7 +513,7 @@
assertEqualSets(asSet("0"),
renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
}
- table.setRowIndex(-1);
+ table.setRowKey(null);
}
@Test
@@ -541,7 +529,7 @@
assertSame(VisitContext.ALL_IDS,
renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowIndex(i);
+ table.setRowKey(Integer.valueOf(i));
assertSame(VisitContext.ALL_IDS,
renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedText", "nestedTable"),
renderingContext.getDirectSubtreeIdsToVisit(table));
@@ -550,7 +538,7 @@
assertEqualSets(asSet("0"),
renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
}
- table.setRowIndex(-1);
+ table.setRowKey(null);
}
@Test
@@ -565,7 +553,7 @@
assertSame(VisitContext.ALL_IDS,
renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowIndex(i);
+ table.setRowKey(Integer.valueOf(i));
assertSame(VisitContext.ALL_IDS,
renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedTable"),
renderingContext.getDirectSubtreeIdsToVisit(table));
@@ -574,7 +562,7 @@
assertTrue(renderingContext.getDirectSubtreeIdsToVisit(nestedTable).isEmpty());
}
- table.setRowIndex(-1);
+ table.setRowKey(null);
}
@Test