JBoss Rich Faces SVN: r409 - in trunk/richfaces-samples/dropdownmenu-sample/src/main: webapp/pages and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: d.bulahov
Date: 2007-04-13 11:28:50 -0400 (Fri, 13 Apr 2007)
New Revision: 409
Modified:
trunk/richfaces-samples/dropdownmenu-sample/src/main/java/org/richfaces/samples/dropdownmenu/Bean.java
trunk/richfaces-samples/dropdownmenu-sample/src/main/webapp/pages/index.jsp
Log:
sample aplication update
Modified: trunk/richfaces-samples/dropdownmenu-sample/src/main/java/org/richfaces/samples/dropdownmenu/Bean.java
===================================================================
--- trunk/richfaces-samples/dropdownmenu-sample/src/main/java/org/richfaces/samples/dropdownmenu/Bean.java 2007-04-13 14:38:48 UTC (rev 408)
+++ trunk/richfaces-samples/dropdownmenu-sample/src/main/java/org/richfaces/samples/dropdownmenu/Bean.java 2007-04-13 15:28:50 UTC (rev 409)
@@ -33,7 +33,20 @@
private String jointPoint = "auto";
private String direction = "auto";
private String groupDirection = "auto";
+ private int verticalOffset = 10;
+ private int horizontalOffset =10;
+ private String verticalOffsets = "10";
+ private String horizontalOffsets ="10";
+ private String event ="onmouseover";
+ public String getEvent() {
+ return event;
+ }
+
+ public void setEvent(String event) {
+ this.event = event;
+ }
+
public String getWidth() {
return width;
}
@@ -61,11 +74,52 @@
public String getGroupDirection() {
return groupDirection;
}
+
+ public void setHorizontalOffset(int horizontalOffset) {
+ this.horizontalOffset = horizontalOffset;
+ }
+ public int getHorizontalOffset() {
+ return horizontalOffset;
+ }
+
+ public void setVerticalOffset(int verticalOffset) {
+ this.verticalOffset = verticalOffset;
+ }
+
+ public int getVerticalOffset() {
+ return verticalOffset;
+ }
+
public void setGroupDirection(String direction) {
this.groupDirection = direction;
}
+
+
+
+
+ public void setHorizontalOffsets(String horizontalOffsets) {
+ this.horizontalOffsets = horizontalOffsets;
+ setHorizontalOffset(new Integer(this.horizontalOffsets).intValue());
+ }
+
+ public String getHorizontalOffsets() {
+ return horizontalOffsets;
+ }
+
+ public void setVerticalOffsets(String verticalOffsets) {
+ this.verticalOffsets = verticalOffsets;
+ setVerticalOffset(new Integer(this.verticalOffsets).intValue());
+ }
+
+ public String getVerticalOffsets() {
+ return verticalOffsets;
+ }
+
+
+
+
public void actionListener(ActionEvent event) {
System.out.println("ActionEvent on " + event.getComponent().getId() + " & Phase is "+ event.getPhaseId());
}
Modified: trunk/richfaces-samples/dropdownmenu-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/richfaces-samples/dropdownmenu-sample/src/main/webapp/pages/index.jsp 2007-04-13 14:38:48 UTC (rev 408)
+++ trunk/richfaces-samples/dropdownmenu-sample/src/main/webapp/pages/index.jsp 2007-04-13 15:28:50 UTC (rev 409)
@@ -11,13 +11,13 @@
<body>
<f:view>
- <h:form>
+ <h:form id="frm">
<h:messages style="color:red"/>
<h:selectOneRadio binding="#{skinBean.component}"/>
<h:commandLink action="#{skinBean.change}" value="set skin"/>
<h:panelGrid id="grid" columns="2" cellspacing="4">
- <ddm:dropDownMenu id="MenuItem1" popupWidth="#{bean.width}" value="Item1" jointPoint="#{bean.jointPoint}" direction="#{bean.direction}">
+ <ddm:dropDownMenu event="#{bean.event}" id="MenuItem1" verticalOffset="#{bean.verticalOffset}" horizontalOffset="#{bean.horizontalOffset}" popupWidth="#{bean.width}" value="Item1" jointPoint="#{bean.jointPoint}" direction="#{bean.direction}">
<mc:menuItem id="menuItem11" value="Active11: ajax" mode="ajax" actionListener="#{bean.actionListener}"/>
<mc:menuItem id="menuItem12" value="Active12" actionListener="#{bean.actionListener}" immediate="true"/>
<mc:menuItem id="menuItem13" value="Active13" action="#{bean.action}" icon="/images/ico1.gif"/>
@@ -37,7 +37,7 @@
</mc:menuItem>
</ddm:dropDownMenu>
- <ddm:dropDownMenu id="MenuItem2" popupWidth="#{bean.width}" jointPoint="#{bean.jointPoint}" direction="#{bean.direction}">
+ <ddm:dropDownMenu event="#{bean.event}" verticalOffset="#{bean.verticalOffset}" horizontalOffset="#{bean.horizontalOffset}" id="MenuItem2" popupWidth="#{bean.width}" jointPoint="#{bean.jointPoint}" direction="#{bean.direction}">
<f:facet name="label">
<f:verbatim>Item2</f:verbatim>
</f:facet>
@@ -72,7 +72,41 @@
<br/>
<br/>
+ <ddm:dropDownMenu event="#{bean.event}" verticalOffset="#{bean.verticalOffset}" horizontalOffset="#{bean.horizontalOffset}" style="position: absolute; left: 300px; top: 70px; font-size:14px" id="MenuItemAbs1" popupWidth="#{bean.width}" value="Absolute" jointPoint="#{bean.jointPoint}" direction="#{bean.direction}">
+ <mc:menuItem id="menuItemAbs11" value="Active11: ajax" mode="ajax" actionListener="#{bean.actionListener}"/>
+ <mc:menuItem id="menuItemAbs12" value="Active12" actionListener="#{bean.actionListener}" immediate="true"/>
+ <mc:menuItem id="menuItemAbs13" value="Active13" action="#{bean.action}" icon="/images/ico1.gif"/>
+ <mc:menuItem id="menuItemAbs14" value="Active14"/>
+ <mc:menuGroup id="menuGroupAbs1" value="Group1" direction="#{bean.groupDirection}">
+ <mc:menuItem id="menuGroupAbs1Item1" value="Active"/>
+ <mc:menuItem id="menuGroupAbs1Item2" value="Active" icon="/images/ico1.gif"/>
+ <mc:menuGroup id="menuGroupAbs2" value="Group2" direction="#{bean.groupDirection}">
+ <mc:menuItem id="menuGroupAbs2Item1" value="Active"/>
+ <mc:menuItem id="menuGroupAbs2Item2" value="Active" icon="/images/ico1.gif"/>
+ <mc:menuGroup id="menuGroupAbs4" value="Group3" direction="#{bean.groupDirection}">
+ <mc:menuItem id="menuGroupAbs4Item1" value="Active" icon="/images/ico1.gif"/>
+ <mc:menuItem id="menuGroupAbs4Item2" value="Active" icon="/images/ico1.gif"/>
+ <mc:menuGroup id="menuGroupAbs5" value="Group3" direction="#{bean.groupDirection}">
+ <mc:menuItem id="menuGroupAbs5Item1" value="Active" icon="/images/ico1.gif"/>
+ <mc:menuItem id="menuGroupAbs5Item2" value="Active" icon="/images/ico1.gif"/>
+ </mc:menuGroup>
+ </mc:menuGroup>
+ </mc:menuGroup>
+ <mc:menuItem id="menuGroupAbs1Item3" value="Active"/>
+ </mc:menuGroup>
+ <mc:menuItem id="menuItemAbs15" value="Active15" icon="/images/ico2.gif"/>
+
+ <mc:menuSeparator id="menuSeparator1111"/>
+
+ <mc:menuItem id="menuItemAbs16" value="Disable16" disabled="true"/>
+ <mc:menuItem id="menuItemAbs17" value="">
+ <h:inputText value="#{bean.width}"/>
+ </mc:menuItem>
+ </ddm:dropDownMenu>
+
+
+
<h:panelGroup>
<h:outputText value="Width:"/>
<h:selectOneRadio value="#{bean.width}" onclick="submit()">
@@ -114,6 +148,163 @@
<f:selectItem itemLabel="right" itemValue="right"/>
</h:selectOneRadio>
</h:panelGroup>
+
+ <h:panelGroup>
+ <h:outputText value="Menu appearance event:"/>
+ <h:selectOneRadio value="#{bean.event}" onclick="submit()">
+ <f:selectItem itemLabel="onclick" itemValue="onclick"/>
+ <f:selectItem itemLabel="onmouseover" itemValue="onmouseover"/>
+ </h:selectOneRadio>
+ </h:panelGroup>
+
+ <h:panelGroup>
+ <h:outputText value="Horizontal offset: "/>
+ <h:inputText value="#{bean.horizontalOffsets}" onchange="submit()"/>
+ </h:panelGroup>
+
+ <h:panelGroup>
+ <h:outputText value="Vertical offset: "/>
+ <h:inputText value="#{bean.verticalOffsets}" onchange="submit()"/>
+ </h:panelGroup>
+
+ <br/>
+ <br/>
+
+
+ <ddm:dropDownMenu
+ oncollapse="$('oncollapsedd').innerHTML='+'"
+ onexpand="$('onexpanddd').innerHTML='+'"
+ onmouseout="$('onmouseoutdd').innerHTML='+'"
+ onmousemove="$('onmousemovedd').innerHTML='+'"
+ onmouseover="$('onmouseoverdd').innerHTML='+'"
+ onitemselect="$('onitemselectdd').innerHTML='+'"
+ ongroupactivate="$('ongroupactivatedd').innerHTML='+'"
+ event="#{bean.event}"
+ verticalOffset="#{bean.verticalOffset}"
+ horizontalOffset="#{bean.horizontalOffset}"
+ id="MenuItemTest1"
+ popupWidth="#{bean.width}"
+ value="Test event menu"
+ jointPoint="#{bean.jointPoint}"
+ direction="#{bean.direction}">
+ <mc:menuItem
+ onclick="$('onclicki').innerHTML='+'"
+ onmouseout="$('onmouseouti').innerHTML='+'"
+ onmousedown="$('onmousedowni').innerHTML='+'"
+ onmouseup="$('onmouseupi').innerHTML='+'"
+ onmousemove="$('onmousemovei').innerHTML='+'"
+ onmouseover="$('onmouseoveri').innerHTML='+'"
+ onselect ="$('onselecti').innerHTML='+'"
+ id="menuItemTest11" value="Active11: ajax" mode="ajax" actionListener="#{bean.actionListener}"/>
+ <mc:menuGroup id="menuGroupTest1" value="Group" direction="#{bean.groupDirection}"
+ onmouseout="$('onmouseoutmg').innerHTML='+'"
+ onmousemove="$('onmousemovemg').innerHTML='+'"
+ onmouseover="$('onmouseovermg').innerHTML='+'"
+ onopen="$('onopenmg').innerHTML='+'"
+ onclose="$('onclosemg').innerHTML='+'">
+ <mc:menuItem id="menuGroupTest1Item1" value="Active"/>
+ <mc:menuItem id="menuGroupTest1Item2" value="Active" icon="/images/ico1.gif"/>
+ <mc:menuGroup id="menuGroupTest2" value="Group2" direction="#{bean.groupDirection}">
+ <mc:menuItem id="menuGroupTest2Item1" value="Active"/>
+ <mc:menuItem id="menuGroupTest2Item2" value="Active" icon="/images/ico1.gif"/>
+ </mc:menuGroup>
+ <mc:menuItem id="menuGroupTest1Item3" value="Active"/>
+ </mc:menuGroup>
+ <mc:menuSeparator id="menuSeparatorTest"/>
+ <mc:menuItem id="menuItemTest15" value="Disable" disabled="true"/>
+ </ddm:dropDownMenu>
+<br/>
+<br/>
+<br/>
+ <h:panelGroup>
+ <h:outputText value="dropDownMenu event:"/>
+ <h:panelGrid id="grid1" columns="7" cellspacing="0" border="1">
+ <h:outputText value="oncollapse"/>
+ <h:outputText value="onexpand"/>
+ <h:outputText value="onmouseout"/>
+ <h:outputText value="onmousemove"/>
+ <h:outputText value="onmouseover"/>
+ <h:outputText value="onitemselect"/>
+ <h:outputText value="ongroupactivate"/>
+ <f:verbatim>
+ <span id="oncollapsedd"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onexpanddd"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmouseoutdd"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmousemovedd"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmouseoverdd"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onitemselectdd"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="ongroupactivatedd"> </span>
+ </f:verbatim>
+ </h:panelGrid>
+ <h:outputText value="menuGroup event:"/>
+ <h:panelGrid id="grid2" columns="5" border="1" cellspacing="0">
+ <h:outputText value="onmouseout"/>
+ <h:outputText value="onmousemove"/>
+ <h:outputText value="onmouseover"/>
+ <h:outputText value="onopen"/>
+ <h:outputText value="onclose"/>
+ <f:verbatim>
+ <span id="onmouseoutmg"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmousemovemg"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmouseovermg"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onopenmg"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onclosemg"> </span>
+ </f:verbatim>
+ </h:panelGrid>
+
+ <h:outputText value="menuItem event:"/>
+ <h:panelGrid id="grid3" columns="7" border="1" cellspacing="0">
+ <h:outputText value="onmouseout"/>
+ <h:outputText value="onmousedown"/>
+ <h:outputText value="onmouseup"/>
+ <h:outputText value="onmousemove"/>
+ <h:outputText value="onmouseover"/>
+ <h:outputText value="onitemselect"/>
+ <h:outputText value="onselect"/>
+ <f:verbatim>
+ <span id="onclicki"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmouseouti"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmousedowni"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmouseupi"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmousemovei"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onmouseoveri"> </span>
+ </f:verbatim>
+ <f:verbatim>
+ <span id="onselecti"> </span>
+ </f:verbatim>
+ </h:panelGrid>
+ </h:panelGroup>
+
</h:form>
</f:view>
</body>
19 years
JBoss Rich Faces SVN: r408 - trunk/richfaces/dataTable/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: F.antonov
Date: 2007-04-13 10:38:48 -0400 (Fri, 13 Apr 2007)
New Revision: 408
Added:
trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java
Log:
DataTable components test cases development.
Added: trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java
===================================================================
--- trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java (rev 0)
+++ trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java 2007-04-13 14:38:48 UTC (rev 408)
@@ -0,0 +1,433 @@
+/**
+ * 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.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlOutputLink;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+import javax.faces.model.ListDataModel;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * Unit test for DataTable component.
+ */
+public class DataTableComponentTest extends AbstractAjax4JsfTestCase {
+
+ private UIDataTable dataTable;
+
+ private UIColumn column1;
+
+ private UIColumn column2;
+
+ private UIColumnGroup columnGroup;
+
+ /**
+ * Create the test case
+ *
+ * @param testName
+ * name of the test case
+ */
+ public DataTableComponentTest(String testName) {
+ super(testName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ dataTable = (UIDataTable) application
+ .createComponent("org.richfaces.DataTable");
+ dataTable.setId("dataTable");
+
+ List list = new ArrayList();
+ for (int i = 1; i <= 5; i++) {
+ list.add(new Date((long) Math.random()));
+ }
+ dataTable.setValue(new ListDataModel(list));
+
+ columnGroup = (UIColumnGroup) application
+ .createComponent("org.richfaces.ColumnGroup");
+ dataTable.getChildren().add(columnGroup);
+
+ column1 = (UIColumn) application
+ .createComponent("org.richfaces.Column");
+ UIOutput cellElement1 = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ cellElement1.setValueBinding("value", new ValueBinding() {
+ public Class getType(FacesContext context)
+ throws EvaluationException, PropertyNotFoundException {
+ return String.class;
+ }
+
+ public Object getValue(FacesContext context)
+ throws EvaluationException, PropertyNotFoundException {
+ return Long.toString(((Date) dataTable.getValue()).getTime());
+ }
+
+ public boolean isReadOnly(FacesContext context)
+ throws EvaluationException, PropertyNotFoundException {
+ return false;
+ }
+
+ public void setValue(FacesContext context, Object value)
+ throws EvaluationException, PropertyNotFoundException {
+ }
+ });
+ column1.getChildren().add(cellElement1);
+ columnGroup.getChildren().add(column1);
+
+ column2 = (UIColumn) application
+ .createComponent("org.richfaces.Column");
+ UIOutput cellElement2 = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputLink.class.getName(),
+ null, null, null);
+ cellElement2.setValueBinding("value", new ValueBinding() {
+ public Class getType(FacesContext context)
+ throws EvaluationException, PropertyNotFoundException {
+ return String.class;
+ }
+
+ public Object getValue(FacesContext context)
+ throws EvaluationException, PropertyNotFoundException {
+ return Long.toString(((Date) dataTable.getValue()).getTime());
+ }
+
+ public boolean isReadOnly(FacesContext context)
+ throws EvaluationException, PropertyNotFoundException {
+ return false;
+ }
+
+ public void setValue(FacesContext context, Object value)
+ throws EvaluationException, PropertyNotFoundException {
+ }
+ });
+ column2.getChildren().add(cellElement2);
+ columnGroup.getChildren().add(column2);
+
+ facesContext.getViewRoot().getChildren().add(dataTable);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ column1 = null;
+ column2 = null;
+ columnGroup = null;
+ dataTable = null;
+ }
+
+ /**
+ * Test DataTable component rendering.
+ *
+ * @throws Exception
+ */
+ public void testRenderDataTable() throws Exception {
+
+ dataTable.getAttributes().put("columnsWidth", "400px,200px");
+
+ UIColumn column3 = (UIColumn) application
+ .createComponent("org.richfaces.Column");
+ dataTable.getChildren().add(column3);
+ HtmlOutputText text = (HtmlOutputText) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ text.setValue("Column");
+ column3.getChildren().add(text);
+ column3.setBreakBefore(true);
+
+ UIColumn column4 = (UIColumn) application
+ .createComponent("org.richfaces.Column");
+ dataTable.getChildren().add(column4);
+ HtmlOutputText text2 = (HtmlOutputText) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ text.setValue("Column2");
+ column4.getChildren().add(text2);
+ column4.setRendered(false);
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ // System.out.println(page.asXml());
+
+ HtmlElement table = page.getHtmlElementById(dataTable
+ .getClientId(facesContext));
+ assertNotNull(table);
+ assertEquals("table", table.getNodeName());
+ String classAttr = table.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table rich-table"));
+
+ List elements = table.getHtmlElementsByTagName("col");
+ assertEquals(2, elements.size());
+ classAttr = ((HtmlElement) elements.get(0)).getAttributeValue("width");
+ assertTrue(classAttr.contains("400px"));
+ classAttr = ((HtmlElement) elements.get(1)).getAttributeValue("width");
+ assertTrue(classAttr.contains("200px"));
+
+ List bodies = table.getHtmlElementsByTagName("tbody");
+ assertEquals(1, bodies.size());
+ List trs = ((HtmlElement) bodies.get(0)).getHtmlElementsByTagName("tr");
+ assertTrue(trs.size() > 0);
+ HtmlElement tr = (HtmlElement) trs.get(0);
+ assertNotNull(tr);
+ classAttr = tr.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-firstrow rich-table-firstrow"));
+
+ List tds = tr.getHtmlElementsByTagName("td");
+ assertTrue(tds.size() > 0);
+ HtmlElement td = (HtmlElement) tds.get(0);
+ assertNotNull(td);
+ classAttr = td.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-cell rich-table-cell"));
+ }
+
+ /**
+ * Test DataTable component facets rendering.
+ *
+ * @throws Exception
+ */
+ public void testRenderDataTableFacets() throws Exception {
+
+ UIColumnGroup header1 = (UIColumnGroup) application
+ .createComponent("org.richfaces.ColumnGroup");
+ header1.getAttributes().put("columnClasses", "cola, colb");
+ dataTable.getFacets().put("header", header1);
+
+ UIColumn headerColumn1 = (UIColumn) application
+ .createComponent("org.richfaces.Column");
+ UIOutput headerText1 = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ headerText1.setValue("Header Column1");
+ headerColumn1.getChildren().add(headerText1);
+ header1.getChildren().add(headerColumn1);
+
+ UIOutput column1header = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ column1header.setValue("Column1 Header");
+ headerColumn1.getFacets().put("header", column1header);
+
+ UIColumn headerColumn2 = (UIColumn) application
+ .createComponent("org.richfaces.Column");
+ UIOutput headerText2 = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ headerText2.setValue("Header Column2");
+ headerColumn2.getChildren().add(headerText2);
+ header1.getChildren().add(headerColumn2);
+
+ UIOutput column2header = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ column2header.setValue("Column2 Header");
+ headerColumn2.getFacets().put("header", column2header);
+
+ UIOutput caption = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ dataTable.getFacets().put("caption", caption);
+ caption.setValue("Caption");
+
+ UIOutput footer = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ dataTable.getFacets().put("footer", footer);
+ footer.setValue("Footer");
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ // System.out.println(page.asXml());
+
+ HtmlElement table = page.getHtmlElementById(dataTable
+ .getClientId(facesContext));
+ assertNotNull(table);
+
+ List captions = table.getHtmlElementsByTagName("caption");
+ assertNotNull(captions);
+ assertEquals(1, captions.size());
+ String classAttr = ((HtmlElement) captions.get(0))
+ .getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-caption rich-table-caption"));
+
+ List headers = table.getHtmlElementsByTagName("thead");
+ assertNotNull(headers);
+ assertEquals(1, headers.size());
+ List trs = ((HtmlElement) headers.get(0))
+ .getHtmlElementsByTagName("tr");
+ assertTrue(trs.size() > 0);
+ HtmlElement tr = (HtmlElement) trs.get(0);
+ assertNotNull(tr);
+ classAttr = tr.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-header rich-table-header"));
+
+ List tds = tr.getHtmlElementsByTagName("td");
+ assertTrue(tds.size() > 0);
+ HtmlElement td = (HtmlElement) tds.get(0);
+ assertNotNull(td);
+ classAttr = td.getAttributeValue("class");
+ assertTrue(classAttr
+ .contains("dr-table-headercell rich-table-headercell"));
+ assertTrue(classAttr.contains("cola"));
+
+ List footers = table.getHtmlElementsByTagName("tfoot");
+ assertNotNull(footers);
+ assertEquals(1, footers.size());
+ trs = ((HtmlElement) footers.get(0)).getHtmlElementsByTagName("tr");
+ assertTrue(trs.size() > 0);
+ tr = (HtmlElement) trs.get(0);
+ assertNotNull(tr);
+ classAttr = tr.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-footer rich-table-footer"));
+
+ tds = tr.getHtmlElementsByTagName("td");
+ assertTrue(tds.size() > 0);
+ td = (HtmlElement) tds.get(0);
+ assertNotNull(td);
+ classAttr = td.getAttributeValue("class");
+ assertTrue(classAttr
+ .contains("dr-table-footercell rich-table-footercell"));
+ }
+
+ /**
+ * Test DataTable component rows and columns rendering.
+ *
+ * @throws Exception
+ */
+ public void testRenderDataTableRowsAndColumns() throws Exception {
+
+ UIOutput caption = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ dataTable.getFacets().put("caption", caption);
+ caption.setValue("Caption");
+ dataTable.getAttributes().put("captionClass", "captionClass");
+ dataTable.getAttributes().put("captionStyle", "captionStyle");
+
+ dataTable.getAttributes().put("rowClasses", "row1,row2");
+ dataTable.getAttributes().put("columnClasses", "column1,column2");
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ // System.out.println(page.asXml());
+
+ HtmlElement table = page.getHtmlElementById(dataTable
+ .getClientId(facesContext));
+ assertNotNull(table);
+
+ List captions = table.getHtmlElementsByTagName("caption");
+ assertNotNull(captions);
+ assertEquals(1, captions.size());
+ String classAttr = ((HtmlElement) captions.get(0))
+ .getAttributeValue("class");
+ assertTrue(classAttr.contains("captionClass"));
+ classAttr = ((HtmlElement) captions.get(0)).getAttributeValue("style");
+ assertTrue(classAttr.contains("captionStyle"));
+
+ List bodies = table.getHtmlElementsByTagName("tbody");
+ assertTrue(bodies.size() > 0);
+ List trs = ((HtmlElement) bodies.get(0)).getHtmlElementsByTagName("tr");
+ assertTrue(trs.size() > 0);
+ HtmlElement tr = (HtmlElement) trs.get(0);
+ assertNotNull(tr);
+ classAttr = tr.getAttributeValue("class");
+ assertTrue(classAttr.contains("row1"));
+
+ List tds = tr.getHtmlElementsByTagName("td");
+ assertTrue(tds.size() > 0);
+ HtmlElement td = (HtmlElement) tds.get(0);
+ assertNotNull(td);
+ classAttr = td.getAttributeValue("class");
+ assertTrue(classAttr.contains("column1"));
+ }
+
+ /**
+ * Test SubTable component rendering.
+ *
+ * @throws Exception
+ */
+ public void testSubTable() throws Exception {
+
+ UISubTable subTable = (UISubTable) application
+ .createComponent("org.richfaces.SubTable");
+ subTable.setId("subTable");
+ dataTable.getChildren().add(subTable);
+
+ UIColumn column3 = (UIColumn) application
+ .createComponent("org.richfaces.Column");
+ subTable.getChildren().add(column3);
+ HtmlOutputText text = (HtmlOutputText) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ text.setValue("Column");
+ column3.getChildren().add(text);
+
+ UIColumn column4 = (UIColumn) application
+ .createComponent("org.richfaces.Column");
+ subTable.getChildren().add(column4);
+ HtmlOutputText text2 = (HtmlOutputText) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ text.setValue("Column2");
+ column4.getChildren().add(text2);
+
+ subTable.getAttributes().put("columnClasses", "sub1,sub2");
+
+ assertTrue(subTable.isBreakBefore());
+
+ try {
+ subTable.setBreakBefore(false);
+ assertTrue(false);
+ } catch (IllegalStateException e) {
+
+ }
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ // System.out.println(page.asXml());
+ }
+
+}
19 years
JBoss Rich Faces SVN: r407 - trunk/richfaces/dataTable/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: F.antonov
Date: 2007-04-13 10:37:52 -0400 (Fri, 13 Apr 2007)
New Revision: 407
Added:
trunk/richfaces/dataTable/src/test/java/org/richfaces/component/AbstractListComponentsTest.java
trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataGridComponentTest.java
Removed:
trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java
Log:
DataTable components test cases.
Added: trunk/richfaces/dataTable/src/test/java/org/richfaces/component/AbstractListComponentsTest.java
===================================================================
--- trunk/richfaces/dataTable/src/test/java/org/richfaces/component/AbstractListComponentsTest.java (rev 0)
+++ trunk/richfaces/dataTable/src/test/java/org/richfaces/component/AbstractListComponentsTest.java 2007-04-13 14:37:52 UTC (rev 407)
@@ -0,0 +1,123 @@
+/**
+ * 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.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.model.ListDataModel;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.html.HtmlColumnGroup;
+import org.richfaces.component.html.HtmlColumn;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * Unit test for DataList component.
+ */
+public class AbstractListComponentsTest extends AbstractAjax4JsfTestCase {
+
+ private UIDataList dataList;
+
+ /**
+ * Create the test case
+ *
+ * @param testName
+ * name of the test case
+ */
+ public AbstractListComponentsTest(String testName) {
+ super(testName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ dataList = (UIDataList) application
+ .createComponent("org.richfaces.DataList");
+ dataList.setId("dataList");
+
+ List list = new ArrayList();
+ for (int i = 1; i <= 10; i++) {
+ list.add(new Date((long) Math.random()));
+ }
+ dataList.setValue(list);
+
+ facesContext.getViewRoot().getChildren().add(dataList);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ dataList = null;
+ }
+
+ /**
+ * Test DataList component rendering.
+ *
+ * @throws Exception
+ */
+ public void testRenderDataList() throws Exception {
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ // System.out.println(page.asXml());
+
+ // TYPE=disc|circle|square
+ dataList.getAttributes().put("type", "circle");
+
+ HtmlElement ul = page.getHtmlElementById(dataList
+ .getClientId(facesContext));
+ assertNotNull(ul);
+ assertEquals("ul", ul.getNodeName());
+ String classAttr = ul.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-list rich-datalist"));
+
+ List lis = ul.getHtmlElementsByTagName("li");
+ assertTrue(lis.size() > 0);
+ assertEquals(lis.size(), 10);
+ HtmlElement li = (HtmlElement) lis.get(0);
+ assertNotNull(li);
+ classAttr = li.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-list-item rich-list-item"));
+
+ }
+
+}
Added: trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataGridComponentTest.java
===================================================================
--- trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataGridComponentTest.java (rev 0)
+++ trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataGridComponentTest.java 2007-04-13 14:37:52 UTC (rev 407)
@@ -0,0 +1,239 @@
+/**
+ * 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.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.model.ListDataModel;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.html.HtmlColumnGroup;
+import org.richfaces.component.html.HtmlColumn;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * Unit test for DataGrid component.
+ */
+public class DataGridComponentTest extends AbstractAjax4JsfTestCase {
+
+ private UIDataGrid dataGrid;
+
+
+
+ /**
+ * Create the test case
+ *
+ * @param testName
+ * name of the test case
+ */
+ public DataGridComponentTest(String testName) {
+ super(testName);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ dataGrid = (UIDataGrid) application
+ .createComponent("org.richfaces.DataGrid");
+ dataGrid.setId("dataGrid");
+
+ dataGrid.setColumns(5);
+
+ List list = new ArrayList();
+ for (int i = 1; i <= 10; i++) {
+ list.add(new Date((long) Math.random()));
+ }
+ dataGrid.setValue(list);
+
+ facesContext.getViewRoot().getChildren().add(dataGrid);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ dataGrid = null;
+ }
+
+ /**
+ * Test DataGrid component rendering.
+ *
+ * @throws Exception
+ */
+ public void testRenderDataGrid() throws Exception {
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ //System.out.println(page.asXml());
+
+ HtmlElement table = page.getHtmlElementById(dataGrid
+ .getClientId(facesContext));
+ assertNotNull(table);
+ }
+
+ /**
+ * Test DataGrid component facets rendering.
+ *
+ * @throws Exception
+ */
+ public void testRenderDataGridFacets() throws Exception {
+
+ dataGrid.getAttributes().put("rowClasses", "row1,row2");
+ dataGrid.getAttributes().put("columnClasses", "A,B,Y,B,C");
+
+ UIOutput header = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ dataGrid.getFacets().put("header", header);
+ header.setValue("Header");
+
+ UIOutput footer = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ dataGrid.getFacets().put("footer", footer);
+ footer.setValue("Footer");
+
+ UIOutput caption = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+ dataGrid.getFacets().put("caption", caption);
+ caption.setValue("Caption");
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ //System.out.println(page.asXml());
+
+ HtmlElement table = page.getHtmlElementById(dataGrid
+ .getClientId(facesContext));
+ assertNotNull(table);
+ assertEquals("table", table.getNodeName());
+ String classAttr = table.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table rich-table"));
+
+ List captions = table.getHtmlElementsByTagName("caption");
+ assertNotNull(captions);
+ assertEquals(1, captions.size());
+ classAttr = ((HtmlElement) captions.get(0))
+ .getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-caption rich-table-caption"));
+
+ List headers = table.getHtmlElementsByTagName("thead");
+ assertNotNull(headers);
+ assertEquals(1, headers.size());
+ List trs = ((HtmlElement) headers.get(0))
+ .getHtmlElementsByTagName("tr");
+ assertTrue(trs.size() > 0);
+ HtmlElement tr = (HtmlElement) trs.get(0);
+ assertNotNull(tr);
+ classAttr = tr.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-header rich-table-header"));
+
+ List tds = tr.getHtmlElementsByTagName("td");
+ assertTrue(tds.size() > 0);
+ HtmlElement td = (HtmlElement) tds.get(0);
+ assertNotNull(td);
+ classAttr = td.getAttributeValue("class");
+ assertTrue(classAttr
+ .contains("dr-table-headercell rich-table-headercell"));
+
+ List footers = table.getHtmlElementsByTagName("tfoot");
+ assertNotNull(footers);
+ assertEquals(1, footers.size());
+ trs = ((HtmlElement) footers.get(0)).getHtmlElementsByTagName("tr");
+ assertTrue(trs.size() > 0);
+ tr = (HtmlElement) trs.get(0);
+ assertNotNull(tr);
+ classAttr = tr.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-footer rich-table-footer"));
+
+ tds = tr.getHtmlElementsByTagName("td");
+ assertTrue(tds.size() > 0);
+ td = (HtmlElement) tds.get(0);
+ assertNotNull(td);
+ classAttr = td.getAttributeValue("class");
+ assertTrue(classAttr
+ .contains("dr-table-footercell rich-table-footercell"));
+
+ List bodies = table.getHtmlElementsByTagName("tbody");
+ assertEquals(1, bodies.size());
+ trs = ((HtmlElement) bodies.get(0)).getHtmlElementsByTagName("tr");
+ assertTrue(trs.size() > 0);
+ tr = (HtmlElement) trs.get(0);
+ assertNotNull(tr);
+ classAttr = tr.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-row rich-table-row"));
+ assertTrue(classAttr.contains("row1"));
+
+ tds = tr.getHtmlElementsByTagName("td");
+ assertTrue(tds.size() > 0);
+ td = (HtmlElement) tds.get(0);
+ assertNotNull(td);
+ classAttr = td.getAttributeValue("class");
+ assertTrue(classAttr.contains("dr-table-cell rich-table-cell"));
+ assertTrue(classAttr.contains("A"));
+ }
+
+ /**
+ * Test UIDataGrid component class.
+ *
+ * @throws Exception
+ */
+ public void testUIDataGrid() throws Exception {
+
+ dataGrid.setColumns(1);
+
+ dataGrid.setElements(5);
+ assertEquals(5, dataGrid.getElements());
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ //System.out.println(page.asXml());
+
+ HtmlElement table = page.getHtmlElementById(dataGrid
+ .getClientId(facesContext));
+ assertNotNull(table);
+ List bodies = table.getHtmlElementsByTagName("tbody");
+ assertEquals(1, bodies.size());
+ List trs = ((HtmlElement) bodies.get(0)).getHtmlElementsByTagName("tr");
+ assertEquals(5, trs.size());
+ }
+
+}
Deleted: trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java
===================================================================
--- trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java 2007-04-13 14:33:24 UTC (rev 406)
+++ trunk/richfaces/dataTable/src/test/java/org/richfaces/component/DataTableComponentTest.java 2007-04-13 14:37:52 UTC (rev 407)
@@ -1,234 +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 java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import javax.faces.component.UIComponent;
-import javax.faces.component.html.HtmlOutputText;
-
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.component.html.HtmlColumnGroup;
-import org.richfaces.component.html.HtmlColumn;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-/**
- * Unit test for simple Component.
- */
-public class DataTableComponentTest extends AbstractAjax4JsfTestCase {
-
- private UIDataTable dataTable;
- private UIDataGrid dataGrid;
-
- /**
- * Create the test case
- *
- * @param testName
- * name of the test case
- */
- public DataTableComponentTest(String testName) {
- super(testName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
-
- dataTable = (UIDataTable) application
- .createComponent("org.richfaces.DataTable");
- dataTable.setId("dataTable");
- List value = new ArrayList();
- value.add("First");
- value.add("Second");
- dataTable.setValue(value);
- facesContext.getViewRoot().getChildren().add(dataTable);
-
- dataGrid = (UIDataGrid) application
- .createComponent("org.richfaces.DataGrid");
- dataGrid.setId("dataGrid");
- facesContext.getViewRoot().getChildren().add(dataGrid);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- dataTable = null;
- }
-
- /**
- * Test component rendering
- *
- * @throws Exception
- */
- public void testRenderDataTable() throws Exception {
-
- HtmlColumnGroup header = (HtmlColumnGroup) application
- .createComponent("org.richfaces.ColumnGroup");
- header.setColumnClasses("cola, colb");
- dataTable.getFacets().put("header", header);
-
- UIComponent caption = createComponent(HtmlOutputText.COMPONENT_TYPE,
- HtmlOutputText.class.getName(), null, null, null);
- dataTable.getFacets().put("caption", caption);
- UIComponent footer = createComponent(HtmlOutputText.COMPONENT_TYPE,
- HtmlOutputText.class.getName(), null, null, null);
- dataTable.getFacets().put("footer", footer);
-
- HtmlColumn column1 = (HtmlColumn) application
- .createComponent("org.richfaces.Column");
- dataTable.getChildren().add(column1);
- HtmlOutputText text = (HtmlOutputText) createComponent(
- HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
- null, null, null);
- text.setValue("Column");
- column1.getChildren().add(text);
-
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- HtmlElement table = page.getHtmlElementById(dataTable
- .getClientId(facesContext));
- assertNotNull(table);
- assertEquals("table", table.getNodeName());
-
- String classAttr = table.getAttributeValue("class");
- assertTrue(classAttr.contains("dr-table rich-table"));
-
- List captions = table.getHtmlElementsByTagName("caption");
- assertNotNull(captions);
- assertEquals(1, captions.size());
-
- classAttr = ((HtmlElement) captions.get(0)).getAttributeValue("class");
- assertTrue(classAttr.contains("dr-table-caption rich-table-caption"));
-
- List headers = table.getHtmlElementsByTagName("thead");
- assertNotNull(headers);
- assertEquals(1, headers.size());
- HtmlElement tr = (HtmlElement) ((HtmlElement) headers.get(0))
- .getFirstChild();
- assertNotNull(tr);
- classAttr = tr.getAttributeValue("class");
- assertTrue(classAttr.contains("dr-table-header rich-table-header"));
-
- List footers = table.getHtmlElementsByTagName("tfoot");
- assertNotNull(footers);
- assertEquals(1, footers.size());
- tr = (HtmlElement) ((HtmlElement) footers.get(0)).getFirstChild();
- assertNotNull(tr);
- classAttr = tr.getAttributeValue("class");
- assertTrue(classAttr.contains("dr-table-footer rich-table-footer"));
-
- List bodies = table.getHtmlElementsByTagName("tbody");
- assertNotNull(bodies);
- assertEquals(1, bodies.size());
- tr = (HtmlElement) ((HtmlElement) bodies.get(0)).getFirstChild();
- assertNotNull(tr);
- classAttr = tr.getAttributeValue("class");
- assertTrue(classAttr.contains("dr-table-firstrow rich-table-firstrow"));
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testRenderSubTable() throws Exception {
- UISubTable subTable = (UISubTable) application
- .createComponent("org.richfaces.SubTable");
- subTable.setId("subTable");
- List value = new ArrayList();
- value.add("First");
- subTable.setValue(value);
-
- dataTable.getChildren().add(subTable);
-
- HtmlColumn column1 = (HtmlColumn) application
- .createComponent("org.richfaces.Column");
- subTable.getChildren().add(column1);
-
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- HtmlElement table = page.getHtmlElementById(dataTable
- .getClientId(facesContext));
- assertNotNull(table);
- assertEquals("table", table.getNodeName());
-
- List bodies = table.getHtmlElementsByTagName("tbody");
- assertNotNull(bodies);
- assertEquals(1, bodies.size());
- List trs = ((HtmlElement) bodies.get(0)).getHtmlElementsByTagName("tr");
- assertNotNull(trs);
-
- Iterator it = trs.iterator();
- boolean found = false;
- for( ; it.hasNext();) {
- HtmlElement tr = (HtmlElement)it.next();
- String classAttr = tr.getAttributeValue("class");
- if (classAttr.contains("dr-subtable-")) {
- found = true;
- break;
- }
- }
- assertTrue(found);
-
- }
-
- public void testRenderDataGrid() throws Exception {
- dataGrid.setColumns(1);
- List value = new ArrayList();
- value.add("First");
- dataGrid.setValue(value);
-
- UIComponent caption = createComponent(HtmlOutputText.COMPONENT_TYPE,
- HtmlOutputText.class.getName(), null, null, null);
- dataGrid.getChildren().add(caption);
-
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- HtmlElement table = page.getHtmlElementById(dataGrid
- .getClientId(facesContext));
- assertNotNull(table);
- assertEquals("table", table.getNodeName());
-
-
- }
-
-}
19 years
JBoss Rich Faces SVN: r406 - trunk/richfaces/menu-components/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-04-13 10:33:24 -0400 (Fri, 13 Apr 2007)
New Revision: 406
Modified:
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
Log:
test development
Modified: trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-04-13 13:49:39 UTC (rev 405)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuGroupComponentTest.java 2007-04-13 14:33:24 UTC (rev 406)
@@ -103,9 +103,48 @@
assertEquals("div", div.getNodeName());
}
+
+ /**
+ * MenuGroup icon test.
+ */
+ public void testMenuGroupIcon() throws Exception {
+ menuGroup.setDisabled(false);
+ menuGroup.getFacets().clear();
+ menuGroup.getAttributes().put("icon", "menuGroupIcon");
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ HtmlElement span = page.getHtmlElementById(menuGroup
+ .getClientId(facesContext)
+ + ":icon");
+ assertEquals("span", span.getNodeName());
+ assertNotNull(span);
+ List images = span.getHtmlElementsByTagName("img");
+ assertNotNull(images);
+ assertEquals(1, images.size());
+ }
+
+ /**
+ * MenuGroup icon test.
+ */
+ public void testMenuGroupIconDisabled() throws Exception {
+ menuGroup.setDisabled(true);
+ menuGroup.getAttributes().put("iconDisabled", "menuGroupIcon");
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ HtmlElement span = page.getHtmlElementById(menuGroup
+ .getClientId(facesContext)
+ + ":icon");
+ assertEquals("span", span.getNodeName());
+ assertNotNull(span);
+ List images = span.getHtmlElementsByTagName("img");
+ assertNotNull(images);
+ assertEquals(1, images.size());
+ }
+
- public void testMenuItemIconFacet() throws Exception
+ public void testMenuGroupIconFacet() throws Exception
{
+ menuGroup.setDisabled(false);
UIComponent facet = createComponent(HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(), null, null , null);
menuGroup.getFacets().put("icon", facet);
HtmlPage page = renderView();
@@ -116,6 +155,19 @@
assertNotNull(span);
}
+ public void testMenuGroupIconFacetDisabled() throws Exception
+ {
+ menuGroup.setDisabled(true);
+ UIComponent facet = createComponent(HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(), null, null , null);
+ menuGroup.getFacets().put("iconDisabled", facet);
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ //System.out.println(page.asXml());
+ HtmlElement span = page.getHtmlElementById("ref" + menuGroup.getClientId(facesContext) + ":icon");
+ assertEquals("span", span.getNodeName());
+ assertNotNull(span);
+ }
+
public void testDisabledMenuItem() throws Exception
{
menuGroup.setDisabled(true);
Modified: trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-04-13 13:49:39 UTC (rev 405)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2007-04-13 14:33:24 UTC (rev 406)
@@ -117,6 +117,23 @@
public void testMenuItemIconFacet() throws Exception {
UIComponent text = createComponent(HtmlOutputText.COMPONENT_TYPE,
HtmlOutputText.class.getName(), null, null, null);
+ menuItem.getFacets().put("icon", text);
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ // System.out.println(page.asXml());
+ HtmlElement span = page.getHtmlElementById(menuItem
+ .getClientId(facesContext)
+ + ":icon");
+ assertEquals("span", span.getNodeName());
+ assertNotNull(span);
+ }
+
+ /**
+ * MenuItem facet test.
+ */
+ public void testMenuItemDisabledIconFacet() throws Exception {
+ UIComponent text = createComponent(HtmlOutputText.COMPONENT_TYPE,
+ HtmlOutputText.class.getName(), null, null, null);
menuItem.getFacets().put("iconDisabled", text);
HtmlPage page = renderView();
assertNotNull(page);
19 years
JBoss Rich Faces SVN: r405 - in trunk/richfaces/dropdown-menu/src: main/java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-13 09:49:39 -0400 (Fri, 13 Apr 2007)
New Revision: 405
Modified:
trunk/richfaces/dropdown-menu/src/main/config/component/dropdownmenu.xml
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/component/UIDropDownMenu.java
trunk/richfaces/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
Log:
small refactoring. test updated
Modified: trunk/richfaces/dropdown-menu/src/main/config/component/dropdownmenu.xml
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/config/component/dropdownmenu.xml 2007-04-13 13:48:45 UTC (rev 404)
+++ trunk/richfaces/dropdown-menu/src/main/config/component/dropdownmenu.xml 2007-04-13 13:49:39 UTC (rev 405)
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
<components>
- <component>
- <name>org.richfaces.DropDownMenu</name>
- <family>org.richfaces.DropDownMenu</family>
- <classname>org.richfaces.component.html.HtmlDropDownMenu</classname>
- <superclass>org.richfaces.component.UIDropDownMenu</superclass>
- <description>
- <![CDATA[ ]]>
- </description>
+ <component>
+ <name>org.richfaces.DropDownMenu</name>
+ <family>org.richfaces.DropDownMenu</family>
+ <classname>org.richfaces.component.html.HtmlDropDownMenu</classname>
+ <superclass>org.richfaces.component.UIDropDownMenu</superclass>
+ <description>
+ <![CDATA[ ]]>
+ </description>
- <renderer generate="true" override="true">
- <name>org.richfaces.DropDownMenuRenderer</name>
- <template>org/richfaces/htmlDropDownMenu.jspx</template>
- </renderer>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.DropDownMenuRenderer</name>
+ <template>org/richfaces/htmlDropDownMenu.jspx</template>
+ </renderer>
- <tag>
- <name>dropDownMenu</name>
- <classname>org.richfaces.taglib.DropDownMenuTag</classname>
- <superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
- </superclass>
- </tag>
+ <tag>
+ <name>dropDownMenu</name>
+ <classname>org.richfaces.taglib.DropDownMenuTag</classname>
+ <superclass>
+ org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ </superclass>
+ </tag>
<taghandler generate="true">
<classname>org.richfaces.taglib.DropDownMenuTagHandler</classname>
@@ -30,203 +30,208 @@
&ui_component_attributes;
- <property>
- <name>event</name>
- <classname>java.lang.String</classname>
- <description>
- Defines the event on the representation element that triggers the menu's appearance.
- </description>
- </property>
+ <property>
+ <name>event</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Defines the event on the representation element that triggers
+ the menu's appearance.
+ </description>
+ </property>
- <property>
- <name>mode</name>
- <classname>java.lang.String</classname>
- <description>
- Set the submission mode for all menu items of the menu except ones where this attribute redefined. (ajax,server(Default),none)
- </description>
- <defaultvalue>"server"</defaultvalue>
- </property>
+ <property>
+ <name>mode</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Set the submission mode for all menu items of the menu except
+ ones where this attribute redefined. (ajax,server(Default),none)
+ </description>
+ <defaultvalue>"server"</defaultvalue>
+ </property>
- <property>
- <name>showDelay</name>
- <classname>java.lang.Integer</classname>
- <description>
- Delay between event and menu showing.
- </description>
- <defaultvalue><![CDATA[new Integer(300)]]></defaultvalue>
- </property>
+ <property>
+ <name>showDelay</name>
+ <classname>java.lang.Integer</classname>
+ <description>
+ Delay between event and menu showing.
+ </description>
+ <defaultvalue><![CDATA[new Integer(300)]]></defaultvalue>
+ </property>
- <property>
- <name>hideDelay</name>
- <classname>java.lang.Integer</classname>
- <description>
- Delay between losing focus and menu closing.
- </description>
- <defaultvalue><![CDATA[new Integer(300)]]></defaultvalue>
- </property>
+ <property>
+ <name>hideDelay</name>
+ <classname>java.lang.Integer</classname>
+ <description>
+ Delay between losing focus and menu closing.
+ </description>
+ <defaultvalue><![CDATA[new Integer(300)]]></defaultvalue>
+ </property>
- <property>
- <name>value</name>
- <classname>java.lang.Object</classname>
- <description>
- Defines representation text for Label used for menu calls.
- </description>
- </property>
+ <property>
+ <name>value</name>
+ <classname>java.lang.Object</classname>
+ <description>
+ Defines representation text for Label used for menu calls.
+ </description>
+ </property>
- <property>
- <name>direction</name>
- <classname>java.lang.String</classname>
- <description>
- Defines direction of the popup list to appear (top-right, top-left bottom-right, bottom-left, auto(default))
- </description>
- <defaultvalue>"auto"</defaultvalue>
- </property>
+ <property>
+ <name>direction</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Defines direction of the popup list to appear (top-right,
+ top-left bottom-right, bottom-left, auto(default))
+ </description>
+ <defaultvalue>"auto"</defaultvalue>
+ </property>
- <property>
- <name>popupWidth</name>
- <classname>java.lang.String</classname>
- <description>
- Set minimal width for the all of the lists that will appear.
- </description>
- </property>
+ <property>
+ <name>popupWidth</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Set minimal width for the all of the lists that will appear.
+ </description>
+ </property>
- <property>
- <name>jointPoint</name>
- <classname>java.lang.String</classname>
- <description>
- Set the corner of the label for the popup to be connected with. (auto(default), tr, tl, bl, br, where tr – top-right)
- </description>
- <defaultvalue>"auto"</defaultvalue>
- </property>
+ <property>
+ <name>jointPoint</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Set the corner of the label for the popup to be connected with.
+ (auto(default), tr, tl, bl, br, where tr – top-right)
+ </description>
+ <defaultvalue>"auto"</defaultvalue>
+ </property>
- <property>
- <name>horizontalOffset</name>
- <classname>int</classname>
- <description>
- Sets the horizontal offset between popup list and label element conjunction point
- </description>
- <defaultvalue><![CDATA[0]]></defaultvalue>
- </property>
+ <property>
+ <name>horizontalOffset</name>
+ <classname>int</classname>
+ <description>
+ Sets the horizontal offset between popup list and label element
+ conjunction point
+ </description>
+ <defaultvalue><![CDATA[0]]></defaultvalue>
+ </property>
- <property>
- <name>verticalOffset</name>
- <classname>int</classname>
- <description>
- Sets the vertical offset between popup list and label element conjunction point
- </description>
- <defaultvalue><![CDATA[0]]></defaultvalue>
- </property>
+ <property>
+ <name>verticalOffset</name>
+ <classname>int</classname>
+ <description>
+ Sets the vertical offset between popup list and label element
+ conjunction point
+ </description>
+ <defaultvalue><![CDATA[0]]></defaultvalue>
+ </property>
- &html_style_attributes;
+ &html_style_attributes;
- <property>
- <name>selectItemStyle</name>
- <classname>java.lang. String</classname>
- <description>
- </description>
- </property>
+ <property>
+ <name>selectItemStyle</name>
+ <classname>java.lang. String</classname>
+ <description>
+ </description>
+ </property>
- <property>
- <name>selectItemClass</name>
- <classname>java.lang.String</classname>
- <description>
- </description>
- </property>
+ <property>
+ <name>selectItemClass</name>
+ <classname>java.lang.String</classname>
+ <description>
+ </description>
+ </property>
- <property>
- <name>disabledItemStyle</name>
- <classname>java.lang.String</classname>
- <description>
- </description>
- </property>
+ <property>
+ <name>disabledItemStyle</name>
+ <classname>java.lang.String</classname>
+ <description>
+ </description>
+ </property>
- <property>
- <name>disabledItemClass</name>
- <classname>java.lang.String</classname>
- <description>
- </description>
- </property>
+ <property>
+ <name>disabledItemClass</name>
+ <classname>java.lang.String</classname>
+ <description>
+ </description>
+ </property>
- <property>
- <name>itemStyle</name>
- <classname>java.lang.String</classname>
- <description>
- </description>
- </property>
+ <property>
+ <name>itemStyle</name>
+ <classname>java.lang.String</classname>
+ <description>
+ </description>
+ </property>
- <property>
- <name>itemClass</name>
- <classname>java.lang.String</classname>
- <description>
- </description>
- </property>
+ <property>
+ <name>itemClass</name>
+ <classname>java.lang.String</classname>
+ <description>
+ </description>
+ </property>
- <property>
- <name>oncollapse</name>
- <classname>java.lang.String</classname>
- <description>
- Event must occurs on menu closure
- </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ <property>
+ <name>oncollapse</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Event must occurs on menu closure
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
- <property>
- <name>onexpand</name>
- <classname>java.lang.String</classname>
- <description>
- Event must occurs on menu opening
- </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ <property>
+ <name>onexpand</name>
+ <classname>java.lang.String</classname>
+ <description>
+ Event must occurs on menu opening
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
- <property>
- <name>onmouseout</name>
- <classname>java.lang.String</classname>
- <description>
- HTML: script expression; a pointer was moved away.
- </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ <property>
+ <name>onmouseout</name>
+ <classname>java.lang.String</classname>
+ <description>
+ HTML: script expression; a pointer was moved away.
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
- <property>
- <name>onmousemove</name>
- <classname>java.lang.String</classname>
- <description>
- HTML: script expression; a pointer was moved within.
- </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ <property>
+ <name>onmousemove</name>
+ <classname>java.lang.String</classname>
+ <description>
+ HTML: script expression; a pointer was moved within.
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
- <property>
- <name>onmouseover</name>
- <classname>java.lang.String</classname>
- <description>
- HTML: script expression; a pointer was moved onto.
- </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ <property>
+ <name>onmouseover</name>
+ <classname>java.lang.String</classname>
+ <description>
+ HTML: script expression; a pointer was moved onto.
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
- <property>
- <name>onitemselect</name>
- <classname>java.lang.String</classname>
- <description>
- HTML: script expression; some item was selected.
- </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ <property>
+ <name>onitemselect</name>
+ <classname>java.lang.String</classname>
+ <description>
+ HTML: script expression; some item was selected.
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
- <property>
- <name>ongroupactivate</name>
- <classname>java.lang.String</classname>
- <description>
- HTML: script expression; some group was activated.
- </description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ <property>
+ <name>ongroupactivate</name>
+ <classname>java.lang.String</classname>
+ <description>
+ HTML: script expression; some group was activated.
+ </description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
-
- </component>
+ </component>
</components>
Modified: trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/component/UIDropDownMenu.java
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/component/UIDropDownMenu.java 2007-04-13 13:48:45 UTC (rev 404)
+++ trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/component/UIDropDownMenu.java 2007-04-13 13:49:39 UTC (rev 405)
@@ -26,18 +26,17 @@
/**
* JSF component class
- *
*/
public abstract class UIDropDownMenu extends UIComponentBase implements MenuComponent {
- public static final String COMPONENT_TYPE = "org.richfaces.dropDownMenu";
-
-
+ public static final String COMPONENT_TYPE = "org.richfaces.DropDownMenu";
+
public abstract void setEvent(String Event);
+
public abstract String getEvent();
-
+
public abstract void setMode(String mode);
+
public abstract String getMode();
-
}
Modified: trunk/richfaces/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java
===================================================================
--- trunk/richfaces/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-04-13 13:48:45 UTC (rev 404)
+++ trunk/richfaces/dropdown-menu/src/test/java/org/richfaces/component/DropDownMenuComponentTest.java 2007-04-13 13:49:39 UTC (rev 405)
@@ -25,15 +25,11 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlScript;
-import org.richfaces.event.SwitchablePanelSwitchEvent;
-import org.richfaces.component.UISwitchablePanel;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
import org.apache.commons.lang.StringUtils;
-import javax.faces.component.UIComponent;
+
import javax.faces.component.UIForm;
-import javax.faces.component.UIOutput;
import javax.faces.component.html.HtmlForm;
-import javax.faces.event.ActionEvent;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -45,7 +41,7 @@
public class DropDownMenuComponentTest extends AbstractAjax4JsfTestCase {
private static Set javaScripts = new HashSet();
- static {
+ static {
javaScripts.add("prototype.js");
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
javaScripts.add("scripts/menu.js");
@@ -68,16 +64,52 @@
*/
public void setUp() throws Exception {
super.setUp();
-
-
-
+
form = new HtmlForm();
form.setId("form");
facesContext.getViewRoot().getChildren().add(form);
dropDownMenu = (UIDropDownMenu)application.createComponent("org.richfaces.DropDownMenu");
dropDownMenu.setId("DropDownMenu");
form.getChildren().add(dropDownMenu);
-
+
+ UIMenuItem item = (UIMenuItem)application.createComponent("org.richfaces.MenuItem");
+ item.setId("item11");
+ item.setValue("Item 11");
+ dropDownMenu.getChildren().add(item);
+
+ UIMenuGroup group = (UIMenuGroup)application.createComponent("org.richfaces.MenuGroup");
+ group.setId("group1");
+ group.setValue("Group 1");
+ dropDownMenu.getChildren().add(group);
+
+ item = (UIMenuItem)application.createComponent("org.richfaces.MenuItem");
+ item.setId("item12");
+ item.setValue("Item 12");
+ dropDownMenu.getChildren().add(item);
+
+ UIMenuSeparator separator = (UIMenuSeparator)application.createComponent("org.richfaces.MenuSeparator");
+ separator.setId("separator1");
+ dropDownMenu.getChildren().add(separator);
+
+ item = (UIMenuItem)application.createComponent("org.richfaces.MenuItem");
+ item.setId("item13");
+ item.setValue("Item 13");
+ dropDownMenu.getChildren().add(item);
+
+ //---------------------------------------------------------------------
+ item = (UIMenuItem)application.createComponent("org.richfaces.MenuItem");
+ item.setId("item21");
+ item.setValue("Item 21");
+ group.getChildren().add(item);
+
+ separator = (UIMenuSeparator)application.createComponent("org.richfaces.MenuSeparator");
+ separator.setId("separator2");
+ group.getChildren().add(separator);
+
+ item = (UIMenuItem)application.createComponent("org.richfaces.MenuItem");
+ item.setId("item22");
+ item.setValue("Item 22");
+ group.getChildren().add(item);
}
/* (non-Javadoc)
@@ -85,8 +117,8 @@
*/
public void tearDown() throws Exception {
super.tearDown();
- dropDownMenu = null;
- form = null;
+ dropDownMenu = null;
+ form = null;
}
/**
@@ -94,7 +126,7 @@
*
* @throws Exception
*/
-
+
public void testRender() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
@@ -121,12 +153,12 @@
HtmlElement link = (HtmlElement) links.get(0);
assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/dropdownmenu.xcss"));
}
-
+
/**
* Test script rendering
*
* @throws Exception
- */
+ */
public void testRenderScript() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
@@ -147,8 +179,8 @@
}
}
}
-
-
+
+
}
19 years
JBoss Rich Faces SVN: r404 - in trunk/richfaces/menu-components/src/main: java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-13 09:48:45 -0400 (Fri, 13 Apr 2007)
New Revision: 404
Modified:
trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuSeparator.java
Log:
small refactoring
Modified: trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml
===================================================================
--- trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml 2007-04-13 13:32:00 UTC (rev 403)
+++ trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml 2007-04-13 13:48:45 UTC (rev 404)
@@ -1,246 +1,268 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
<components>
- <component>
- <name>org.richfaces.MenuGroup</name>
- <family>org.richfaces.DropDownMenu</family>
- <classname>org.richfaces.component.html.HtmlMenuGroup</classname>
- <superclass>org.richfaces.component.UIMenuGroup</superclass>
+ <component>
+ <name>org.richfaces.MenuGroup</name>
+ <family>org.richfaces.DropDownMenu</family>
+ <classname>org.richfaces.component.html.HtmlMenuGroup</classname>
+ <superclass>org.richfaces.component.UIMenuGroup</superclass>
<description>
<![CDATA[
Defines expandable group of items inside popup list or another group. Should accept only "menuItem", "menuGroup" and "menuSeparator" components as children.
]]>
</description>
- <renderer generate="true" override="true">
- <name>org.richfaces.MenuGroupRenderer</name>
- <template>org/richfaces/htmlMenuGroup.jspx</template>
- </renderer>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.MenuGroupRenderer</name>
+ <template>org/richfaces/htmlMenuGroup.jspx</template>
+ </renderer>
- <tag>
- <name>menuGroup</name>
- <classname>org.richfaces.taglib.MenuGroupTag</classname>
- <superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
- </superclass>
- </tag>
+ <tag>
+ <name>menuGroup</name>
+ <classname>org.richfaces.taglib.MenuGroupTag</classname>
+ <superclass>
+ org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ </superclass>
+ </tag>
- <property>
- <name>icon</name>
- <classname>java.lang.String</classname>
- <description>Path to the icon to be displayed for the enabled item state</description>
- </property>
- <property>
- <name>iconDisabled</name>
- <classname>java.lang.String</classname>
- <description>Path to the icon to be displayed for the disabled item state</description>
- </property>
- <property>
- <name>disabled</name>
- <classname>boolean</classname>
- <description>If "true" sets state of the item to disabled state. "false" is default.</description>
- <defaultvalue>false</defaultvalue>
- </property>
- <property required="true">
- <name>value</name>
- <classname>java.lang.Object</classname>
- <description>Defines representation text for menuItem.</description>
- </property>
- <property>
- <name>direction</name>
- <classname>java.lang.String</classname>
- <description>Defines direction of the popup sublist to appear (right, left, auto(Default))</description>
- </property>
- <property>
- <name>iconFolder</name>
- <classname>java.lang.String</classname>
- <description>Path to the folder icon to be displayed for the enabled item state</description>
- </property>
- <property>
- <name>iconFolderDisabled</name>
- <classname>java.lang.String</classname>
- <description>Path to the folder icon to be displayed for the enabled item state</description>
- </property>
- <property>
- <name>event</name>
- <classname>java.lang.String</classname>
- <description>Defines the event on the representation element that triggers the menu's appearance.</description>
- <defaultvalue>"onmouseover"</defaultvalue>
- </property>
- <property>
- <name>showDelay</name>
- <classname>java.lang.Integer</classname>
- <description>Delay between event and menu showing.</description>
- <defaultvalue><![CDATA[new Integer(300)]]></defaultvalue>
- </property>
- <property>
- <name>onmousemove</name>
- <classname>java.lang.String</classname>
- <description>HTML: a script expression; a pointer is moved within</description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
- <property>
- <name>onmouseout</name>
- <classname>java.lang.String</classname>
- <description>HTML: a script expression; a pointer is moved away</description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
- <property>
- <name>onmouseover</name>
- <classname>java.lang.String</classname>
- <description>HTML: a script expression; a pointer is moved onto</description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
- <property>
- <name>onopen</name>
- <classname>java.lang.String</classname>
- <description>HTML: script expression; group was opened.</description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
- <property>
- <name>onclose</name>
- <classname>java.lang.String</classname>
- <description>HTML: script expression; group was closed.</description>
- <defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ <property>
+ <name>icon</name>
+ <classname>java.lang.String</classname>
+ <description>Path to the icon to be displayed for the enabled item
+ state</description>
+ </property>
+ <property>
+ <name>iconDisabled</name>
+ <classname>java.lang.String</classname>
+ <description>Path to the icon to be displayed for the disabled item
+ state</description>
+ </property>
+ <property>
+ <name>disabled</name>
+ <classname>boolean</classname>
+ <description>If "true" sets state of the item to disabled state.
+ "false" is default.</description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <property required="true">
+ <name>value</name>
+ <classname>java.lang.Object</classname>
+ <description>Defines representation text for menuItem.</description>
+ </property>
+ <property>
+ <name>direction</name>
+ <classname>java.lang.String</classname>
+ <description>Defines direction of the popup sublist to appear
+ (right, left, auto(Default))</description>
+ </property>
+ <property>
+ <name>iconFolder</name>
+ <classname>java.lang.String</classname>
+ <description>Path to the folder icon to be displayed for the enabled
+ item state</description>
+ </property>
+ <property>
+ <name>iconFolderDisabled</name>
+ <classname>java.lang.String</classname>
+ <description>Path to the folder icon to be displayed for the enabled
+ item state</description>
+ </property>
+ <property>
+ <name>event</name>
+ <classname>java.lang.String</classname>
+ <description>Defines the event on the representation element that
+ triggers the menu's appearance.</description>
+ <defaultvalue>"onmouseover"</defaultvalue>
+ </property>
+ <property>
+ <name>showDelay</name>
+ <classname>java.lang.Integer</classname>
+ <description>Delay between event and menu showing.</description>
+ <defaultvalue><![CDATA[new Integer(300)]]></defaultvalue>
+ </property>
+ <property>
+ <name>onmousemove</name>
+ <classname>java.lang.String</classname>
+ <description>HTML: a script expression; a pointer is moved
+ within</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>onmouseout</name>
+ <classname>java.lang.String</classname>
+ <description>HTML: a script expression; a pointer is moved
+ away</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>onmouseover</name>
+ <classname>java.lang.String</classname>
+ <description>HTML: a script expression; a pointer is moved
+ onto</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>onopen</name>
+ <classname>java.lang.String</classname>
+ <description>HTML: script expression; group was
+ opened.</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>onclose</name>
+ <classname>java.lang.String</classname>
+ <description>HTML: script expression; group was
+ closed.</description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
- <property>
- <name>selectStyle</name>
- <classname>java.lang.String</classname>
- <description>CSS style rules to be applied to selected items.</description>
- </property>
- <property>
- <name>selectClass</name>
- <classname>java.lang.String</classname>
- <description>Class to be applied to selected items.</description>
- </property>
- <property>
- <name>iconStyle</name>
- <classname>java.lang.String</classname>
- <description>CSS style rules to be applied to icon element.</description>
- </property>
- <property>
- <name>iconClass</name>
- <classname>java.lang.String</classname>
- <description>Class to be applied to icon element.</description>
- </property>
+ <property>
+ <name>selectStyle</name>
+ <classname>java.lang.String</classname>
+ <description>CSS style rules to be applied to selected
+ items.</description>
+ </property>
+ <property>
+ <name>selectClass</name>
+ <classname>java.lang.String</classname>
+ <description>Class to be applied to selected items.</description>
+ </property>
+ <property>
+ <name>iconStyle</name>
+ <classname>java.lang.String</classname>
+ <description>CSS style rules to be applied to icon
+ element.</description>
+ </property>
+ <property>
+ <name>iconClass</name>
+ <classname>java.lang.String</classname>
+ <description>Class to be applied to icon element.</description>
+ </property>
- &ui_component_attributes;
- &html_style_attributes;
- </component>
- <component>
- <name>org.richfaces.MenuItem</name>
- <family>org.richfaces.DropDownMenu</family>
- <classname>org.richfaces.component.html.HtmlMenuItem</classname>
- <superclass>org.richfaces.component.UIMenuItem</superclass>
- <description>
- <![CDATA[ ]]>
- </description>
+ &ui_component_attributes;
+ &html_style_attributes;
+ </component>
+ <component>
+ <name>org.richfaces.MenuItem</name>
+ <family>org.richfaces.DropDownMenu</family>
+ <classname>org.richfaces.component.html.HtmlMenuItem</classname>
+ <superclass>org.richfaces.component.UIMenuItem</superclass>
+ <description>
+ <![CDATA[ ]]>
+ </description>
- <renderer generate="true" override="true">
- <name>org.richfaces.MenuItemRenderer</name>
- <template>org/richfaces/htmlMenuItem.jspx</template>
- </renderer>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.MenuItemRenderer</name>
+ <template>org/richfaces/htmlMenuItem.jspx</template>
+ </renderer>
- <tag>
- <name>menuItem</name>
- <classname>org.richfaces.taglib.MenuItemTag</classname>
- <superclass>
- org.ajax4jsf.framework.taglib.HtmlComponentTagBase
- </superclass>
- </tag>
+ <tag>
+ <name>menuItem</name>
+ <classname>org.richfaces.taglib.MenuItemTag</classname>
+ <superclass>
+ org.ajax4jsf.framework.taglib.HtmlComponentTagBase
+ </superclass>
+ </tag>
- <!-- Standart component attributes -->
- &ui_component_attributes;
+ <!-- Standart component attributes -->
+ &ui_component_attributes;
- <!-- Specific component attributes -->
- <property>
- <name>icon</name>
- <classname>java.lang.String</classname>
- <description>Path to the icon to be displayed for the enabled item state</description>
- </property>
- <property>
- <name>iconDisabled</name>
- <classname>java.lang.String</classname>
- <description>Path to the icon to be displayed for the disabled item state</description>
- </property>
- <property>
- <name>disabled</name>
- <classname>boolean</classname>
- <description>If "true" sets state of the item to disabled state. "false" is default</description>
- <defaultvalue>false</defaultvalue>
- </property>
- <!-- property>
- <name>value</name>
- <classname>java.lang.Object</classname>
- <description>Defines representation text for menuItem</description>
- </property -->
- <property>
- <name>mode</name>
- <classname>java.lang.String</classname>
- <description>Set the submission mode (ajax, server(Default), none)</description>
- </property>
+ <!-- Specific component attributes -->
+ <property>
+ <name>icon</name>
+ <classname>java.lang.String</classname>
+ <description>Path to the icon to be displayed for the enabled item
+ state</description>
+ </property>
+ <property>
+ <name>iconDisabled</name>
+ <classname>java.lang.String</classname>
+ <description>Path to the icon to be displayed for the disabled item
+ state</description>
+ </property>
+ <property>
+ <name>disabled</name>
+ <classname>boolean</classname>
+ <description>If "true" sets state of the item to disabled state.
+ "false" is default</description>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <!-- property>
+ <name>value</name>
+ <classname>java.lang.Object</classname>
+ <description>Defines representation text for menuItem</description>
+ </property -->
+ <property>
+ <name>mode</name>
+ <classname>java.lang.String</classname>
+ <description>Set the submission mode (ajax, server(Default),
+ none)</description>
+ </property>
- <!-- Command attributes -->
- &ui_command_attributes;
- <property>
- <name>target</name>
- <classname>java.lang.Object</classname>
- <description>Name of a frame where the resource retrieved via this hyperlink is to be displayed</description>
- <defaultvalue>""</defaultvalue>
- </property>
+ <!-- Command attributes -->
+ &ui_command_attributes;
+ <property>
+ <name>target</name>
+ <classname>java.lang.Object</classname>
+ <description>Name of a frame where the resource retrieved via this
+ hyperlink is to be displayed</description>
+ <defaultvalue>""</defaultvalue>
+ </property>
- <!-- Events attributes -->
- &html_events;
- <property>
- <name>onselect</name>
- <classname>java.lang.String</classname>
- <description>HTML: script expression; The onselect event occurs when a user selects some menu item.</description>
- <defaultvalue>""</defaultvalue>
- </property>
- <property hidden="true">
- <name>ondblclick</name>
- <classname>java.lang.String</classname>
+ <!-- Events attributes -->
+ &html_events;
+ <property>
+ <name>onselect</name>
+ <classname>java.lang.String</classname>
+ <description>HTML: script expression; The onselect event occurs when
+ a user selects some menu item.</description>
+ <defaultvalue>""</defaultvalue>
</property>
<property hidden="true">
- <name>onkeydown</name>
- <classname>java.lang.String</classname>
+ <name>ondblclick</name>
+ <classname>java.lang.String</classname>
</property>
<property hidden="true">
- <name>onkeypress</name>
- <classname>java.lang.String</classname>
+ <name>onkeydown</name>
+ <classname>java.lang.String</classname>
</property>
<property hidden="true">
- <name>onkeyup</name>
- <classname>java.lang.String</classname>
+ <name>onkeypress</name>
+ <classname>java.lang.String</classname>
</property>
+ <property hidden="true">
+ <name>onkeyup</name>
+ <classname>java.lang.String</classname>
+ </property>
<!-- Style Attributes -->
&html_style_attributes;
<property>
- <name>selectClass</name>
- <classname>java.lang.String</classname>
- <description>Class to be applied to selected items</description>
- </property>
- <property>
- <name>selectStyle</name>
- <classname>java.lang.String</classname>
- <description>CSS style rules to be applied to selected items</description>
- </property>
- <property>
- <name>iconClass</name>
- <classname>java.lang.String</classname>
- <description>Class to be applied to icon element</description>
- </property>
- <property>
- <name>iconStyle</name>
- <classname>java.lang.String</classname>
- <description>CSS style rules to be applied to icon element</description>
- </property>
+ <name>selectClass</name>
+ <classname>java.lang.String</classname>
+ <description>Class to be applied to selected items</description>
+ </property>
+ <property>
+ <name>selectStyle</name>
+ <classname>java.lang.String</classname>
+ <description>CSS style rules to be applied to selected
+ items</description>
+ </property>
+ <property>
+ <name>iconClass</name>
+ <classname>java.lang.String</classname>
+ <description>Class to be applied to icon element</description>
+ </property>
+ <property>
+ <name>iconStyle</name>
+ <classname>java.lang.String</classname>
+ <description>CSS style rules to be applied to icon
+ element</description>
+ </property>
- &ajax_component_attributes;
- </component>
+ &ajax_component_attributes;
+ </component>
<component>
<name>org.richfaces.MenuSeparator</name>
<family>org.richfaces.DropDownMenu</family>
@@ -258,7 +280,8 @@
<tag bodyContent="empty">
<name>menuSeparator</name>
<classname>org.richfaces.taglib.MenuSeparatorTag</classname>
- <superclass>org.ajax4jsf.framework.taglib.UIComponentTagBase</superclass>
+ <superclass>
+ org.ajax4jsf.framework.taglib.UIComponentTagBase</superclass>
</tag>
&ui_component_attributes;
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java 2007-04-13 13:32:00 UTC (rev 403)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuGroup.java 2007-04-13 13:48:45 UTC (rev 404)
@@ -26,11 +26,11 @@
/**
* JSF component class
- *
*/
public abstract class UIMenuGroup extends UIOutput {
+ public static final String COMPONENT_TYPE = "org.richfaces.MenuGroup";
- public abstract boolean isDisabled();
- public abstract void setDisabled(boolean disabled);
+ public abstract boolean isDisabled();
+ public abstract void setDisabled(boolean disabled);
}
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java 2007-04-13 13:32:00 UTC (rev 403)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuItem.java 2007-04-13 13:48:45 UTC (rev 404)
@@ -26,30 +26,30 @@
import org.ajax4jsf.framework.ajax.AjaxActionComponent;
import org.ajax4jsf.framework.ajax.AjaxComponent;
import org.ajax4jsf.framework.ajax.AjaxSource;
-
+
/**
* JSF component class
*
*/
public abstract class UIMenuItem extends AjaxActionComponent implements AjaxComponent, AjaxSource, ActionSource {
-
- public static final String COMPONENT_TYPE = "org.richfaces.DropDownMenu";
-
-
+
+ public static final String COMPONENT_TYPE = "org.richfaces.MenuItem";
+
+
public abstract String getMode();
public abstract void setMode(String mode);
-
+
public abstract Object getValue();
public abstract void setValue(Object value);
-
+
public abstract String getIcon();
public abstract void setIcon(String icon);
-
+
public abstract String getIconDisabled();
public abstract void setIconDisabled(String iconDisabled);
-
+
public abstract boolean isDisabled();
- public abstract void setDisabled(boolean disabled);
+ public abstract void setDisabled(boolean disabled);
}
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuSeparator.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuSeparator.java 2007-04-13 13:32:00 UTC (rev 403)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/component/UIMenuSeparator.java 2007-04-13 13:48:45 UTC (rev 404)
@@ -29,5 +29,7 @@
*
*/
public abstract class UIMenuSeparator extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.MenuSeparator";
}
19 years
JBoss Rich Faces SVN: r403 - trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-04-13 09:32:00 -0400 (Fri, 13 Apr 2007)
New Revision: 403
Modified:
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
error in event support(onmouseout and onmouseover) fixed
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-13 13:07:38 UTC (rev 402)
+++ trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-04-13 13:32:00 UTC (rev 403)
@@ -840,10 +840,10 @@
item.obj = $(itemId);
item.menu = this;
item.options = options || {};
- if (item.options.onmouseover != ""){
+ if (item.options.onmouseover && item.options.onmouseover != ""){
item.eventOnMouseOver = new Function("event",item.options.onmouseover).bindAsEventListener(item);
}
- if (item.options.onmouseout != ""){
+ if (item.options.onmouseout && item.options.onmouseout != ""){
item.eventOnMouseOut = new Function("event",item.options.onmouseout).bindAsEventListener(item);
}
this.items[itemId] = item;
19 years
JBoss Rich Faces SVN: r402 - trunk/richfaces/datascroller/src/test/java/org/richfaces/event.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-13 09:07:38 -0400 (Fri, 13 Apr 2007)
New Revision: 402
Modified:
trunk/richfaces/datascroller/src/test/java/org/richfaces/event/DataScrollerEventTest.java
Log:
test updated
Modified: trunk/richfaces/datascroller/src/test/java/org/richfaces/event/DataScrollerEventTest.java
===================================================================
--- trunk/richfaces/datascroller/src/test/java/org/richfaces/event/DataScrollerEventTest.java 2007-04-13 13:04:16 UTC (rev 401)
+++ trunk/richfaces/datascroller/src/test/java/org/richfaces/event/DataScrollerEventTest.java 2007-04-13 13:07:38 UTC (rev 402)
@@ -25,8 +25,8 @@
import javax.faces.component.UIData;
import javax.faces.component.html.HtmlDataTable;
+import javax.faces.event.FacesListener;
import javax.faces.event.PhaseId;
-import javax.faces.event.FacesListener;
/**
* Unit test for DataScrollerEvent.
@@ -35,6 +35,8 @@
private DataScrollerEvent event;
private UIData data;
+ private boolean result;
+
/**
* Create the test case
*
@@ -52,6 +54,7 @@
data = (UIData) application.createComponent(HtmlDataTable.COMPONENT_TYPE);
event = new DataScrollerEvent(data, "old", "new");
+ result = false;
}
/* (non-Javadoc)
@@ -69,6 +72,9 @@
assertEquals("new", event.getNewScrolVal());
assertFalse(event.isAppropriateListener(new TestFacesListener()));
assertTrue(event.isAppropriateListener(new TestDataScrollerListener()));
+
+ event.processListener(new TestDataScrollerListener());
+ assertTrue(result);
}
class TestFacesListener implements FacesListener {
@@ -77,6 +83,7 @@
class TestDataScrollerListener implements DataScrollerListener {
public void processScroller(DataScrollerEvent event) {
+ result = true;
}
}
}
19 years
JBoss Rich Faces SVN: r401 - in trunk/richfaces/simpleTogglePanel/src: test/java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-13 09:04:16 -0400 (Fri, 13 Apr 2007)
New Revision: 401
Added:
trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleToggleEventTest.java
Modified:
trunk/richfaces/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java
Log:
test updated
Modified: trunk/richfaces/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java
===================================================================
--- trunk/richfaces/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java 2007-04-13 12:36:35 UTC (rev 400)
+++ trunk/richfaces/simpleTogglePanel/src/main/java/org/richfaces/renderkit/html/SimpleTogglePanelRenderer.java 2007-04-13 13:04:16 UTC (rev 401)
@@ -157,13 +157,6 @@
return onClick.toString();
}
- private String getDivId(String panelId, String state) {
- if (state != null) {
- return panelId + "_" + state;
- }
- return null;
- }
-
protected String getValueAsString(FacesContext context, UISimpleTogglePanel Panel) {
return getUtils().getValueAsString(context, Panel);
}
Added: trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleToggleEventTest.java
===================================================================
--- trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleToggleEventTest.java (rev 0)
+++ trunk/richfaces/simpleTogglePanel/src/test/java/org/richfaces/component/SimpleToggleEventTest.java 2007-04-13 13:04:16 UTC (rev 401)
@@ -0,0 +1,90 @@
+/**
+ * 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 org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.event.ISimpleToggleListener;
+import org.richfaces.event.SimpleToggleEvent;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * Unit test for SuggestionEvent.
+ */
+public class SimpleToggleEventTest extends AbstractAjax4JsfTestCase {
+
+ private SimpleToggleEvent event;
+ private UISimpleTogglePanel stp;
+ private boolean result;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public SimpleToggleEventTest(String testName) {
+ super(testName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ stp = (UISimpleTogglePanel)application.createComponent("org.richfaces.SimpleTogglePanel");
+ stp.setId("simpleTogglePanel1");
+ result = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ event = null;
+ stp = null;
+ }
+
+ public void testEvent() throws Exception {
+ event = new SimpleToggleEvent(stp, false);
+ assertFalse(event.isIsOpen());
+ event.setIsOpen(true);
+ assertTrue(event.isIsOpen());
+
+ assertFalse(event.isAppropriateListener(new TestFacesListener()));
+ assertTrue(event.isAppropriateListener(new TestSimpleToggleListener()));
+
+ event.processListener(new TestSimpleToggleListener());
+ assertTrue(result);
+ }
+
+ class TestFacesListener implements FacesListener {
+
+ }
+
+ class TestSimpleToggleListener implements ISimpleToggleListener {
+ public void processToggle(SimpleToggleEvent event) {
+ result = true;
+ }
+ }
+}
19 years
JBoss Rich Faces SVN: r400 - trunk/richfaces/toolBar/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-13 08:36:35 -0400 (Fri, 13 Apr 2007)
New Revision: 400
Modified:
trunk/richfaces/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java
Log:
test updated
Modified: trunk/richfaces/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java
===================================================================
--- trunk/richfaces/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java 2007-04-13 12:26:52 UTC (rev 399)
+++ trunk/richfaces/toolBar/src/test/java/org/richfaces/component/ToolBarComponentTest.java 2007-04-13 12:36:35 UTC (rev 400)
@@ -21,15 +21,21 @@
package org.richfaces.component;
+import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import junit.framework.Assert;
+import org.ajax4jsf.framework.resource.InternetResource;
+import org.ajax4jsf.framework.resource.InternetResourceBuilder;
+import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
+import org.ajax4jsf.framework.util.image.ImageInfo;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.richfaces.component.html.HtmlToolBarGroup;
+import javax.faces.component.UICommand;
import javax.faces.component.UIForm;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlForm;
+import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
@@ -38,9 +44,6 @@
public class ToolBarComponentTest extends AbstractAjax4JsfTestCase {
private UIToolBar toolBar;
- private UIToolBarGroup toolBarGroup;
- private HtmlCommandButton button1;
- private HtmlCommandButton button2;
private UIForm form;
/**
@@ -62,20 +65,48 @@
form.setId("form");
facesContext.getViewRoot().getChildren().add(form);
- toolBar = (UIToolBar)application.createComponent("org.richfaces.ToolBar");
+ toolBar = (UIToolBar) application.createComponent("org.richfaces.ToolBar");
toolBar.setId("toolBar");
+ toolBar.setItemSeparator("square");
form.getChildren().add(toolBar);
- button1 = (HtmlCommandButton)application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
- button1.setValue("Change 1");
- toolBar.getChildren().add(button1);
+ UICommand button = (UICommand) application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
+ button.setValue("Change");
+ toolBar.getChildren().add(button);
- toolBarGroup = (HtmlToolBarGroup)application.createComponent("org.richfaces.ToolBarGroup");
- button2 = (HtmlCommandButton)application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
- button2.setValue("Change 2");
- toolBarGroup.getChildren().add(button2);
+ button = (UICommand) application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
+ button.setValue("Change");
+ toolBar.getChildren().add(button);
+ UIToolBarGroup toolBarGroup = (UIToolBarGroup) application.createComponent("org.richfaces.ToolBarGroup");
+ toolBarGroup.setItemSeparator("disc");
+ button = (HtmlCommandButton) application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
+ button.setValue("Change");
+ toolBarGroup.getChildren().add(button);
+ button = (HtmlCommandButton) application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
+ button.setValue("Change");
+ toolBarGroup.getChildren().add(button);
toolBar.getChildren().add(toolBarGroup);
+
+ toolBarGroup = (UIToolBarGroup) application.createComponent("org.richfaces.ToolBarGroup");
+ toolBarGroup.setItemSeparator("grid");
+ button = (HtmlCommandButton) application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
+ button.setValue("Change");
+ toolBarGroup.getChildren().add(button);
+ button = (HtmlCommandButton) application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
+ button.setValue("Change");
+ toolBarGroup.getChildren().add(button);
+ toolBar.getChildren().add(toolBarGroup);
+
+ toolBarGroup = (UIToolBarGroup) application.createComponent("org.richfaces.ToolBarGroup");
+ toolBarGroup.setItemSeparator("line");
+ button = (HtmlCommandButton) application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
+ button.setValue("Change");
+ toolBarGroup.getChildren().add(button);
+ button = (HtmlCommandButton) application.createComponent(HtmlCommandButton.COMPONENT_TYPE);
+ button.setValue("Change");
+ toolBarGroup.getChildren().add(button);
+ toolBar.getChildren().add(toolBarGroup);
}
/* (non-Javadoc)
@@ -84,7 +115,6 @@
public void tearDown() throws Exception {
super.tearDown();
toolBar = null;
- toolBarGroup = null;
form = null;
}
@@ -120,4 +150,34 @@
HtmlElement link = (HtmlElement) links.get(0);
assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/toolBar.xcss"));
}
+
+ public void testRenderImages() throws Exception {
+ renderView();
+ InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
+ InternetResource resource = builder.getResource("org/richfaces/renderkit/html/css/toolBar.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[]{
+ "org.richfaces.renderkit.html.images.DotSeparatorImage",
+ "org.richfaces.renderkit.html.images.GridSeparatorImage",
+ "org.richfaces.renderkit.html.images.LineSeparatorImage",
+ "org.richfaces.renderkit.html.images.SquareSeparatorImage"
+ };
+
+ 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());
+ }
+ }
}
19 years