JBoss Rich Faces SVN: r318 - in trunk/richfaces-samples: richfaces-art-datatable and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: SergeySmirnov
Date: 2007-04-06 14:53:28 -0400 (Fri, 06 Apr 2007)
New Revision: 318
Added:
trunk/richfaces-samples/richfaces-art-datatable/
Log:
richfaces datatable article example
Property changes on: trunk/richfaces-samples/richfaces-art-datatable
___________________________________________________________________
Name: svn:ignore
+ target
.classpath
.project
19 years
JBoss Rich Faces SVN: r317 - in trunk/richfaces: inputnumber-spinner/src/test/java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-04-06 14:36:37 -0400 (Fri, 06 Apr 2007)
New Revision: 317
Modified:
trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
Log:
Java 5 elements removed
Modified: trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
===================================================================
--- trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-04-06 17:05:52 UTC (rev 316)
+++ trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-04-06 18:36:37 UTC (rev 317)
@@ -47,7 +47,6 @@
/**
* Unit test for simple Component.
*/
-@SuppressWarnings("unchecked")
public class InputNumberSliderComponentTest extends AbstractAjax4JsfTestCase {
private UIForm form = null;
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-04-06 17:05:52 UTC (rev 316)
+++ trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-04-06 18:36:37 UTC (rev 317)
@@ -47,7 +47,6 @@
/**
* Unit test for simple Component.
*/
-@SuppressWarnings("unchecked")
public class InputNumberSpinnerComponentTest extends AbstractAjax4JsfTestCase {
private UIForm form = null;
@@ -119,7 +118,7 @@
HtmlElement buttonsContainer = (HtmlElement) renderedView.getHtmlElementById(spinner.getClientId(facesContext) + "Buttons");
assertNotNull(buttonsContainer);
- Collection<HtmlInput> inputs = buttonsContainer.getHtmlElementsByTagName("input");
+ Collection inputs = buttonsContainer.getHtmlElementsByTagName("input");
for (Iterator iter = inputs.iterator(); iter.hasNext();){
HtmlInput child = (HtmlInput)iter.next();
assertTrue(child.getTypeAttribute().equals("image"));
19 years
JBoss Rich Faces SVN: r316 - in trunk/richfaces/tree/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-04-06 13:05:52 -0400 (Fri, 06 Apr 2007)
New Revision: 316
Added:
trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeRequestDataModel.java
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
Log:
http://jira.jboss.com/jira/browse/RF-76 fixed.
- CacheableTreeRequestDataModel class added
- Method resetSub() implemented in CacheableTreeDataModel to re-read children state
- Methods getTreeNode(Object key) & getRowData(Object key) implemented in UITree to read data by key
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java 2007-04-06 16:48:21 UTC (rev 315)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java 2007-04-06 17:05:52 UTC (rev 316)
@@ -22,7 +22,7 @@
package org.richfaces.component;
import java.io.IOException;
-import java.util.HashSet;
+import java.util.Iterator;
import javax.faces.component.StateHolder;
import javax.faces.context.FacesContext;
@@ -47,11 +47,6 @@
public void process(FacesContext context, Object rowKey, Object argument)
throws IOException {
treeDataModel.setRowKey(rowKey);
- if (!treeDataModel.isLeaf()) {
- leafSet.add(rowKey);
- } else {
- leafSet.remove(rowKey);
- }
locateTreeNode((TreeRowKey) rowKey, true).setData(
treeDataModel.getRowData());
if (visitor != null) {
@@ -75,15 +70,26 @@
}
private TreeDataModel treeDataModel;
- private HashSet leafSet = new HashSet();
public boolean isLeaf() {
- return !leafSet.contains(getRowKey());
+ TreeRowKey rowKey = (TreeRowKey) getRowKey();
+ TreeNode treeNode = locateTreeNode(rowKey);
+ if (treeNode != null && !treeNode.isLeaf()) {
+ return false;
+ }
+
+ treeNode = treeDataModel.locateTreeNode(rowKey);
+ if (treeNode != null) {
+ return treeNode.isLeaf();
+ }
+
+ return false;
}
- public CacheableTreeDataModel() {
+ public CacheableTreeDataModel(TreeDataModel model) {
super();
setWrappedData(new TreeNodeImpl());
+ setTreeDataModel(model);
}
public void walkModel(FacesContext context, DataVisitor visitor,
@@ -96,6 +102,10 @@
public void setTreeDataModel(TreeDataModel treeDataModel) {
this.treeDataModel = treeDataModel;
}
+
+ public TreeDataModel getTreeDataModel() {
+ return treeDataModel;
+ }
public void walk(FacesContext context, final DataVisitor dataVisitor,
Range range, TreeRowKey rowKey, Object argument, boolean last)
@@ -120,13 +130,11 @@
public void restoreState(FacesContext context, Object state) {
Object[] _state = (Object[]) state;
setWrappedData(_state[0]);
- leafSet = (HashSet) _state[1];
}
public Object saveState(FacesContext context) {
- Object[] state = new Object[2];
+ Object[] state = new Object[1];
state[0] = getWrappedData();
- state[1] = leafSet;
return state;
}
@@ -137,4 +145,10 @@
}
}
+ public void resetSub(TreeRowKey key) {
+ TreeNode node = locateTreeNode(key);
+ for (Iterator iterator = node.getChildren(); iterator.hasNext();) {
+ iterator.remove();
+ }
+ }
}
Added: trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeRequestDataModel.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeRequestDataModel.java (rev 0)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeRequestDataModel.java 2007-04-06 17:05:52 UTC (rev 316)
@@ -0,0 +1,47 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * 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.richfaces.component;
+
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 06.04.2007
+ *
+ */
+public class CacheableTreeRequestDataModel extends CacheableTreeDataModel {
+
+ public CacheableTreeRequestDataModel(TreeDataModel model) {
+ super(model);
+ }
+
+ public void resetAll() {
+ throw new IllegalStateException("Should not be called for this class!");
+ }
+
+ public void resetSub(TreeRowKey key) {
+ throw new IllegalStateException("Should not be called for this class!");
+ }
+
+ public boolean isTransient() {
+ return true;
+ }
+}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java 2007-04-06 16:48:21 UTC (rev 315)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java 2007-04-06 17:05:52 UTC (rev 316)
@@ -244,6 +244,14 @@
TreeState state = (TreeState) getComponentState();
+ CacheableTreeDataModel cacheableModel = state.getTreeDataModel();
+ if (cacheableModel != null) {
+ if (cacheableModel.isTransient()) {
+ setExtendedDataModel(cacheableModel.getTreeDataModel());
+ state.setTreeDataModel(null);
+ }
+ }
+
// transfer nodes delayed to open to rendering queue
state.transferQueuedNodes();
// re-set stopInCollapsed to handle AJAX switch type change
@@ -478,14 +486,18 @@
TreeDataModel treeDataModel = new TreeDataModel();
treeDataModel.setWrappedData(this.getValue());
if (stateModel == null) {
- if (!PRESERVE_MODEL_NONE.equals(getPreserveModel())) {
- stateModel = new CacheableTreeDataModel();
- state.setTreeDataModel(stateModel);
+ String preserveModel = getPreserveModel();
+ if (PRESERVE_MODEL_REQUEST.equals(preserveModel)) {
+ stateModel = new CacheableTreeRequestDataModel(treeDataModel);
+ } else if (PRESERVE_MODEL_STATE.equals(preserveModel)) {
+ stateModel = new CacheableTreeDataModel(treeDataModel);
} else {
return treeDataModel;
}
+ } else {
+ stateModel.setTreeDataModel(treeDataModel);
}
- stateModel.setTreeDataModel(treeDataModel);
+
return stateModel;
}
@@ -629,6 +641,40 @@
}
+ /**
+ * Return the data object representing the node data for the contextual row key
+ *
+ * @param rowKey contextual row key
+ * @return data corresponding to the current row key
+ */
+ public Object getRowData(Object rowKey) {
+ Object storedKey = getRowKey();
+ try {
+ setRowKey(rowKey);
+
+ return getRowData();
+ } finally {
+ setRowKey(storedKey);
+ }
+ }
+
+ /**
+ * Return the data object representing the node for the contextual row key
+ *
+ * @param rowKey contextual row key
+ * @return {@link TreeNode} instance corresponding to the current row key
+ */
+ public TreeNode getTreeNode(Object rowKey) {
+ Object storedKey = getRowKey();
+ try {
+ setRowKey(rowKey);
+
+ return getTreeNode();
+ } finally {
+ setRowKey(storedKey);
+ }
+ }
+
private UIOutput createDefaultNodeFaceOutput(FacesContext facesContext) {
UIOutput component = new UIOutput() {
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-04-06 16:48:21 UTC (rev 315)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-04-06 17:05:52 UTC (rev 316)
@@ -41,11 +41,13 @@
import org.ajax4jsf.framework.util.javascript.JSFunction;
import org.ajax4jsf.framework.util.javascript.JSReference;
import org.ajax4jsf.framework.util.javascript.ScriptUtils;
+import org.richfaces.component.CacheableTreeDataModel;
import org.richfaces.component.LastElementAware;
import org.richfaces.component.TreeRowKey;
import org.richfaces.component.UITree;
import org.richfaces.component.UITreeNode;
import org.richfaces.component.nsutils.NSUtils;
+import org.richfaces.component.state.TreeState;
public abstract class TreeRendererBase extends CompositeRenderer {
@@ -296,6 +298,13 @@
final Flag droppedDownToLevelFlag = new Flag();
TreeRowKey rowKey = (TreeRowKey) key;
+
+ TreeState state = (TreeState) input.getComponentState();
+ CacheableTreeDataModel cacheableModel = state.getTreeDataModel();
+ if (cacheableModel != null) {
+ cacheableModel.resetSub(rowKey);
+ }
+
final TreeDataModelEventNavigator levelNavigator = new TreeDataModelEventNavigator(
input, rowKey) {
19 years
JBoss Rich Faces SVN: r315 - trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-06 12:48:21 -0400 (Fri, 06 Apr 2007)
New Revision: 315
Modified:
trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleTogglePanelComponentTest.java
Log:
test updated
Modified: trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleTogglePanelComponentTest.java
===================================================================
--- trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleTogglePanelComponentTest.java 2007-04-06 16:19:41 UTC (rev 314)
+++ trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleTogglePanelComponentTest.java 2007-04-06 16:48:21 UTC (rev 315)
@@ -21,13 +21,18 @@
package org.richfaces.component;
+import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
+import javax.faces.component.UICommand;
import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlCommandLink;
import javax.faces.component.html.HtmlForm;
import java.util.HashSet;
import java.util.Iterator;
@@ -50,8 +55,15 @@
javaScripts.add("org/richfaces/renderkit/html/scripts/simpleTogglePanel.js");
}
- private UISimpleTogglePanel ui;
+ private UISimpleTogglePanel stp1;
+ private UISimpleTogglePanel stp2;
private UIForm form;
+ private UIOutput openMarker1;
+ private UIOutput closeMarker1;
+ private UIOutput openMarker2;
+ private UIOutput closeMarker2;
+ private UICommand command;
+ private UIInput input;
/**
* Create the test case
@@ -72,10 +84,48 @@
form.setId("form");
facesContext.getViewRoot().getChildren().add(form);
- ui = (UISimpleTogglePanel)application.createComponent("org.richfaces.SimpleTogglePanel");
- ui.setId("simpleTogglePanel");
+ stp1 = (UISimpleTogglePanel)application.createComponent("org.richfaces.SimpleTogglePanel");
+ stp1.setId("simpleTogglePanel1");
+ stp1.setOpened(true);
+ stp1.setSwitchType(UISimpleTogglePanel.SERVER_SWITCH_TYPE);
- form.getChildren().add(ui);
+ openMarker1 = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
+ openMarker1.setId("openMarker");
+ openMarker1.setValue("open");
+
+ closeMarker1 = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
+ closeMarker1.setId("closeMarker");
+ closeMarker1.setValue("close");
+
+ stp1.getFacets().put(openMarker1.getId(), openMarker1);
+ stp1.getFacets().put(closeMarker1.getId(), closeMarker1);
+ form.getChildren().add(stp1);
+
+ stp2 = (UISimpleTogglePanel)application.createComponent("org.richfaces.SimpleTogglePanel");
+ stp2.setId("simpleTogglePanel2");
+ stp2.setOpened(false);
+ stp2.setSwitchType(UISimpleTogglePanel.SERVER_SWITCH_TYPE);
+
+ openMarker2 = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
+ openMarker2.setId("openMarker");
+ openMarker2.setValue("open");
+
+ closeMarker2 = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
+ closeMarker2.setId("closeMarker");
+ closeMarker2.setValue("close");
+
+ stp2.getFacets().put(openMarker2.getId(), openMarker2);
+ stp2.getFacets().put(closeMarker2.getId(), closeMarker2);
+ form.getChildren().add(stp2);
+
+ input = (UIInput)application.createComponent(UIInput.COMPONENT_TYPE);
+ input.setValue("");
+ input.setId("opened");
+ stp1.getChildren().add(input);
+
+ command = new HtmlCommandLink();
+ command.setId("command");
+ stp1.getChildren().add(command);
}
/* (non-Javadoc)
@@ -83,8 +133,15 @@
*/
public void tearDown() throws Exception {
super.tearDown();
- ui = null;
+ stp1 = null;
+ stp2 = null;
form = null;
+ openMarker1 = null;
+ closeMarker1 = null;
+ openMarker2 = null;
+ closeMarker2 = null;
+ command = null;
+ input = null;
}
/**
@@ -97,7 +154,7 @@
assertNotNull(page);
System.out.println(page.asXml());
- HtmlElement div1 = page.getHtmlElementById(ui.getClientId(facesContext));
+ HtmlElement div1 = page.getHtmlElementById(stp1.getClientId(facesContext));
assertNotNull(div1);
assertEquals("div", div1.getNodeName());
@@ -105,7 +162,7 @@
assertTrue(classAttr1.contains("dr-stglpnl"));
assertTrue(classAttr1.contains("rich-stglpanel"));
- HtmlElement div2 = page.getHtmlElementById(ui.getClientId(facesContext) + "_header");
+ HtmlDivision div2 = (HtmlDivision)page.getHtmlElementById(stp1.getClientId(facesContext) + "_header");
assertNotNull(div2);
assertEquals("div", div2.getNodeName());
@@ -113,13 +170,29 @@
assertTrue(classAttr2.contains("dr-stglpnl-h"));
assertTrue(classAttr2.contains("rich-stglpanel-header"));
- HtmlElement div3 = page.getHtmlElementById(ui.getClientId(facesContext) + "_switch");
+ HtmlElement div3 = page.getHtmlElementById(stp1.getClientId(facesContext) + "_switch");
assertNotNull(div3);
assertEquals("div", div3.getNodeName());
- HtmlElement div4 = page.getHtmlElementById(ui.getClientId(facesContext) + "_body");
+ HtmlElement div4 = page.getHtmlElementById(stp1.getClientId(facesContext) + "_body");
assertNotNull(div4);
assertEquals("div", div4.getNodeName());
+
+ try {
+ page.getHtmlElementById(openMarker1.getClientId(facesContext));
+ assertTrue(false);
+ } catch(Throwable t) { }
+
+ HtmlElement f1 = page.getHtmlElementById(closeMarker1.getClientId(facesContext));
+ assertNotNull(f1);
+
+ HtmlElement f2 = page.getHtmlElementById(openMarker2.getClientId(facesContext));
+ assertNotNull(f2);
+
+ try {
+ page.getHtmlElementById(closeMarker2.getClientId(facesContext));
+ assertTrue(false);
+ } catch(Throwable t) { }
}
/**
@@ -164,4 +237,25 @@
}
}
}
+
+ /**
+ * Test simpleTogglePanel switch
+ *
+ * @throws Exception
+ */
+ public void testSwitch() throws Exception {
+ assertTrue(stp1.isOpened());
+
+ HtmlPage page = renderView();
+ System.out.println(page.asXml());
+
+ externalContext.addRequestParameterMap(stp1.getClientId(facesContext), "");
+ System.out.println(this.webConnection.getLastParameters());
+
+ stp1.processDecodes(facesContext);
+ stp1.processValidators(facesContext);
+ stp1.processUpdates(facesContext);
+
+ assertFalse(stp1.isOpened());
+ }
}
19 years
JBoss Rich Faces SVN: r314 - trunk/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-06 12:19:41 -0400 (Fri, 06 Apr 2007)
New Revision: 314
Modified:
trunk/richfaces/pom.xml
Log:
change variable cloverLicense to clover.license.path.
Modified: trunk/richfaces/pom.xml
===================================================================
--- trunk/richfaces/pom.xml 2007-04-06 16:17:38 UTC (rev 313)
+++ trunk/richfaces/pom.xml 2007-04-06 16:19:41 UTC (rev 314)
@@ -324,7 +324,7 @@
true
</includesAllSourceRoots>
<licenseLocation>
- ${cloverLicense}
+ ${clover.license.path}
</licenseLocation>
<jdk>1.5</jdk>
</configuration>
@@ -348,7 +348,7 @@
<artifactId>maven-clover-plugin</artifactId>
<!--
<configuration>
- <licenseLocation>${cloverLicense}</licenseLocation>
+ <licenseLocation>${clover.license.path}</licenseLocation>
<jdk>1.5</jdk>
</configuration>
-->
19 years
JBoss Rich Faces SVN: r313 - in trunk/richfaces/inputnumber-slider/src: test/java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: pkotikov
Date: 2007-04-06 12:17:38 -0400 (Fri, 06 Apr 2007)
New Revision: 313
Added:
trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
Removed:
trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/JSFComponentTest.java
Modified:
trunk/richfaces/inputnumber-slider/src/main/java/org/richfaces/component/UIInputNumberSlider.java
Log:
https://xplanner.exadel.com:1443/do/view/task?oid=92998
https://xplanner.exadel.com:1443/do/view/task?oid=92999
Modified: trunk/richfaces/inputnumber-slider/src/main/java/org/richfaces/component/UIInputNumberSlider.java
===================================================================
--- trunk/richfaces/inputnumber-slider/src/main/java/org/richfaces/component/UIInputNumberSlider.java 2007-04-06 16:17:28 UTC (rev 312)
+++ trunk/richfaces/inputnumber-slider/src/main/java/org/richfaces/component/UIInputNumberSlider.java 2007-04-06 16:17:38 UTC (rev 313)
@@ -28,6 +28,6 @@
*/
public abstract class UIInputNumberSlider extends UIRangedNumberInput {
- public static final String COMPONENT_TYPE = "org.richfaces.InputNumberSlider";
+ public static final String COMPONENT_TYPE = "org.richfaces.inputNumberSlider";
}
Copied: trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java (from rev 252, trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/JSFComponentTest.java)
===================================================================
--- trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java (rev 0)
+++ trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-04-06 16:17:38 UTC (rev 313)
@@ -0,0 +1,224 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * 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.richfaces.component;
+
+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 org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+
+import com.gargoylesoftware.htmlunit.KeyValuePair;
+import com.gargoylesoftware.htmlunit.html.DomNode;
+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;
+
+/**
+ * Unit test for simple Component.
+ */
+@SuppressWarnings("unchecked")
+public class InputNumberSliderComponentTest extends AbstractAjax4JsfTestCase {
+
+ private UIForm form = null;
+ private UIComponent slider = null;
+ private UICommand command = null;
+ private static Set javaScripts = new HashSet();
+
+ /**
+ * Create the test case
+ *
+ * @param testName
+ * name of the test case
+ */
+
+ static {
+ javaScripts.add("prototype.js");
+ javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org/richfaces/renderkit/html/script/SliderScript.js");
+ javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
+ javaScripts.add("org/richfaces/renderkit/html/scripts/events.js");
+ }
+
+ public InputNumberSliderComponentTest(String testName) {
+ super(testName);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+ facesContext.getViewRoot().getChildren().add(form);
+
+ command = new HtmlCommandLink();
+ command.setId("command");
+ form.getChildren().add(command);
+
+ slider = application.createComponent(UIInputNumberSlider.COMPONENT_TYPE);
+ slider.setId("slider");
+ form.getChildren().add(slider);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ this.form = null;
+ this.slider = null;
+ this.command = null;
+ }
+
+ /**
+ * Test component renders correctly
+ *
+ * @throws Exception
+ */
+ public void testComponent() throws Exception {
+ HtmlPage renderedView = renderView();
+
+ HtmlElement htmlSlider = renderedView.getHtmlElementById(slider.getClientId(facesContext));
+
+ assertNotNull(htmlSlider);
+
+ assertTrue(htmlSlider.getAttributeValue("class").contains("rich-slider"));
+
+ HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Input");
+
+ assertNotNull(htmlSliderInput);
+
+ if (slider.getAttributes().get("showInput").equals(Boolean.TRUE)) {
+ assertTrue(htmlSliderInput.getClassAttribute().contains("dr-insldr-field rich-inslider-field"));
+ assertTrue(htmlSliderInput.getTypeAttribute().equals("text"));
+ } else {
+ assertTrue(htmlSliderInput.getTypeAttribute().equals("hidden"));
+ }
+
+ DomNode numContainer = htmlSliderInput.getParentNode().getPreviousSibling();
+ assertTrue(((HtmlElement)numContainer).getAttributeValue("class").contains("dr-insldr-right-num rich-inslider-right-num"));
+ assertTrue(((HtmlElement)(numContainer.getPreviousSibling())).getAttributeValue("class").contains("dr-insldr-left-num rich-inslider-left-num"));
+
+ HtmlElement tip = renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Tip");
+ assertTrue(tip.getAttributeValue("class").contains("dr-insldr-tip rich-inslider-tip"));
+
+ HtmlElement handle = renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Handle");
+ assertTrue(handle.getAttributeValue("class").contains("dr-insldr-handler rich-inslider-handler"));
+
+ HtmlElement track = (HtmlElement)tip.getParentNode().getNextSibling();
+ assertTrue(track.getAttributeValue("class").contains("dr-insldr-track rich-inslider-track"));
+
+ }
+
+ 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/slider.xcss"));
+ }
+
+ public void testRenderScript() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ 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();) {
+ String src = (String) srcIt.next();
+
+ found = srcAttr.contains(src);
+ if (found) {
+ break;
+ }
+ }
+
+ assertTrue(found);
+ }
+ }
+ }
+
+ public void testUpdate() throws Exception {
+ //tests if component handles value bindings correctly
+ HtmlPage renderedView = renderView();
+
+ String maxValue = ((UIInputNumberSlider)slider).getMaxValue();
+
+ HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Input");
+ htmlSliderInput.setValueAttribute(maxValue);
+
+ 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());
+ }
+
+ UIViewRoot root = facesContext.getViewRoot();
+ root.processDecodes(facesContext);
+ root.processValidators(facesContext);
+ root.processUpdates(facesContext);
+ root.processApplication(facesContext);
+
+ renderedView = renderView();
+ htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(slider.getClientId(facesContext)+"Input");
+ assertTrue( maxValue.equals(((UIInputNumberSlider)slider).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.
+ HtmlPage renderedView = renderView();
+ HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
+ htmlLink.click();
+ externalContext.addRequestParameterMap(slider.getClientId(facesContext),((UIInputNumberSlider)slider).getMaxValue());
+ UIViewRoot root = facesContext.getViewRoot();
+ root.processDecodes(facesContext);
+ UIInputNumberSlider uiSlider = (UIInputNumberSlider) slider;
+ if (uiSlider.isImmediate()){
+ uiSlider.validate(facesContext);
+ assertTrue(uiSlider.isValid());
+ }
+ assertTrue(externalContext.getRequestParameterMap().get(slider.getClientId(facesContext)).equals(uiSlider.getMaxValue()));
+
+ }
+
+ public void testValidate(){
+ // tests if component is able to handle submittedValue() correctly (convert & validate)
+ }
+
+}
Deleted: trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-06 16:17:28 UTC (rev 312)
+++ trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-06 16:17:38 UTC (rev 313)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * 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.richfaces.component;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
-
-/**
- * Unit test for simple Component.
- */
-public class JSFComponentTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public JSFComponentTest( String testName )
- {
- super( testName );
- }
-
-
- /**
- * Rigourous Test :-)
- */
- public void testComponent()
- {
- assertTrue( true );
- }
-}
19 years
JBoss Rich Faces SVN: r312 - in trunk/richfaces/inputnumber-spinner/src: test/java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: pkotikov
Date: 2007-04-06 12:17:28 -0400 (Fri, 06 Apr 2007)
New Revision: 312
Added:
trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java
Removed:
trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/JSFComponentTest.java
Modified:
trunk/richfaces/inputnumber-spinner/src/main/java/org/richfaces/component/UIInputNumberSpinner.java
Log:
https://xplanner.exadel.com:1443/do/view/task?oid=92998
https://xplanner.exadel.com:1443/do/view/task?oid=92999
Modified: trunk/richfaces/inputnumber-spinner/src/main/java/org/richfaces/component/UIInputNumberSpinner.java
===================================================================
--- trunk/richfaces/inputnumber-spinner/src/main/java/org/richfaces/component/UIInputNumberSpinner.java 2007-04-06 15:21:18 UTC (rev 311)
+++ trunk/richfaces/inputnumber-spinner/src/main/java/org/richfaces/component/UIInputNumberSpinner.java 2007-04-06 16:17:28 UTC (rev 312)
@@ -29,6 +29,6 @@
*/
public abstract class UIInputNumberSpinner extends UIRangedNumberInput {
- public static final String COMPONENT_TYPE = "org.richfaces.InputNumberSpinner";
+ public static final String COMPONENT_TYPE = "org.richfaces.inputNumberSpinner";
}
Copied: trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java (from rev 252, trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/JSFComponentTest.java)
===================================================================
--- trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java (rev 0)
+++ trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/InputNumberSpinnerComponentTest.java 2007-04-06 16:17:28 UTC (rev 312)
@@ -0,0 +1,220 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * 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.richfaces.component;
+
+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 org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+
+import com.gargoylesoftware.htmlunit.KeyValuePair;
+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;
+
+/**
+ * Unit test for simple Component.
+ */
+@SuppressWarnings("unchecked")
+public class InputNumberSpinnerComponentTest extends AbstractAjax4JsfTestCase {
+
+ private UIForm form = null;
+ private UIComponent spinner = null;
+ private UICommand command = null;
+ private static Set javaScripts = new HashSet();
+
+ static {
+ javaScripts.add("prototype.js");
+ javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("org/richfaces/renderkit/html/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);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ 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);
+ }
+
+ public void tearDown() throws Exception {
+ 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();
+
+ HtmlElement htmlSpinner = renderedView.getHtmlElementById(spinner.getClientId(facesContext));
+
+ 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<HtmlInput> 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 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"));
+ }
+
+ public void testRenderScript() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ 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();) {
+ String src = (String) srcIt.next();
+
+ found = srcAttr.contains(src);
+ if (found) {
+ break;
+ }
+ }
+
+ assertTrue(found);
+ }
+ }
+ }
+
+ public void testUpdate() throws Exception {
+ //tests if component handles value bindings correctly
+ HtmlPage renderedView = renderView();
+
+ String maxValue = ((UIInputNumberSpinner)spinner).getMaxValue();
+
+ HtmlElement inputContainer = (HtmlElement) renderedView.getHtmlElementById(spinner.getClientId(facesContext)+"Edit");
+ HtmlInput htmlSliderInput = (HtmlInput) inputContainer.getLastChild();
+ htmlSliderInput.setValueAttribute(maxValue);
+
+ 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());
+ }
+
+ UIViewRoot root = facesContext.getViewRoot();
+ root.processDecodes(facesContext);
+ root.processValidators(facesContext);
+ root.processUpdates(facesContext);
+ root.processApplication(facesContext);
+
+ renderedView = renderView();
+ inputContainer = (HtmlElement) renderedView.getHtmlElementById(spinner.getClientId(facesContext)+"Edit");
+ htmlSliderInput = (HtmlInput) inputContainer.getLastChild();
+ assertTrue( maxValue.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.
+ HtmlPage renderedView = renderView();
+ HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
+ htmlLink.click();
+ externalContext.addRequestParameterMap(spinner.getClientId(facesContext),((UIInputNumberSpinner)spinner).getMaxValue());
+ UIViewRoot root = facesContext.getViewRoot();
+ root.processDecodes(facesContext);
+ UIInputNumberSpinner uiSpinner = (UIInputNumberSpinner) spinner;
+ if (uiSpinner.isImmediate()){
+ uiSpinner.validate(facesContext);
+ assertTrue(uiSpinner.isValid());
+ }
+ assertTrue(externalContext.getRequestParameterMap().get(spinner.getClientId(facesContext)).equals(uiSpinner.getMaxValue()));
+
+ }
+
+ public void testValidate(){
+ // tests if component is able to handle submittedValue() correctly (convert & validate)
+ UIInputNumberSpinner uispinner = (UIInputNumberSpinner) spinner;
+ uispinner.validate(facesContext);
+ assertTrue(uispinner.isValid());
+ }
+
+}
Deleted: trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-06 15:21:18 UTC (rev 311)
+++ trunk/richfaces/inputnumber-spinner/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-06 16:17:28 UTC (rev 312)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * 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.richfaces.component;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
-
-/**
- * Unit test for simple Component.
- */
-public class JSFComponentTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public JSFComponentTest( String testName )
- {
- super( testName );
- }
-
-
- /**
- * Rigourous Test :-)
- */
- public void testComponent()
- {
- assertTrue( true );
- }
-}
19 years
JBoss Rich Faces SVN: r311 - trunk/richfaces/togglePanel/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: d.bulahov
Date: 2007-04-06 11:21:18 -0400 (Fri, 06 Apr 2007)
New Revision: 311
Added:
trunk/richfaces/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java
Removed:
trunk/richfaces/togglePanel/src/test/java/org/richfaces/component/TogglePanelTest.java
Log:
Unit tests development
Added: trunk/richfaces/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java
===================================================================
--- trunk/richfaces/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java (rev 0)
+++ trunk/richfaces/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java 2007-04-06 15:21:18 UTC (rev 311)
@@ -0,0 +1,184 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * 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.richfaces.component;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlForm;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Unit test for Datascroller component.
+ */
+public class TogglePanelComponentTest extends AbstractAjax4JsfTestCase {
+ private static Set javaScripts = new HashSet();
+
+ static {
+ javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
+ javaScripts.add("prototype.js");
+ javaScripts.add("scripts/togglePanel.js");
+ }
+
+ private UITogglePanel togglePanel;
+ private UIToggleControl toggleControl;
+ private UIComponent form;
+ private UIOutput a;
+ private UIOutput b;
+ private UIOutput c;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public TogglePanelComponentTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ a = (UIOutput)application.createComponent(UIOutput.COMPONENT_TYPE);
+ a.setId("a_output");
+ a.setValue("a");
+
+ b = (UIOutput)application.createComponent(UIOutput.COMPONENT_TYPE);
+ b.setId("b_output");
+ b.setValue("b");
+
+ c = (UIOutput)application.createComponent(UIOutput.COMPONENT_TYPE);
+ c.setId("c_output");
+ c.setValue("c");
+
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ togglePanel = (UITogglePanel)application.createComponent("org.richfaces.TogglePanel");
+ togglePanel.setId("TogglePanel");
+ togglePanel.getFacets().put("a", a);
+ togglePanel.getFacets().put("b", b);
+ togglePanel.getFacets().put("c", c);
+ togglePanel.setStateOrder("a,b,c");
+ togglePanel.setInitialState("a");
+
+ form.getChildren().add(togglePanel);
+
+ toggleControl = (UIToggleControl)application.createComponent("org.richfaces.ToggleControl");
+ toggleControl.setId("ToggleControl");
+ toggleControl.setFor(togglePanel.getId());
+ toggleControl.setFor(togglePanel.getId());
+ form.getChildren().add(toggleControl);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ togglePanel = null;
+ toggleControl = null;
+ form = null;
+ }
+
+ /**
+ * Test component rendering
+ *
+ * @throws Exception
+ */
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ //System.out.println(page.asXml());
+
+ HtmlElement div = page.getHtmlElementById(togglePanel.getClientId(facesContext));
+ assertNotNull(div);
+ assertEquals("div", div.getNodeName());
+
+ HtmlElement div_control = page.getHtmlElementById(toggleControl.getClientId(facesContext));
+ String classAttr = div_control.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-tglctrl"));
+ assertTrue(classAttr.contains("rich-tglctrl"));
+ }
+
+ /**
+ * Test style rendering
+ *
+ * @throws Exception
+ */
+ 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/toggleControl.xcss"));
+ }
+
+ /**
+ * Test script rendering
+ *
+ * @throws Exception
+ */
+ public void testRenderScript() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ 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();) {
+ String src = (String) srcIt.next();
+
+ found = srcAttr.contains(src);
+ if (found) {
+ break;
+ }
+ }
+
+ assertTrue(found);
+ }
+ }
+ }
+}
+
+
+
+
Deleted: trunk/richfaces/togglePanel/src/test/java/org/richfaces/component/TogglePanelTest.java
===================================================================
--- trunk/richfaces/togglePanel/src/test/java/org/richfaces/component/TogglePanelTest.java 2007-04-06 14:50:38 UTC (rev 310)
+++ trunk/richfaces/togglePanel/src/test/java/org/richfaces/component/TogglePanelTest.java 2007-04-06 15:21:18 UTC (rev 311)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * 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.richfaces.component;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
-
-/**
- * Unit test for simple Component.
- */
-public class TogglePanelTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public TogglePanelTest( String testName )
- {
- super( testName );
- }
-
-
- /**
- * Rigourous Test :-)
- */
- public void testComponent()
- {
- assertTrue( true );
- }
-}
19 years
JBoss Rich Faces SVN: r310 - in trunk/richfaces/menu-components/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-04-06 10:50:38 -0400 (Fri, 06 Apr 2007)
New Revision: 310
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
Log:
menuGroup template development
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-04-06 14:45:47 UTC (rev 309)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-04-06 14:50:38 UTC (rev 310)
@@ -21,13 +21,6 @@
package org.richfaces.renderkit.html;
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.renderer.ComponentVariables;
-import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.richfaces.component.UIMenuGroup;
@@ -43,31 +36,4 @@
return true;
}
- public void initializeResources(FacesContext context, UIMenuGroup menuGroup)
- throws IOException {
-
- ComponentVariables variables = ComponentsVariableResolver.getVariables(this, menuGroup);
-
- boolean disabled = ((Boolean) menuGroup.getAttributes().get("disabled")).booleanValue();
- if (!disabled) {
- StringBuffer scriptValue = new StringBuffer();
- scriptValue.append("document.getElementById('ref" + menuGroup.getClientId(context) + ":icon').className='dr-menu-icon rich-menu-item-icon ")
- .append(getAttributeOrEmpty(menuGroup, "iconClass") + "'; ")
- .append("document.getElementById('ref" + menuGroup.getClientId(context) + ":anchor').className='dr-menu-label rich-menu-item-label'; ");
- variables.setVariable("onmouseout", scriptValue);
-
- scriptValue = new StringBuffer();
- scriptValue.append("document.getElementById('ref" + menuGroup.getClientId(context) + ":icon').className='dr-menu-icon dr-menu-icon-selected rich-menu-item-icon rich-menu-item-icon-selected ")
- .append(getAttributeOrEmpty(menuGroup, "iconClass") + "'; ")
- .append("document.getElementById('ref" + menuGroup.getClientId(context) + ":anchor').className='dr-menu-label dr-menu-label-selected rich-menu-item-label rich-menu-item-label-selected'; ");
- variables.setVariable("onmouseover", scriptValue);
-
- }
- }
-
- public String getAttributeOrEmpty(UIComponent component, String attr) {
- Object value = component.getAttributes().get(attr);
- return value==null?"":value.toString();
- }
-
}
Modified: trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
===================================================================
--- trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-04-06 14:45:47 UTC (rev 309)
+++ trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-04-06 14:50:38 UTC (rev 310)
@@ -14,12 +14,9 @@
<h:scripts>
new org.ajax4jsf.framework.resource.PrototypeScript(),
- new org.ajax4jsf.framework.ajax.AjaxScript(),
- scripts/menu.js
+ new org.ajax4jsf.framework.ajax.AjaxScript()
</h:scripts>
- <f:call name="initializeResources" />
-
<f:clientid var="clientId"/>
<f:resource name="/org/richfaces/renderkit/html/images/spacer.gif" var="spacer" />
@@ -30,8 +27,14 @@
<div id="ref#{clientId}"
class="dr-menu-item dr-menu-item-enabled rich-menu-group #{component.attributes['styleClass']}"
style="#{component.attributes['style']}"
- onmouseout="this.className='dr-menu-item dr-menu-item-enabled rich-menu-group'; #{onmouseout} #{component.attributes['onmouseout']}"
- onmouseover="this.className='dr-menu-item dr-menu-item-hover rich-menu-group rich-menu-group-hover'; #{component.attributes['selectClass']} #{onmouseover} #{component.attributes['onmouseover']}"
+ onmouseout="this.className='dr-menu-item dr-menu-item-enabled rich-menu-group';
+ $('ref#{clientId}:icon').className='dr-menu-icon rich-menu-item-icon #{component.attributes['iconClass']}';
+ $('ref#{clientId}:anchor').className='dr-menu-label rich-menu-item-label';
+ #{component.attributes['onmouseout']}"
+ onmouseover="this.className='dr-menu-item dr-menu-item-hover rich-menu-group rich-menu-group-hover'; #{component.attributes['selectClass']}
+ $('ref#{clientId}:icon').className='dr-menu-icon dr-menu-icon-selected rich-menu-item-icon rich-menu-item-icon-selected #{component.attributes['iconClass']}';
+ $('ref#{clientId}:anchor').className='dr-menu-label dr-menu-label-selected rich-menu-item-label rich-menu-item-label-selected';
+ #{component.attributes['onmouseover']}"
onmousemove="#{component.attributes['onmousemove']}">
<span id="ref#{clientId}:icon"
19 years
JBoss Rich Faces SVN: r309 - in trunk/richfaces/dropdown-menu/src/main: resources/org/richfaces/renderkit/html/scripts and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-04-06 10:45:47 -0400 (Fri, 06 Apr 2007)
New Revision: 309
Modified:
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
second iframe removed; function fitLayerToContent changed; support for attributes "verticalOffset" and "horisontalOffset" added
Modified: trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-04-06 14:16:36 UTC (rev 308)
+++ trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-04-06 14:45:47 UTC (rev 309)
@@ -86,19 +86,12 @@
writer.writeAttribute("style", "position:absolute", null);
writer.endElement("iframe");
- writer.startElement("iframe", layer);
- writer.writeAttribute("id", clientId+"_menu_iframe1", null);
- writer.writeAttribute("class", "underneath_iframe", null);
- writer.writeAttribute("style", "position:absolute", null);
- writer.endElement("iframe");
-
writer.startElement("script", layer);
writer.writeAttribute("id", clientId+"_menu_script", null);
writer.writeAttribute("type", "text/javascript", null);
encodeScript(context, layer);
writer.endElement("script");
AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_iframe");
- AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_iframe1");
AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_script");
}
Modified: trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-04-06 14:16:36 UTC (rev 308)
+++ trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-04-06 14:45:47 UTC (rev 309)
@@ -18,8 +18,11 @@
var table = layer.childNodes[0];
if (table) {
- var tmpDims = Element.getDimensions(table);
- layer.style.width = tmpDims.width + "px";
+ if (layer.style.width.indexOf("px")!=-1) {
+ var width = parseFloat(layer.style.width.substring(0,layer.style.width.indexOf('px')));
+ var tmpDims = Element.getDimensions(table);
+ if (tmpDims.width > width) layer.style.width = tmpDims.width + "px";
+ }
//layer.style.height = dims.height + "px";
} // if
}
@@ -123,7 +126,6 @@
if(this.IE || this.NS) {
menuName = $(menuName).id;
var iframe = $(menuName + "_iframe");
- var iframe1 = $(menuName + "_iframe1");
var nsfix = (this.NS ? 7 : 0);
if(on){
Position.clone(menuName, iframe);
@@ -134,16 +136,8 @@
iframe.style.visibility = "visible";
iframe.style.height = (dim.height - this.CornerRadius - 1 - this.shadowWidth - nsfix) + "px";
- Position.clone(menuName, iframe1);
- dim = Element.getDimensions(iframe1);
- iframe1.style.top = (iframe1.style.pixelTop) + "px";
- iframe1.style.left = (iframe1.offsetLeft + Math.round(this.CornerRadius / 2)) + "px";
- iframe1.style.width = (dim.width - this.CornerRadius - this.shadowWidth - nsfix - 1) + "px";
- iframe1.style.visibility = "visible";
- iframe1.style.height = (dim.height - this.shadowWidth - nsfix) + "px";
} else {
iframe.style.visibility = "hidden";
- iframe1.style.visibility = "hidden";
}
}
},
@@ -487,16 +481,18 @@
direction = sDir.indexOf('BOTTOM-RIGHT')!= -1?3:direction;
direction = sDir.indexOf('BOTTOM-LEFT') != -1?4:direction;
}
+ var hOffset = options.horizontalOffset;
+ var vOffset = options.verticalOffset;
var listPos = this.listPositions(jointPoint, direction);
var layerPos;
var foundPos = false;
for (var i=0;i<listPos.length;i++) {
layerPos = this.calcPosition(listPos[i].jointPoint, listPos[i].direction)
- if ((layerPos.left >= winOffset.left) &&
- (layerPos.left + this.layerdim.width - winOffset.left <= windowWidth) &&
- (layerPos.top >= winOffset.top) &&
- (layerPos.top + this.layerdim.height - winOffset.top <= windowHeight)) {
+ if ((layerPos.left + hOffset >= winOffset.left) &&
+ (layerPos.left + hOffset + this.layerdim.width - winOffset.left <= windowWidth) &&
+ (layerPos.top + vOffset >= winOffset.top) &&
+ (layerPos.top + vOffset + this.layerdim.height - winOffset.top <= windowHeight)) {
foundPos = true;
break;
}
@@ -504,8 +500,8 @@
if (!foundPos) {
layerPos = this.calcPosition(listPos[0].jointPoint, listPos[0].direction)
}
- this.layer.style.left = layerPos.left + "px";
- this.layer.style.top = layerPos.top + "px";
+ this.layer.style.left = layerPos.left + hOffset + "px";
+ this.layer.style.top = layerPos.top + vOffset + "px";
Exadel.Menu.Layers.LMPopUp(this.layer.id, false);
Exadel.Menu.Layers.clearLMTO();
19 years