JBoss Rich Faces SVN: r18214 - in root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: internal and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-23 10:14:55 -0400 (Fri, 23 Jul 2010)
New Revision: 18214
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/NamedType.java
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
Log:
externalized NamedType
Added: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/NamedType.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/NamedType.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/NamedType.java 2010-07-23 14:14:55 UTC (rev 18214)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.internal;
+
+import java.lang.annotation.Annotation;
+
+import org.richfaces.tests.metamer.ftest.annotations.Named;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class NamedType {
+ private Class<?> parameterType;
+ private String name;
+
+ public NamedType(Class<?> parameterType, String name) {
+ this.parameterType = parameterType;
+ this.name = name;
+ }
+
+ public NamedType(Class<?> parameterType, Annotation[] annotations) {
+ this.parameterType = parameterType;
+ for (Annotation annotation : annotations) {
+ if (annotation.annotationType() == Named.class) {
+ this.name = ((Named) annotation).value();
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "NamedType(" + parameterType.getSimpleName() + ", " + name + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((parameterType == null) ? 0 : parameterType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ NamedType other = (NamedType) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (parameterType == null) {
+ if (other.parameterType != null) {
+ return false;
+ }
+ } else if (!parameterType.equals(other.parameterType)) {
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23 14:14:10 UTC (rev 18213)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23 14:14:55 UTC (rev 18214)
@@ -24,7 +24,6 @@
import static org.jboss.test.selenium.locator.LocatorFactory.id;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.net.URL;
@@ -42,6 +41,7 @@
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Named;
import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.internal.NamedType;
import org.richfaces.tests.metamer.ftest.richExtendedDataTable.AssertingDataScroller;
import org.richfaces.tests.metamer.ftest.richExtendedDataTable.DataTable;
import org.testng.annotations.AfterMethod;
@@ -204,77 +204,6 @@
return result;
}
- private class NamedType {
- private Class<?> parameterType;
- private String name;
-
- public NamedType(Class<?> parameterType, String name) {
- this.parameterType = parameterType;
- this.name = name;
- }
-
- public NamedType(Class<?> parameterType, Annotation[] annotations) {
- this.parameterType = parameterType;
- for (Annotation annotation : annotations) {
- if (annotation.annotationType() == Named.class) {
- this.name = ((Named) annotation).value();
- }
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((parameterType == null) ? 0 : parameterType.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- NamedType other = (NamedType) obj;
- if (!getOuterType().equals(other.getOuterType())) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (parameterType == null) {
- if (other.parameterType != null) {
- return false;
- }
- } else if (!parameterType.equals(other.parameterType)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "NamedType(" + parameterType.getSimpleName() + ", " + name + ")";
- }
-
- private TestPagination getOuterType() {
- return TestPagination.this;
- }
-
- }
-
private List<? extends Object> getUseParameter(Class<?> parameterType, Use use) {
if (parameterType == int.class || parameterType == Integer.class) {
return Arrays.asList(ArrayUtils.toObject(use.ints()));
14 years, 5 months
JBoss Rich Faces SVN: r18213 - in root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: annotations and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-23 10:14:10 -0400 (Fri, 23 Jul 2010)
New Revision: 18213
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Inject.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Named.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
Log:
implemented parametrization of test properties using @Factory, @Use and @Inject annotations
Added: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Inject.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Inject.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Inject.java 2010-07-23 14:14:10 UTC (rev 18213)
@@ -0,0 +1,11 @@
+package org.richfaces.tests.metamer.ftest.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.*;
+
+@Target({ TYPE, FIELD, METHOD, PARAMETER })
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Inject {
+}
Added: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Named.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Named.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Named.java 2010-07-23 14:14:10 UTC (rev 18213)
@@ -0,0 +1,12 @@
+package org.richfaces.tests.metamer.ftest.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.*;
+
+@Target({ PARAMETER })
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Named {
+ String value();
+}
Added: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/annotations/Use.java 2010-07-23 14:14:10 UTC (rev 18213)
@@ -0,0 +1,16 @@
+package org.richfaces.tests.metamer.ftest.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.*;
+
+@Target({ TYPE, FIELD, METHOD, PARAMETER })
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface Use {
+ String field() default "";
+
+ String[] value() default {};
+
+ int[] ints() default {};
+}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23 13:06:59 UTC (rev 18212)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23 14:14:10 UTC (rev 18213)
@@ -24,15 +24,29 @@
import static org.jboss.test.selenium.locator.LocatorFactory.id;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.net.URL;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
import org.jboss.test.selenium.locator.IdLocator;
-import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
+import org.richfaces.tests.metamer.ftest.annotations.Named;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
import org.richfaces.tests.metamer.ftest.richExtendedDataTable.AssertingDataScroller;
import org.richfaces.tests.metamer.ftest.richExtendedDataTable.DataTable;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
@@ -46,35 +60,257 @@
*/
public class TestPagination extends AbstractMetamerTest {
+ private static final int FAST_STEP = 2;
private static final int[] PAGES = new int[] { 3, 6, 1, 4, 6, 2, 4, 5 };
IdLocator attributeFastStep = id("form:attributes:fastStepInput");
IdLocator attributeMaxPages = id("form:attributes:maxPagesInput");
- AssertingDataScroller dataScroller = new AssertingDataScroller(null);
+ @Inject
+ @Use(value = { "dataScroller*" })
+ AssertingDataScroller dataScroller;
+ AssertingDataScroller dataScroller1 = new AssertingDataScroller(pjq("span.rf-ds[id$=scroller1]"));
+ AssertingDataScroller dataScroller2 = new AssertingDataScroller(pjq("span.rf-ds[id$=scroller2]"));
+
DataTable dataTable = new DataTable(pjq("table.rf-dt[id$=richDataTable]"));
- JQueryLocator scroller1 = pjq("span.rf-ds[id$=scroller1]");
- JQueryLocator scroller2 = pjq("span.rf-ds[id$=scroller2]");
+ @Inject
+ @Use(ints = { 2 })
+ int fastStep;
+ @Inject
+ @Use(ints = { 3 })
+ int maxPages;
+
+ public TestPagination() {
+ }
+
+ public TestPagination(AssertingDataScroller dataScroller, @Named("fastStep") int fastStep,
+ @Named("maxPages") int maxPages) {
+ this.dataScroller = dataScroller;
+ this.fastStep = fastStep;
+ this.maxPages = maxPages;
+ }
+
@Override
public URL getTestUrl() {
return buildUrl(contextPath, "faces/components/richDataScroller/simple.xhtml");
}
- @Test(dataProvider = "templates")
- public void testNumberedPagesScrollerOutsideTable(String template) {
- testNumberedPages(scroller1);
+ @Factory
+ public Object[] createTests() {
+ // obtain parametrized constructor
+ Constructor<?> constructor = null;
+ for (Constructor<?> c : this.getClass().getConstructors()) {
+ if (c.getParameterTypes().length > 0) {
+ if (constructor == null) {
+ constructor = c;
+ } else {
+ throw new IllegalStateException("there cannot be more than one parametrized constructor");
+ }
+ }
+ }
+
+ Map<NamedType, List<? extends Object>> parameters = new LinkedHashMap<NamedType, List<? extends Object>>();
+
+ // fill all parameters with null values to sorted map
+ for (int i = 0; i < constructor.getParameterTypes().length; i++) {
+ NamedType namedType = new NamedType(constructor.getParameterTypes()[i],
+ constructor.getParameterAnnotations()[i]);
+
+ if (parameters.containsKey(namedType)) {
+ throw new IllegalStateException("there are ambiguous parameters");
+ } else {
+ parameters.put(namedType, null);
+ }
+ }
+
+ List<Field> injections = new LinkedList<Field>();
+
+ for (Field field : this.getClass().getDeclaredFields()) {
+ if (field.getAnnotation(Inject.class) != null) {
+ if (field.getAnnotation(Use.class) != null) {
+ NamedType namedType = new NamedType(field.getType(), (String) null);
+ if (!parameters.containsKey(namedType)) {
+ namedType = new NamedType(field.getType(), field.getName());
+ }
+ if (!parameters.containsKey(namedType)) {
+ throw new IllegalStateException("cannot find equivalent constructor parameter");
+ }
+
+ parameters.put(namedType, getUseParameter(field.getType(), field.getAnnotation(Use.class)));
+ } else {
+ injections.add(field);
+ }
+ }
+ }
+
+ if (!injections.isEmpty()) {
+ throw new IllegalStateException("all injections weren't satisfied");
+ }
+
+ Object[][] parameterArray = new Object[parameters.size()][];
+ int parameterPosition = 0;
+ for (List<? extends Object> parameter : parameters.values()) {
+ parameterArray[parameterPosition++] = parameter.toArray();
+ }
+
+ Object[][] combinations = generateCombinations(parameterArray);
+
+ Object[] result = new Object[combinations.length];
+ for (int i = 0; i < combinations.length; i++) {
+ try {
+ result[i] = constructor.newInstance(combinations[i]);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return result;
}
- @Test(dataProvider = "templates")
- public void testNumberedPagesFooterScroller(String template) {
- testNumberedPages(scroller2);
+ private Object[][] generateCombinations(Object[][] toCombine) {
+ int count = 1;
+ for (int outter = 0; outter < toCombine.length; outter++) {
+ count *= toCombine[outter].length;
+ }
+
+ Object[][] result = new Object[count][toCombine.length];
+
+ int[] position = new int[toCombine.length];
+ Arrays.fill(position, 0);
+ // int iterate = 0;
+
+ for (int i = 0; i < count; i++) {
+ result[i] = new Object[toCombine.length];
+
+ for (int j = 0; j < toCombine.length; j++) {
+ result[i][j] = toCombine[j][position[j]];
+ }
+
+ // iterate
+ if (i + 1 < count) {
+ for (int j = 0; j < toCombine.length; j++) {
+ position[j] += 1;
+ if (position[j] < toCombine[j].length) {
+ break;
+ } else {
+ position[j] = 0;
+ }
+ }
+ }
+ }
+
+ return result;
}
- public void testNumberedPages(JQueryLocator scrollerLocator) {
- dataScroller.setRoot(scrollerLocator);
- dataScroller.setFastStep(2);
+ private class NamedType {
+ private Class<?> parameterType;
+ private String name;
+
+ public NamedType(Class<?> parameterType, String name) {
+ this.parameterType = parameterType;
+ this.name = name;
+ }
+
+ public NamedType(Class<?> parameterType, Annotation[] annotations) {
+ this.parameterType = parameterType;
+ for (Annotation annotation : annotations) {
+ if (annotation.annotationType() == Named.class) {
+ this.name = ((Named) annotation).value();
+ }
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + getOuterType().hashCode();
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((parameterType == null) ? 0 : parameterType.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ NamedType other = (NamedType) obj;
+ if (!getOuterType().equals(other.getOuterType())) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (parameterType == null) {
+ if (other.parameterType != null) {
+ return false;
+ }
+ } else if (!parameterType.equals(other.parameterType)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "NamedType(" + parameterType.getSimpleName() + ", " + name + ")";
+ }
+
+ private TestPagination getOuterType() {
+ return TestPagination.this;
+ }
+
+ }
+
+ private List<? extends Object> getUseParameter(Class<?> parameterType, Use use) {
+ if (parameterType == int.class || parameterType == Integer.class) {
+ return Arrays.asList(ArrayUtils.toObject(use.ints()));
+ }
+
+ // tries satisfy parameter from fields
+ List<Object> result = new LinkedList<Object>();
+ for (int i = 0; i < use.value().length; i++) {
+ boolean satisfied = false;
+ for (Field field : this.getClass().getDeclaredFields()) {
+ String name = use.value()[i];
+ name = StringUtils.replace(name, "*", ".+");
+ name = StringUtils.replace(name, "?", ".");
+ Pattern pattern = Pattern.compile(name);
+ if (pattern.matcher(field.getName()).matches()) {
+ if (parameterType.isAssignableFrom(field.getType())) {
+ try {
+ result.add(field.get(this));
+ satisfied = true;
+ } catch (Exception e) {
+ throw new IllegalStateException("the field cannot be obtained");
+ }
+ }
+ }
+ }
+ if (satisfied) {
+ continue;
+ }
+ throw new IllegalStateException("cannot find the field satysfying injection point");
+ }
+ return result;
+ }
+
+ @Test
+ public void testNumberedPages() {
+ dataScroller.setFastStep(FAST_STEP);
dataScroller.setLastPage(dataScroller.getLastPage());
for (int pageNumber : PAGES) {
14 years, 5 months
JBoss Rich Faces SVN: r18212 - in root/examples/richfaces-showcase/trunk/src/main: java/org/richfaces/demo/lists and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-07-23 09:06:59 -0400 (Fri, 23 Jul 2010)
New Revision: 18212
Added:
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/lists/
root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/lists/ListBean.java
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/list/
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/list/lists.xhtml
Modified:
root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
https://jira.jboss.org/browse/RF-8967
Added: root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/lists/ListBean.java
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/lists/ListBean.java (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/java/org/richfaces/demo/lists/ListBean.java 2010-07-23 13:06:59 UTC (rev 18212)
@@ -0,0 +1,18 @@
+package org.richfaces.demo.lists;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+@ManagedBean
+@RequestScoped
+public class ListBean {
+ private String listType = "ordered";
+
+ public String getListType() {
+ return listType;
+ }
+
+ public void setListType(String listType) {
+ this.listType = listType;
+ }
+}
Modified: root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-07-23 10:42:23 UTC (rev 18211)
+++ root/examples/richfaces-showcase/trunk/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-07-23 13:06:59 UTC (rev 18212)
@@ -264,6 +264,16 @@
</sample>
</samples>
</demo>
+ <demo>
+ <id>list</id>
+ <name>rich:list</name>
+ <samples>
+ <sample>
+ <id>lists</id>
+ <name>Data Lists Component</name>
+ </sample>
+ </samples>
+ </demo>
</demos>
</group>
<group new="true">
Added: root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/list/lists.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/list/lists.xhtml (rev 0)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/list/lists.xhtml 2010-07-23 13:06:59 UTC (rev 18212)
@@ -0,0 +1,47 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+
+<ui:composition>
+ <p><b>rich:list</b> component allows to build one of the HTML lists
+ (UL, OL, DL) dynamically from backend data</p>
+ <p>It accepts the same data types as the other iteration components
+ and renders them according to <b>type</b> attribute.</p>
+ <h:form id="form">
+ <h:outputText value="List Type: " style="font-weight:bold" />
+ <a4j:commandLink value="ordered" render="list,form">
+ <a4j:param name="t" value="ordered" assignTo="#{listBean.listType}" />
+ <f:attribute name="style"
+ value="#{(listBean.listType=='ordered') ? 'color:orange' : ''}" />
+ </a4j:commandLink>
+ <h:outputText value=" | " />
+ <a4j:commandLink value="unordered" render="list,form">
+ <a4j:param name="t" value="unordered" assignTo="#{listBean.listType}" />
+ <f:attribute name="style"
+ value="#{(listBean.listType=='unordered') ? 'color:orange' : ''}" />
+ </a4j:commandLink>
+ <h:outputText value=" | " />
+ <a4j:commandLink value="definitions" render="list,form">
+ <a4j:param name="t" value="definitions"
+ assignTo="#{listBean.listType}" />
+ <f:attribute name="style"
+ value="#{(listBean.listType=='definitions') ? 'color:orange' : ''}" />
+ </a4j:commandLink>
+ </h:form>
+
+ <rich:list value="#{carsBean.inventoryVendorLists}" id="list"
+ var="vendorList" type="#{listBean.listType}">
+ <f:facet name="term">
+ <h:panelGroup layout="block">
+ <h:outputText value="In stock: #{vendorList.count}"
+ style="font-weight:bold" />
+ </h:panelGroup>
+ </f:facet>
+ <h:outputText value="#{vendorList.vendor}" />
+ </rich:list>
+</ui:composition>
+</html>
\ No newline at end of file
14 years, 5 months
JBoss Rich Faces SVN: r18211 - in root/tests/metamer/trunk/application/src/main: java/org/richfaces/tests/metamer/bean and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-07-23 06:42:23 -0400 (Fri, 23 Jul 2010)
New Revision: 18211
Added:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/TestIdentityFilter.java
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/UserBean.java
root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/
root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/all.xhtml
root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/list.xhtml
root/tests/metamer/trunk/application/src/main/webapp/resources/css/richFunctions.css
Modified:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
root/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml
Log:
* added a page for RichFaces client functions (clientId, element, component, findComponent, isUserInRole)
Added: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/TestIdentityFilter.java
===================================================================
--- root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/TestIdentityFilter.java (rev 0)
+++ root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/TestIdentityFilter.java 2010-07-23 10:42:23 UTC (rev 18211)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+
+package org.richfaces.tests.metamer;
+
+import java.io.IOException;
+import java.security.Principal;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
+import org.richfaces.tests.metamer.bean.UserBean;
+
+/**
+ * Filter for working with user roles. It is used by RichFaces client function rich:isUserInRole().
+ *
+ * @author Nick Belaevski, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestIdentityFilter implements Filter {
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ }
+
+ public void destroy() {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException {
+
+ HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper((HttpServletRequest) request) {
+
+ private UserBean getUserBean() {
+ HttpSession session = getSession(false);
+ if (session != null) {
+ return (UserBean) session.getAttribute("userBean");
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isUserInRole(String role) {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.isUserInRole(role);
+ }
+ return false;
+ }
+
+ @Override
+ public Principal getUserPrincipal() {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.getPrincipal();
+ }
+ return null;
+ }
+
+ @Override
+ public String getRemoteUser() {
+ UserBean userBean = getUserBean();
+ if (userBean != null) {
+ return userBean.getRolename();
+ }
+ return null;
+ }
+ };
+
+ chain.doFilter(wrapper, response);
+ }
+}
Property changes on: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/TestIdentityFilter.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Modified: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
--- root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-23 07:21:06 UTC (rev 18210)
+++ root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-23 10:42:23 UTC (rev 18211)
@@ -107,6 +107,7 @@
components.put("richDataScroller", "Rich Data Scroller");
components.put("richDataTable", "Rich Data Table");
components.put("richExtendedDataTable", "Rich Extended Data Table");
+ components.put("richFunctions", "Rich Functions");
components.put("richList", "Rich List");
components.put("richPanel", "Rich Panel");
}
Added: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/UserBean.java
===================================================================
--- root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/UserBean.java (rev 0)
+++ root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/UserBean.java 2010-07-23 10:42:23 UTC (rev 18211)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+
+package org.richfaces.tests.metamer.bean;
+
+import java.io.Serializable;
+import java.security.Principal;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+/**
+ * Session-scoped managed bean storing user's roles.
+ *
+ * @author Nick Belaevski, <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "userBean")
+@SessionScoped
+public class UserBean implements Serializable {
+
+ private String rolename;
+
+ public String getRolename() {
+ return rolename;
+ }
+
+ public void setRolename(String username) {
+ this.rolename = username;
+ }
+
+ public Principal getPrincipal() {
+ if (rolename != null) {
+ return new PrincipalImpl(rolename);
+ }
+
+ return null;
+ }
+
+ public boolean isUserInRole(String role) {
+ Principal principal = getPrincipal();
+ if (principal != null) {
+ //username & principal's name & role name are considered the same
+ return principal.getName().equals(role);
+ }
+
+ return false;
+ }
+}
+
+class PrincipalImpl implements Principal {
+
+ private String name;
+
+ public PrincipalImpl(String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
Property changes on: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/UserBean.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Modified: root/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml 2010-07-23 07:21:06 UTC (rev 18210)
+++ root/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml 2010-07-23 10:42:23 UTC (rev 18211)
@@ -16,6 +16,14 @@
<param-name>org.richfaces.skin</param-name>
<param-value>#{richBean.skin}</param-value>
</context-param>
+ <filter>
+ <filter-name>Test Identity Filter</filter-name>
+ <filter-class>org.richfaces.tests.metamer.TestIdentityFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>Test Identity Filter</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ </filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
Added: root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/all.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/all.xhtml (rev 0)
+++ root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/all.xhtml 2010-07-23 10:42:23 UTC (rev 18211)
@@ -0,0 +1,69 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j" xmlns:ta="http://java.sun.com/jsf/composite/testapp"
+ xmlns:rich="http://richfaces.org/rich">
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates" value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+
+ <h:outputStylesheet library="css" name="richFunctions.css"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <f:subview id="subview">
+ <h:outputLabel value="input: " for="input" />
+ <h:inputText id="input" value="abc" />
+ </f:subview>
+
+ <br/><br/>
+
+ <h:panelGrid columns="2">
+ rich:clientId('input')
+ <h:outputText value="#{rich:clientId('input')}" style="font-weight: bold;" />
+
+ rich:element('input')
+ <h:outputText value="#{rich:element('input')}" style="font-weight: bold;" />
+
+ rich:component('input')
+ <h:outputText value="#{rich:component('input')}" style="font-weight: bold;" />
+
+ rich:findComponent('input').value
+ <h:outputText value="#{rich:findComponent('input').value}" style="font-weight: bold;" />
+ </h:panelGrid>
+
+ <hr/>
+
+ <h:outputLabel value="Role name: " for="roleName" />
+ <h:inputText value="#{userBean.rolename}" id="roleName" />
+ <br />
+ <h:commandLink value="Apply role name" />
+
+ <hr/>
+ <h:panelGrid columns="2">
+ rich:isUserInRole('admin, user')
+ <h:outputText id="outputUserInRoleAU" value="#{rich:isUserInRole('admin, user')}" style="font-weight: bold;" />
+
+ rich:isUserInRole('admin')
+ <h:outputText id="outputUserInRoleA" value="#{rich:isUserInRole('admin')}" style="font-weight: bold;" />
+
+ rich:isUserInRole('user')
+ <h:outputText id="outputUserInRoleU" value="#{rich:isUserInRole('user')}" style="font-weight: bold;" />
+ </h:panelGrid>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/list.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/list.xhtml (rev 0)
+++ root/tests/metamer/trunk/application/src/main/webapp/components/richFunctions/list.xhtml 2010-07-23 10:42:23 UTC (rev 18211)
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:c="http://java.sun.com/jsp/jstl/core">
+
+ <h:head>
+ <title>Rich Functions</title>
+ <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
+ <h:outputStylesheet library="css" name="list.css" />
+ </h:head>
+
+ <h:body>
+ <h:link outcome="all" value="All" styleClass="link"/>
+ <div class="description">Page containing all RichFaces client functions.</div>
+
+ </h:body>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/application/src/main/webapp/resources/css/richFunctions.css
===================================================================
14 years, 5 months
JBoss Rich Faces SVN: r18210 - in root/tests/metamer/trunk/ftest-source/src/main/java/org: richfaces/tests/metamer/ftest and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-23 03:21:06 -0400 (Fri, 23 Jul 2010)
New Revision: 18210
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
Log:
introduced AssertingDataScroller - used in richExtendedDataTable/TestScroller and in new case richDataScroller/TestPagination
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java 2010-07-23 07:19:27 UTC (rev 18209)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java 2010-07-23 07:21:06 UTC (rev 18210)
@@ -25,6 +25,7 @@
import org.jboss.test.selenium.locator.CompoundableLocator;
import org.jboss.test.selenium.locator.IterableLocator;
import org.jboss.test.selenium.locator.type.LocationStrategy;
+import org.jboss.test.selenium.utils.text.SimplifiedFormat;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -101,4 +102,15 @@
public Iterable<T> getDescendants(T elementLocator) {
return getReferenced().getDescendants(elementLocator);
}
+
+ @SuppressWarnings("unchecked")
+ public T format(Object... args) {
+ String newAddition = SimplifiedFormat.format(addition, args);
+ try {
+ return (T) this.getClass().getConstructor(LocatorReference.class, String.class)
+ .newInstance(reference, newAddition);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
}
Added: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23 07:21:06 UTC (rev 18210)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richDataScroller;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.id;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.jboss.test.selenium.locator.IdLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.richExtendedDataTable.AssertingDataScroller;
+import org.richfaces.tests.metamer.ftest.richExtendedDataTable.DataTable;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
+
+/**
+ * Test the functionality of switching pages using DataScroller bound to DataTable.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestPagination extends AbstractMetamerTest {
+
+ private static final int[] PAGES = new int[] { 3, 6, 1, 4, 6, 2, 4, 5 };
+
+ IdLocator attributeFastStep = id("form:attributes:fastStepInput");
+ IdLocator attributeMaxPages = id("form:attributes:maxPagesInput");
+
+ AssertingDataScroller dataScroller = new AssertingDataScroller(null);
+ DataTable dataTable = new DataTable(pjq("table.rf-dt[id$=richDataTable]"));
+
+ JQueryLocator scroller1 = pjq("span.rf-ds[id$=scroller1]");
+ JQueryLocator scroller2 = pjq("span.rf-ds[id$=scroller2]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richDataScroller/simple.xhtml");
+ }
+
+ @Test(dataProvider = "templates")
+ public void testNumberedPagesScrollerOutsideTable(String template) {
+ testNumberedPages(scroller1);
+ }
+
+ @Test(dataProvider = "templates")
+ public void testNumberedPagesFooterScroller(String template) {
+ testNumberedPages(scroller2);
+ }
+
+ public void testNumberedPages(JQueryLocator scrollerLocator) {
+ dataScroller.setRoot(scrollerLocator);
+ dataScroller.setFastStep(2);
+ dataScroller.setLastPage(dataScroller.getLastPage());
+
+ for (int pageNumber : PAGES) {
+ String tableText = dataTable.getTableText();
+ dataScroller.gotoPage(pageNumber);
+ assertFalse(tableText.equals(dataTable.getTableText()));
+ }
+ }
+
+ @Override
+ @AfterMethod(alwaysRun = true)
+ public void invalidateSession() {
+ super.invalidateSession();
+ }
+
+ @BeforeMethod
+ public void prepareAttributes() {
+ guardHttp(selenium).type(attributeFastStep, "2");
+ guardHttp(selenium).type(attributeMaxPages, "3");
+ }
+}
Added: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/AssertingDataScroller.java 2010-07-23 07:21:06 UTC (rev 18210)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richExtendedDataTable;
+
+import static junit.framework.Assert.*;
+
+import org.jboss.test.selenium.locator.JQueryLocator;
+
+/**
+ * Provides DataScroller control methods with assertions about scroller state.
+ *
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class AssertingDataScroller extends DataScroller {
+
+ private static final String CLASS_DISABLED = "rf-ds-dis";
+
+ private Integer fastStep = null;
+ private Integer lastPage = null;
+
+ public AssertingDataScroller(JQueryLocator root) {
+ super(root);
+ }
+
+ public void setFastStep(int fastStep) {
+ this.fastStep = fastStep;
+ }
+
+ public void setLastPage(int pageNumber) {
+ this.lastPage = pageNumber;
+ }
+
+ @Override
+ public void gotoPage(int pageNumber) {
+ int startCount = this.getCountOfVisiblePages();
+ super.gotoPage(pageNumber);
+
+ int currentPage = this.getCurrentPage();
+ assertEquals(this.getCountOfVisiblePages(), startCount);
+ assertEquals(currentPage, pageNumber);
+
+ assertEquals(isFirstPageButtonDisabled(), this.isFirstPage());
+ assertEquals(isLastPageButtonDisabled(), this.isLastPage());
+
+ if (fastStep != null) {
+ assertEquals(isFastRewindDisabled(), currentPage - fastStep < 1);
+ if (lastPage != null) {
+ assertEquals(isFastForwardDisabled(), currentPage + fastStep > lastPage);
+ }
+ }
+ }
+
+ @Override
+ public void gotoFirstPage() {
+ super.gotoFirstPage();
+ assertTrue(isFastRewindDisabled());
+ assertTrue(isFirstPageButtonDisabled());
+ }
+
+ @Override
+ public void gotoLastPage() {
+ super.gotoLastPage();
+ assertTrue(isFastForwardDisabled());
+ assertTrue(isLastPageButtonDisabled());
+ }
+
+ public boolean isFastForwardDisabled() {
+ return selenium.belongsClass(fastForwardButton, CLASS_DISABLED);
+ }
+
+ public boolean isFastRewindDisabled() {
+ return selenium.belongsClass(fastRewindButton, CLASS_DISABLED);
+ }
+
+ public boolean isLastPageButtonDisabled() {
+ return selenium.belongsClass(lastPageButton, CLASS_DISABLED);
+ }
+
+ public boolean isFirstPageButtonDisabled() {
+ return selenium.belongsClass(firstPageButton, CLASS_DISABLED);
+ }
+}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-23 07:19:27 UTC (rev 18209)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-23 07:21:06 UTC (rev 18210)
@@ -32,6 +32,8 @@
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
/**
+ * Provides DataScroller control methods.
+ *
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
@@ -40,9 +42,16 @@
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
- ReferencedLocator<JQueryLocator> pageNumbers = ref(root, "> .rf-ds-dtl");
+
+ ReferencedLocator<JQueryLocator> numberedPages = ref(root, "> .rf-ds-dtl");
+ ReferencedLocator<JQueryLocator> specificNumberedPage = ref(root, "> .rf-ds-dtl:textEquals('{0}')");
+
ReferencedLocator<JQueryLocator> firstPageButton = ref(root, "> .rf-ds-l[id$=ds_f]");
- ReferencedLocator<JQueryLocator> lastPageButton = ref(root, "> .rf-ds-r:eq(1)");
+ ReferencedLocator<JQueryLocator> fastRewindButton = ref(root, "> .rf-ds-l[id$=ds_fr]");
+ ReferencedLocator<JQueryLocator> fastForwardButton = ref(root, "> .rf-ds-r[id$=ds_ff]");
+ ReferencedLocator<JQueryLocator> lastPageButton = ref(root, "> .rf-ds-r[id$=ds_l]");
+
+ ReferencedLocator<JQueryLocator> firstVisiblePage = ref(root, "> .rf-ds-dtl:first");
ReferencedLocator<JQueryLocator> lastVisiblePage = ref(root, "> .rf-ds-dtl:last");
ReferencedLocator<JQueryLocator> currentPage = ref(root, "> .rf-ds-cur");
@@ -70,28 +79,63 @@
}
}
- public void clickLastPageButton() {
- guardXhr(selenium).click(lastPageButton);
+ public void gotoPage(int pageNumber) {
+ while (pageNumber > getLastVisiblePage()) {
+ fastForward();
+ }
+ while (pageNumber < getFirstVisiblePage()) {
+ fastRewind();
+ }
+ clickPageButton(pageNumber);
}
- public void clickFirstPageButton() {
- guardXhr(selenium).click(firstPageButton);
+ public void fastForward() {
+ if (selenium.belongsClass(fastForwardButton, "rf-ds-dis")) {
+ throw new AssertionError("fast forward button disabled");
+ }
+ clickFastForward();
}
+ public void fastRewind() {
+ if (selenium.belongsClass(fastRewindButton, "rf-ds-dis")) {
+ throw new AssertionError("fast rewind button disabled");
+ }
+ clickFastRewind();
+ }
+
public int getCountOfVisiblePages() {
- return selenium.getCount(pageNumbers);
+ return selenium.getCount(numberedPages);
}
public boolean hasPages() {
return selenium.isElementPresent(lastVisiblePage);
}
- public Integer getLastVisiblePage() {
+ public int getFirstVisiblePage() {
if (!hasPages()) {
- return null;
+ return 1;
}
+ return integer(selenium.getText(firstVisiblePage));
+ }
+
+ public int getLastVisiblePage() {
+ if (!hasPages()) {
+ return 1;
+ }
return integer(selenium.getText(lastVisiblePage));
}
+
+ public int getLastPage() {
+ int startPage = getCurrentPage();
+ clickLastPageButton();
+ int lastPage = getCurrentPage();
+ if (startPage == 1) {
+ clickFirstPageButton();
+ } else {
+ gotoPage(startPage);
+ }
+ return lastPage;
+ }
public int getCurrentPage() {
if (!hasPages()) {
@@ -111,4 +155,26 @@
public static int integer(String string) {
return Integer.valueOf(string);
}
+
+ public void clickLastPageButton() {
+ guardXhr(selenium).click(lastPageButton);
+ }
+
+ public void clickFirstPageButton() {
+ guardXhr(selenium).click(firstPageButton);
+ }
+
+ public void clickPageButton(int pageNumber) {
+ guardXhr(selenium).click(specificNumberedPage.format(pageNumber));
+ }
+
+ public void clickFastForward() {
+ guardXhr(selenium).click(fastForwardButton);
+ }
+
+ public void clickFastRewind() {
+ guardXhr(selenium).click(fastRewindButton);
+ }
+
+
}
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-23 07:19:27 UTC (rev 18209)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-23 07:21:06 UTC (rev 18210)
@@ -30,6 +30,8 @@
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
/**
+ * Provides methods to control DataTable
+ *
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
@@ -38,7 +40,7 @@
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
-
+
ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b table table tr");
public DataTable(JQueryLocator tableRoot) {
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-23 07:19:27 UTC (rev 18209)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-23 07:21:06 UTC (rev 18210)
@@ -42,8 +42,8 @@
private static final int TOTAL_ROW_COUNT = 50;
private static final Integer[] ROW_COUNT_VALUES =
new Integer[]{null, 10, 1, TOTAL_ROW_COUNT, 13, 9, 17, TOTAL_ROW_COUNT + 1, 2 * TOTAL_ROW_COUNT};
- DataScroller dataScroller1 = new DataScroller(pjq("span.rf-ds[id$=scroller1]"));
- DataScroller dataScroller2 = new DataScroller(pjq("span.rf-ds[id$=scroller2]"));
+ DataScroller dataScroller1 = new AssertingDataScroller(pjq("span.rf-ds[id$=scroller1]"));
+ DataScroller dataScroller2 = new AssertingDataScroller(pjq("span.rf-ds[id$=scroller2]"));
DataTable table = new DataTable(pjq("div.rf-edt[id$=richEDT]"));
IdLocator attributeRowsInput = id("form:attributes:rowsInput");
14 years, 5 months
JBoss Rich Faces SVN: r18209 - in root/tests/metamer/trunk/ftest-source/src/main/java/org: richfaces/tests/metamer/ftest and 9 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-23 03:19:27 -0400 (Fri, 23 Jul 2010)
New Revision: 18209
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTest.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/PushAttributes.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestInterval.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
Log:
following changes in library - Cheiron: possibility to parametrize the Locators
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -29,7 +29,7 @@
*
* @param <T> type of referenced locator
*/
-public class LocatorReference<T extends Locator> {
+public class LocatorReference<T extends Locator<?>> {
private T reference;
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -30,9 +30,10 @@
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*
- * @param <T> type of referenced locator
+ * @param <T>
+ * type of referenced locator
*/
-public class ReferencedLocator<T extends IterableLocator<T> & CompoundableLocator<T>> extends AbstractElementLocator
+public class ReferencedLocator<T extends IterableLocator<T> & CompoundableLocator<T>> extends AbstractElementLocator<T>
implements IterableLocator<T>, CompoundableLocator<T> {
private LocatorReference<T> reference;
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractMetamerTest.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -160,8 +160,8 @@
* @param element
* locator of tested element
*/
- protected void testFireEvent(Event event, ElementLocator element) {
- ElementLocator eventInput = pjq("input[id$=on" + event.getEventName() + "Input]");
+ protected void testFireEvent(Event event, ElementLocator<?> element) {
+ ElementLocator<?> eventInput = pjq("input[id$=on" + event.getEventName() + "Input]");
final String value = "alert('" + event.getEventName() + "')";
selenium.type(eventInput, value);
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -26,7 +26,6 @@
import java.net.URL;
-import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.waiting.selenium.SeleniumCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
@@ -41,10 +40,10 @@
*/
public class TestA4JActionListener extends AbstractMetamerTest {
- private ElementLocator invokeButtonType = pjq("input[id$=invokeByTypeButton]");
- private ElementLocator invokeButtonBinding = pjq("input[id$=invokeByBindingButton]");
- private ElementLocator invokeButtonMethod = pjq("input[id$=invokeMethodButton]");
- private ElementLocator invokeButtonCC = pjq("input[id$=invokeFromCCButton:button]");
+ private JQueryLocator invokeButtonType = pjq("input[id$=invokeByTypeButton]");
+ private JQueryLocator invokeButtonBinding = pjq("input[id$=invokeByBindingButton]");
+ private JQueryLocator invokeButtonMethod = pjq("input[id$=invokeMethodButton]");
+ private JQueryLocator invokeButtonCC = pjq("input[id$=invokeFromCCButton:button]");
private JQueryLocator message = pjq("ul[id$=messages] li");
@Override
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandButton/TestA4JCommandButton.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -32,7 +32,7 @@
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -45,11 +45,11 @@
*/
public class TestA4JCommandButton extends AbstractMetamerTest {
- private ElementLocator input = pjq("input[id$=input]");
- private ElementLocator button = pjq("input[id$=a4jCommandButton]");
- private ElementLocator output1 = pjq("span[id$=output1]");
- private ElementLocator output2 = pjq("span[id$=output2]");
- private ElementLocator output3 = pjq("span[id$=output3]");
+ private JQueryLocator input = pjq("input[id$=input]");
+ private JQueryLocator button = pjq("input[id$=a4jCommandButton]");
+ private JQueryLocator output1 = pjq("span[id$=output1]");
+ private JQueryLocator output2 = pjq("span[id$=output2]");
+ private JQueryLocator output3 = pjq("span[id$=output3]");
@Override
public URL getTestUrl() {
@@ -98,9 +98,9 @@
@Test(dataProvider = "templates")
public void testAction(String templates) {
- ElementLocator doubleStringAction = pjq("input[value=doubleStringAction]");
- ElementLocator first6CharsAction = pjq("input[value=first6CharsAction]");
- ElementLocator toUpperCaseAction = pjq("input[value=toUpperCaseAction]");
+ JQueryLocator doubleStringAction = pjq("input[value=doubleStringAction]");
+ JQueryLocator first6CharsAction = pjq("input[value=first6CharsAction]");
+ JQueryLocator toUpperCaseAction = pjq("input[value=toUpperCaseAction]");
selenium.click(doubleStringAction);
selenium.waitForPageToLoad(TIMEOUT);
@@ -130,9 +130,9 @@
@Test(dataProvider = "templates")
public void testActionListener(String templates) {
- ElementLocator doubleStringActionListener = pjq("input[value=doubleStringActionListener]");
- ElementLocator first6CharsActionListener = pjq("input[value=first6CharsActionListener]");
- ElementLocator toUpperCaseActionListener = pjq("input[value=toUpperCaseActionListener]");
+ JQueryLocator doubleStringActionListener = pjq("input[value=doubleStringActionListener]");
+ JQueryLocator first6CharsActionListener = pjq("input[value=first6CharsActionListener]");
+ JQueryLocator toUpperCaseActionListener = pjq("input[value=toUpperCaseActionListener]");
selenium.click(doubleStringActionListener);
selenium.waitForPageToLoad(TIMEOUT);
@@ -163,8 +163,8 @@
@Test(dataProvider = "templates")
public void testDisabled(String templates) {
- ElementLocator disabledChecbox = pjq("input[id$=disabledInput]");
- AttributeLocator disabledAttribute = button.getAttribute(new Attribute("disabled"));
+ JQueryLocator disabledChecbox = pjq("input[id$=disabledInput]");
+ AttributeLocator<?> disabledAttribute = button.getAttribute(new Attribute("disabled"));
selenium.click(disabledChecbox);
selenium.waitForPageToLoad(TIMEOUT);
@@ -225,7 +225,7 @@
@Test(dataProvider = "templates")
public void testRender(String templates) {
- ElementLocator renderInput = pjq("input[name$=renderInput]");
+ JQueryLocator renderInput = pjq("input[name$=renderInput]");
selenium.type(renderInput, "output1");
selenium.waitForPageToLoad(TIMEOUT);
@@ -265,7 +265,7 @@
@Test(dataProvider = "templates")
public void testRendered(String templates) {
- ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
+ JQueryLocator renderedCheckbox = pjq("input[name$=renderedInput]");
selenium.click(renderedCheckbox);
selenium.waitForPageToLoad(TIMEOUT);
@@ -274,11 +274,11 @@
@Test(dataProvider = "templates")
public void testStyleClass(String templates) {
- ElementLocator wide = pjq("input[name$=styleClassInput][value=wide]");
- ElementLocator big = pjq("input[name$=styleClassInput][value=big]");
- ElementLocator none = pjq("input[name$=styleClassInput][value=]");
+ JQueryLocator wide = pjq("input[name$=styleClassInput][value=wide]");
+ JQueryLocator big = pjq("input[name$=styleClassInput][value=big]");
+ JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
- final AttributeLocator classAttribute = button.getAttribute(new Attribute("class"));
+ final AttributeLocator<?> classAttribute = button.getAttribute(new Attribute("class"));
selenium.click(wide);
selenium.waitForPageToLoad(TIMEOUT);
@@ -295,8 +295,8 @@
@Test(dataProvider = "templates")
public void testStyle(String templates) {
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = button.getAttribute(new Attribute("style"));
+ JQueryLocator styleInput = pjq("input[id$=styleInput]");
+ final AttributeLocator<?> attribute = button.getAttribute(new Attribute("style"));
final String value = "font-size: 20px;";
selenium.type(styleInput, value);
@@ -307,8 +307,8 @@
@Test(dataProvider = "templates")
public void testValue(String templates) {
- ElementLocator valueInput = pjq("input[id$=valueInput]");
- final AttributeLocator attribute = button.getAttribute(new Attribute("value"));
+ JQueryLocator valueInput = pjq("input[id$=valueInput]");
+ final AttributeLocator<?> attribute = button.getAttribute(new Attribute("value"));
final String value = "new label";
selenium.type(valueInput, value);
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -32,7 +32,7 @@
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -45,11 +45,11 @@
*/
public class TestA4JCommandLink extends AbstractMetamerTest {
- private ElementLocator input = pjq("input[id$=input]");
- private ElementLocator link = pjq("a[id$=a4jCommandLink]");
- private ElementLocator output1 = pjq("span[id$=output1]");
- private ElementLocator output2 = pjq("span[id$=output2]");
- private ElementLocator output3 = pjq("span[id$=output3]");
+ private JQueryLocator input = pjq("input[id$=input]");
+ private JQueryLocator link = pjq("a[id$=a4jCommandLink]");
+ private JQueryLocator output1 = pjq("span[id$=output1]");
+ private JQueryLocator output2 = pjq("span[id$=output2]");
+ private JQueryLocator output3 = pjq("span[id$=output3]");
@Override
public URL getTestUrl() {
@@ -98,9 +98,9 @@
@Test(dataProvider = "templates")
public void testAction(String templates) {
- ElementLocator doubleStringAction = pjq("input[value=doubleStringAction]");
- ElementLocator first6CharsAction = pjq("input[value=first6CharsAction]");
- ElementLocator toUpperCaseAction = pjq("input[value=toUpperCaseAction]");
+ JQueryLocator doubleStringAction = pjq("input[value=doubleStringAction]");
+ JQueryLocator first6CharsAction = pjq("input[value=first6CharsAction]");
+ JQueryLocator toUpperCaseAction = pjq("input[value=toUpperCaseAction]");
selenium.click(doubleStringAction);
selenium.waitForPageToLoad(TIMEOUT);
@@ -130,9 +130,9 @@
@Test(dataProvider = "templates")
public void testActionListener(String templates) {
- ElementLocator doubleStringActionListener = pjq("input[value=doubleStringActionListener]");
- ElementLocator first6CharsActionListener = pjq("input[value=first6CharsActionListener]");
- ElementLocator toUpperCaseActionListener = pjq("input[value=toUpperCaseActionListener]");
+ JQueryLocator doubleStringActionListener = pjq("input[value=doubleStringActionListener]");
+ JQueryLocator first6CharsActionListener = pjq("input[value=first6CharsActionListener]");
+ JQueryLocator toUpperCaseActionListener = pjq("input[value=toUpperCaseActionListener]");
selenium.click(doubleStringActionListener);
selenium.waitForPageToLoad(TIMEOUT);
@@ -163,8 +163,8 @@
@Test(dataProvider = "templates")
public void testDisabled(String templates) {
- ElementLocator disabledChecbox = pjq("input[id$=disabledInput]");
- ElementLocator newLink = pjq("span[id$=a4jCommandLink]");
+ JQueryLocator disabledChecbox = pjq("input[id$=disabledInput]");
+ JQueryLocator newLink = pjq("span[id$=a4jCommandLink]");
selenium.click(disabledChecbox);
selenium.waitForPageToLoad(TIMEOUT);
@@ -228,7 +228,7 @@
@Test(dataProvider = "templates")
public void testRender(String templates) {
- ElementLocator renderInput = pjq("input[name$=renderInput]");
+ JQueryLocator renderInput = pjq("input[name$=renderInput]");
selenium.type(renderInput, "output1");
selenium.waitForPageToLoad(TIMEOUT);
@@ -268,7 +268,7 @@
@Test(dataProvider = "templates")
public void testRendered(String templates) {
- ElementLocator renderedCheckbox = pjq("input[name$=renderedInput]");
+ JQueryLocator renderedCheckbox = pjq("input[name$=renderedInput]");
selenium.click(renderedCheckbox);
selenium.waitForPageToLoad(TIMEOUT);
@@ -277,11 +277,11 @@
@Test(dataProvider = "templates")
public void testStyleClass(String templates) {
- ElementLocator bold = pjq("input[name$=styleClassInput][value=bold]");
- ElementLocator strike = pjq("input[name$=styleClassInput][value=strike]");
- ElementLocator none = pjq("input[name$=styleClassInput][value=]");
+ JQueryLocator bold = pjq("input[name$=styleClassInput][value=bold]");
+ JQueryLocator strike = pjq("input[name$=styleClassInput][value=strike]");
+ JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
- final AttributeLocator classAttribute = link.getAttribute(new Attribute("class"));
+ final AttributeLocator<?> classAttribute = link.getAttribute(new Attribute("class"));
selenium.click(bold);
selenium.waitForPageToLoad(TIMEOUT);
@@ -298,8 +298,8 @@
@Test(dataProvider = "templates")
public void testStyle(String templates) {
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = link.getAttribute(new Attribute("style"));
+ JQueryLocator styleInput = pjq("input[id$=styleInput]");
+ final AttributeLocator<?> attribute = link.getAttribute(new Attribute("style"));
final String value = "font-size: 20px;";
selenium.type(styleInput, value);
@@ -310,7 +310,7 @@
@Test(dataProvider = "templates")
public void testValue(String templates) {
- ElementLocator valueInput = pjq("input[id$=valueInput]");
+ JQueryLocator valueInput = pjq("input[id$=valueInput]");
final String value = "new label";
selenium.type(valueInput, value);
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jLog/TestA4JLog.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -30,7 +30,6 @@
import java.net.URL;
-import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.AfterMethod;
@@ -51,12 +50,12 @@
DEBUG, INFO, WARN, ERROR;
}
- private ElementLocator input = pjq("input[id$=nameInput]");
- private ElementLocator submitButton = pjq("input[id$=submitButton]");
- private ElementLocator output = pjq("span[id$=out]");
+ private JQueryLocator input = pjq("input[id$=nameInput]");
+ private JQueryLocator submitButton = pjq("input[id$=submitButton]");
+ private JQueryLocator output = pjq("span[id$=out]");
- private ElementLocator log = pjq("div.rich-log");
- private ElementLocator levelSelect = pjq("div.rich-log select");
+ private JQueryLocator log = pjq("div.rich-log");
+ private JQueryLocator levelSelect = pjq("div.rich-log select");
private JQueryLocator logMsg = pjq("div.rich-log div.rich-log-contents div");
@Override
@@ -94,7 +93,7 @@
@Test(dataProvider = "templates")
public void testClearButton(String templates) {
- ElementLocator clearButton = pjq("div.rich-log button");
+ JQueryLocator clearButton = pjq("div.rich-log button");
selenium.typeKeys(input, "RichFaces 4");
selenium.click(submitButton);
@@ -112,7 +111,7 @@
@Test(dataProvider = "templates")
public void testRendered(String templates) {
- ElementLocator renderedInput = pjq("input[id$=renderedInput]");
+ JQueryLocator renderedInput = pjq("input[id$=renderedInput]");
selenium.click(renderedInput);
selenium.waitForPageToLoad(TIMEOUT);
@@ -201,10 +200,10 @@
}
private void testLogging(LogLevel logLevel, LogLevel filterLevel) {
- ElementLocator logButton = pjq("input[id$=" + logLevel.toString().toLowerCase() + "Button]");
- ElementLocator levelInput = pjq("input[type=radio][value=" + filterLevel.toString().toLowerCase() + "]");
- ElementLocator msgType = logMsg.getChild(jq("span:eq(0)"));
- ElementLocator msgContent = logMsg.getChild(jq("span:eq(1)"));
+ JQueryLocator logButton = pjq("input[id$=" + logLevel.toString().toLowerCase() + "Button]");
+ JQueryLocator levelInput = pjq("input[type=radio][value=" + filterLevel.toString().toLowerCase() + "]");
+ JQueryLocator msgType = logMsg.getChild(jq("span:eq(0)"));
+ JQueryLocator msgContent = logMsg.getChild(jq("span:eq(1)"));
if (filterLevel != LogLevel.DEBUG) {
selenium.click(levelInput);
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -33,7 +33,7 @@
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
@@ -47,11 +47,11 @@
*/
public class TestA4JOutputPanel extends AbstractMetamerTest {
- private ElementLocator increaseCounterButton = pjq("input[id$=button]");
- private ElementLocator outputDiv = pjq("div[id$=outputPanel]");
- private ElementLocator outputSpan = pjq("span[id$=outputPanel]");
- private ElementLocator optionBlue = pjq("input[name$=styleClassInput][value=blue-background]");
- private ElementLocator optionGray = pjq("input[name$=styleClassInput][value=gray-background]");
+ private JQueryLocator increaseCounterButton = pjq("input[id$=button]");
+ private JQueryLocator outputDiv = pjq("div[id$=outputPanel]");
+ private JQueryLocator outputSpan = pjq("span[id$=outputPanel]");
+ private JQueryLocator optionBlue = pjq("input[name$=styleClassInput][value=blue-background]");
+ private JQueryLocator optionGray = pjq("input[name$=styleClassInput][value=gray-background]");
@Override
public URL getTestUrl() {
@@ -98,7 +98,7 @@
@Test(dataProvider = "templatesEventsLayouts")
public void testEvent(String templates, Event event, String type) {
- ElementLocator element = null;
+ JQueryLocator element = null;
if ("inline".equals(type)) {
// for inline layout set background to blue
@@ -131,8 +131,8 @@
@Test(dataProvider = "templates")
public void testAjaxRendered(String templates) {
- ElementLocator ajaxRenderedCheckbox = pjq("input[id$=ajaxRenderedInput]");
- ElementLocator reRenderAllImage = jq("div.header img[id$=reRenderAllImage]");
+ JQueryLocator ajaxRenderedCheckbox = pjq("input[id$=ajaxRenderedInput]");
+ JQueryLocator reRenderAllImage = jq("div.header img[id$=reRenderAllImage]");
selenium.click(ajaxRenderedCheckbox);
selenium.waitForPageToLoad(TIMEOUT);
@@ -149,10 +149,10 @@
@Test(dataProvider = "templates")
public void testDir(String templates) {
- ElementLocator optionLtr = pjq("input[name$=dirInput][value=ltr]");
- ElementLocator optionRtl = pjq("input[name$=dirInput][value=rtl]");
- ElementLocator optionNone = pjq("input[name$=dirInput][value=]");
- AttributeLocator attributeDir = outputDiv.getAttribute(new Attribute("dir"));
+ JQueryLocator optionLtr = pjq("input[name$=dirInput][value=ltr]");
+ JQueryLocator optionRtl = pjq("input[name$=dirInput][value=rtl]");
+ JQueryLocator optionNone = pjq("input[name$=dirInput][value=]");
+ AttributeLocator<?> attributeDir = outputDiv.getAttribute(new Attribute("dir"));
// right-to-left
selenium.click(optionRtl);
@@ -177,8 +177,8 @@
@Test(dataProvider = "templates")
public void testLang(String templates) {
- ElementLocator langInput = pjq("input[id$=langInput]");
- AttributeLocator attributeLang = outputDiv.getAttribute(new Attribute("lang"));
+ JQueryLocator langInput = pjq("input[id$=langInput]");
+ AttributeLocator<?> attributeLang = outputDiv.getAttribute(new Attribute("lang"));
selenium.typeKeys(langInput, "en");
selenium.waitForPageToLoad(TIMEOUT);
@@ -195,9 +195,9 @@
@Test(dataProvider = "templates")
public void testLayout(String templates) {
- ElementLocator optionBlock = pjq("input[name$=layoutInput][value=block]");
- ElementLocator optionInline = pjq("input[name$=layoutInput][value=inline]");
- ElementLocator optionNone = pjq("input[name$=layoutInput][value=none]");
+ JQueryLocator optionBlock = pjq("input[name$=layoutInput][value=block]");
+ JQueryLocator optionInline = pjq("input[name$=layoutInput][value=inline]");
+ JQueryLocator optionNone = pjq("input[name$=layoutInput][value=none]");
assertTrue(selenium.isElementPresent(outputDiv), "Div should be rendered on the beginning.");
assertFalse(selenium.isElementPresent(outputSpan), "Div should be rendered on the beginning.");
@@ -220,7 +220,7 @@
@Test(dataProvider = "templates")
public void testRendered(String templates) {
- ElementLocator renderedInput = pjq("input[id$=renderedInput]");
+ JQueryLocator renderedInput = pjq("input[id$=renderedInput]");
selenium.click(renderedInput);
selenium.waitForPageToLoad(TIMEOUT);
@@ -240,8 +240,8 @@
@Test(dataProvider = "templates")
public void testStyle(String templates) {
String style = "background-color: magenta; color: white; font-weight: bold;";
- ElementLocator styleInput = pjq("input[id$=styleInput]");
- AttributeLocator attributeStyle = outputDiv.getAttribute(Attribute.STYLE);
+ JQueryLocator styleInput = pjq("input[id$=styleInput]");
+ AttributeLocator<?> attributeStyle = outputDiv.getAttribute(Attribute.STYLE);
selenium.typeKeys(styleInput, style);
selenium.waitForPageToLoad(TIMEOUT);
@@ -260,8 +260,8 @@
@Test(dataProvider = "templates")
public void testStyleClass(String templates) {
- ElementLocator optionNone = pjq("input[name$=styleClassInput][value=]");
- AttributeLocator attributeClass = outputDiv.getAttribute(Attribute.CLASS);
+ JQueryLocator optionNone = pjq("input[name$=styleClassInput][value=]");
+ AttributeLocator<?> attributeClass = outputDiv.getAttribute(Attribute.CLASS);
selenium.click(optionBlue);
selenium.waitForPageToLoad(TIMEOUT);
@@ -288,8 +288,8 @@
@Test(dataProvider = "templates")
public void testTitle(String templates) {
String title = "a4j:outputPanel title";
- ElementLocator titleInput = pjq("input[id$=titleInput]");
- AttributeLocator attributeTitle = outputDiv.getAttribute(new Attribute("title"));
+ JQueryLocator titleInput = pjq("input[id$=titleInput]");
+ AttributeLocator<?> attributeTitle = outputDiv.getAttribute(new Attribute("title"));
selenium.typeKeys(titleInput, title);
selenium.waitForPageToLoad(TIMEOUT);
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestPoll.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -26,7 +26,7 @@
import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
-import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.IdLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.AfterMethod;
@@ -53,10 +53,10 @@
private static final int MAX_DEVIATION = 100;
private static final int MAX_AVERAGE_DEVIATION = 50;
- ElementLocator attributeEnabled = id("form:attributes:enabledInput");
- ElementLocator attributeInterval = id("form:attributes:intervalInput");
+ IdLocator attributeEnabled = id("form:attributes:enabledInput");
+ IdLocator attributeInterval = id("form:attributes:intervalInput");
JQueryLocator time = pjq("span[id$=time]");
- AttributeLocator clientTime = pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
+ AttributeLocator<?> clientTime = pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
@Override
public URL getTestUrl() {
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTest.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTest.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/AbstractPushTest.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -33,7 +33,7 @@
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.jboss.test.selenium.SystemProperties;
-import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.request.RequestType;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.BeforeClass;
@@ -50,7 +50,7 @@
protected PushAttributes pushAttributes = new PushAttributes();
- private ElementLocator outputCounter = pjq("span[id$=outputCounter]");
+ private JQueryLocator outputCounter = pjq("span[id$=outputCounter]");
private HttpClient httpClient;
private HttpMethod pushMethod;
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/PushAttributes.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/PushAttributes.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/PushAttributes.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -26,7 +26,7 @@
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
-import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.IdLocator;
/**
* The control point for setting different attributes for a4j:push test page.
@@ -38,7 +38,7 @@
private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- private ElementLocator attributeInterval = id("form:attributes:intervalInput");
+ private IdLocator attributeInterval = id("form:attributes:intervalInput");
public void setInterval(long miliseconds) {
selenium.type(attributeInterval, String.valueOf(miliseconds));
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestInterval.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestInterval.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPush/TestInterval.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -49,7 +49,7 @@
private static final int ITERATION_COUNT = 3;
private static final int MULTIPLE_PUSH_COUNT = 5;
- AttributeLocator clientTime = pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
+ AttributeLocator<?> clientTime = pjq("span[id$=clientDate]").getAttribute(ATTRIBUTE_TITLE);
private long startTime;
private int counter;
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/hCommandButton/TestHCommandButton.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -164,7 +164,7 @@
@Test(dataProvider = "templates")
public void testDisabled(String templates) {
JQueryLocator disabledChecbox = pjq("input[id$=disabledInput]");
- AttributeLocator disabledAttribute = button.getAttribute(new Attribute("disabled"));
+ AttributeLocator<?> disabledAttribute = button.getAttribute(new Attribute("disabled"));
selenium.click(disabledChecbox);
selenium.waitForPageToLoad(TIMEOUT);
@@ -248,7 +248,7 @@
JQueryLocator big = pjq("input[name$=styleClassInput][value=big]");
JQueryLocator none = pjq("input[name$=styleClassInput][value=]");
- final AttributeLocator classAttribute = button.getAttribute(new Attribute("class"));
+ final AttributeLocator<?> classAttribute = button.getAttribute(new Attribute("class"));
selenium.click(wide);
selenium.waitForPageToLoad(TIMEOUT);
@@ -266,7 +266,7 @@
@Test(dataProvider = "templates")
public void testStyle(String templates) {
JQueryLocator styleInput = pjq("input[id$=styleInput]");
- final AttributeLocator attribute = button.getAttribute(new Attribute("style"));
+ final AttributeLocator<?> attribute = button.getAttribute(new Attribute("style"));
final String value = "font-size: 20px;";
selenium.type(styleInput, value);
@@ -278,7 +278,7 @@
@Test(dataProvider = "templates")
public void testValue(String templates) {
JQueryLocator valueInput = pjq("input[id$=valueInput]");
- final AttributeLocator attribute = button.getAttribute(new Attribute("value"));
+ final AttributeLocator<?> attribute = button.getAttribute(new Attribute("value"));
final String value = "new label";
selenium.type(valueInput, value);
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-22 23:33:00 UTC (rev 18208)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-23 07:19:27 UTC (rev 18209)
@@ -27,7 +27,7 @@
import java.net.URL;
-import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.IdLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.Test;
@@ -45,7 +45,7 @@
DataScroller dataScroller1 = new DataScroller(pjq("span.rf-ds[id$=scroller1]"));
DataScroller dataScroller2 = new DataScroller(pjq("span.rf-ds[id$=scroller2]"));
DataTable table = new DataTable(pjq("div.rf-edt[id$=richEDT]"));
- ElementLocator attributeRowsInput = id("form:attributes:rowsInput");
+ IdLocator attributeRowsInput = id("form:attributes:rowsInput");
@Override
public URL getTestUrl() {
14 years, 5 months
JBoss Rich Faces SVN: r18208 - root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-22 19:33:00 -0400 (Thu, 22 Jul 2010)
New Revision: 18208
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java
Log:
work in progress https://jira.jboss.org/browse/RF-8907
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java 2010-07-22 23:30:41 UTC (rev 18207)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Attribute.java 2010-07-22 23:33:00 UTC (rev 18208)
@@ -85,7 +85,7 @@
Description description() default @Description();
- Signature signature() default @Signature();
+ Signature signature() default @Signature(returnType=Signature.NONE.class);
EventName[] events() default {};
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java 2010-07-22 23:30:41 UTC (rev 18207)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/Signature.java 2010-07-22 23:33:00 UTC (rev 18208)
@@ -40,7 +40,7 @@
*
* @return
*/
- public Class<?> returnType() default NONE.class;
+ Class<?> returnType() default Void.class;
/**
* <p class="changed_added_4_0">
@@ -49,7 +49,7 @@
*
* @return
*/
- public Class<?>[] parameters() default {};
+ Class<?>[] parameters() default {};
public static final class NONE {}
}
14 years, 5 months
JBoss Rich Faces SVN: r18207 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/model and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-22 19:30:41 -0400 (Thu, 22 Jul 2010)
New Revision: 18207
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/MethodSignature.java
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/PropertyBase.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
Log:
work in progress https://jira.jboss.org/browse/RF-8907
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/apt/processors/AttributesProcessorImpl.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -1,15 +1,10 @@
package org.richfaces.cdk.apt.processors;
+import java.io.FileNotFoundException;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Name;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.MirroredTypeException;
import javax.lang.model.type.MirroredTypesException;
@@ -25,6 +20,7 @@
import org.richfaces.cdk.apt.SourceUtils.SuperTypeVisitor;
import org.richfaces.cdk.model.BeanModelBase;
import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.model.MethodSignature;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.util.Strings;
import org.richfaces.cdk.xmlconfig.CdkEntityResolver;
@@ -35,12 +31,19 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
public class AttributesProcessorImpl implements AttributesProcessor {
- private static final String SIGNATURE_NONE_CLASS_NAME = Signature.NONE.class.getName().replace('$', '.');
+ private static final ClassName SIGNATURE_NONE_CLASS_NAME = ClassName.get(Signature.NONE.class);
private static final String STRING_NAME = String.class.getName();
-
+
@Inject
private Logger log;
@@ -51,13 +54,16 @@
private final FragmentParser parser;
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @param descriptionProcessor
* @param utilsProvider
* @param parser
*/
@Inject
- public AttributesProcessorImpl(DescriptionProcessor descriptionProcessor, Provider<SourceUtils> utilsProvider, FragmentParser parser) {
+ public AttributesProcessorImpl(DescriptionProcessor descriptionProcessor, Provider<SourceUtils> utilsProvider,
+ FragmentParser parser) {
this.descriptionProcessor = descriptionProcessor;
this.utilsProvider = utilsProvider;
this.parser = parser;
@@ -87,7 +93,8 @@
attribute.setReadOnly(attributeAnnotarion.readOnly());
attribute.setGenerate(attributeAnnotarion.generate() || !beanProperty.isExists());
- descriptionProcessor.processDescription(attribute, attributeAnnotarion.description(), beanProperty.getDocComment());
+ descriptionProcessor.processDescription(attribute, attributeAnnotarion.description(), beanProperty
+ .getDocComment());
setDefaultValue(attribute, attributeAnnotarion);
@@ -97,21 +104,8 @@
}
// MethodExpression call signature.
- AnnotationValue signatureMirror = null;
- List<? extends AnnotationMirror> mirrors = beanProperty.getAnnotationMirrors();
- for (AnnotationMirror mirror : mirrors) {
- if (Attribute.class.getName().equals(mirror.getAnnotationType().toString())) {
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : mirror.getElementValues().entrySet()) {
- Name simpleName = entry.getKey().getSimpleName();
- if ("signature".equals(simpleName.toString())) {
- signatureMirror = entry.getValue();
- }
- }
+ attribute.setSignature(getSignature(attributeAnnotarion.signature()));
- }
- }
- attribute.setSignature(getSignature(attributeAnnotarion.signature(), signatureMirror));
-
for (EventName event : attributeAnnotarion.events()) {
setBehaviorEvent(attribute, event);
}
@@ -153,7 +147,6 @@
} else if (isInstace(char.class, typeName)) {
return "Character.MIN_VALUE";
}
-
return null;
}
@@ -161,63 +154,35 @@
return byteClass.getSimpleName().equals(typeName);
}
- private List<ClassName> getSignature(Signature signature, AnnotationValue signatureMirror) {
+ private MethodSignature getSignature(Signature signature) {
- String returnType;
+ ClassName returnType;
+
try {
- returnType = signature.returnType().getName();
+ returnType = ClassName.get(signature.returnType());
} catch (MirroredTypeException e) {
TypeMirror returnTypeMirror = e.getTypeMirror();
- returnType = returnTypeMirror.toString();
+ returnType = ClassName.get(returnTypeMirror.toString());
}
- if (signature != null && !SIGNATURE_NONE_CLASS_NAME.equals(returnType)) {
- return getSignatureParams(signature, signatureMirror);
- // signature parameters always should be replaced.
- // TODO - set method return type.
-
+ if (!SIGNATURE_NONE_CLASS_NAME.equals(returnType)) {
+ MethodSignature methodSignature = new MethodSignature();
+ methodSignature.setParameters(getSignatureParams(signature));
+ return methodSignature;
}
- return Collections.emptyList();
+ return null;
}
- private List<ClassName> getSignatureParams(Signature signature, AnnotationValue signatureMirror) {
+ private List<ClassName> getSignatureParams(Signature signature) {
List<ClassName> parameters = Lists.newArrayList();
try {
for (Class<?> parameterType : signature.parameters()) {
- parameters.add(new ClassName(parameterType.getName()));
+ parameters.add(ClassName.get(parameterType));
}
} catch (MirroredTypeException e) {
- AnnotationValue params = signatureMirror.accept(new EmptyAnnotationValueVisitor<AnnotationValue>() {
- @Override
- public AnnotationValue visitAnnotation(AnnotationMirror a, Object o) {
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : a.getElementValues().entrySet()) {
- if ("parameters".equals(entry.getKey().getSimpleName().toString())) {
- return entry.getValue();
- }
- }
- return null;
- }
- }, null);
-
- List<? extends AnnotationValue> o = params.accept(new EmptyAnnotationValueVisitor<List<? extends AnnotationValue>>(){
- @Override
- public List<? extends AnnotationValue> visitArray(List<? extends AnnotationValue> vals, Object o) {
- return vals;
- }
- }, null);
-
- for (AnnotationValue annotationValue : o) {
- parameters.add(annotationValue.accept(new EmptyAnnotationValueVisitor<ClassName>() {
- @Override
- public ClassName visitType(TypeMirror t, Object o) {
- return new ClassName(t.toString());
- }
- }, null));
- }
-// TypeMirror parameterType = e.getTypeMirror();
-// parameters.add(new ClassName(parameterType.toString()));
+ parameters.add(ClassName.get(e.getTypeMirror().toString()));
} catch (MirroredTypesException e) {
for (TypeMirror parameterType : e.getTypeMirrors()) {
parameters.add(new ClassName(parameterType.toString()));
@@ -225,10 +190,8 @@
}
return parameters;
- // signature parameters always should be replaced.
- // TODO - set method return type.
}
-
+
private void setBehaviorEvent(PropertyBase attribute, EventName eventName) {
if (null != eventName) {
org.richfaces.cdk.model.EventName event = new org.richfaces.cdk.model.EventName();
@@ -238,7 +201,7 @@
attribute.getEventNames().add(event);
}
}
-
+
@Override
public void processType(final BeanModelBase component, TypeElement element) throws CdkException {
log.debug("AttributesProcessorImpl.processType");
@@ -249,32 +212,32 @@
log.debug(" -> sourceUtils.visitSupertypes...");
SourceUtils sourceUtils = getSourceUtils();
sourceUtils.visitSupertypes(element, new SuperTypeVisitor() {
-
+
@Override
public void visit(TypeMirror type) {
+ String uri = type.toString() + ".xml";
try {
log.debug(" -> visit - " + type.toString());
- component.getAttributes().addAll(
- parseProperties(type.toString() + ".xml"));
+ component.getAttributes().addAll(parseProperties(uri));
} catch (CdkException e) {
- // TODO - log errors ?
+ log.error(e);
+ } catch (FileNotFoundException e) {
+ log.debug("No properties description found at "+uri);
}
}
});
-
log.debug(" -- Process Java files.");
Set<BeanProperty> properties = Sets.newHashSet();
properties.addAll(sourceUtils.getBeanPropertiesAnnotatedWith(Attribute.class, element));
properties.addAll(sourceUtils.getAbstractBeanProperties(element));
- // TODO - encapsulate attribute builder into utility class.
for (BeanProperty beanProperty : properties) {
processAttribute(beanProperty, component.getOrCreateAttribute(beanProperty.getName()));
}
}
- private Collection<? extends PropertyBase> parseProperties(String uri) {
+ private Collection<? extends PropertyBase> parseProperties(String uri) throws FileNotFoundException {
return parser.parseProperties(CdkEntityResolver.URN_ATTRIBUTES + uri);
}
@@ -282,15 +245,16 @@
return utilsProvider.get();
}
-
@Override
- public void processXmlFragment(BeanModelBase component, String ...attributesConfig) {
+ public void processXmlFragment(BeanModelBase component, String... attributesConfig) {
// Process all files from @Jsf.. attributes property.
for (String attributes : attributesConfig) {
try {
component.getAttributes().addAll(parseProperties(attributes));
} catch (CdkException e) {
- // TODO - log errors ?
+ log.error(e);
+ } catch (FileNotFoundException e) {
+ log.debug("No properties description found at "+attributes);
}
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/ClassName.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -73,9 +73,7 @@
* @param cl
*/
public ClassName(Class<?> cl) {
-
- // TODO get information directly from class.
- this(cl.getName());
+ this(cl.getName().replace('$', '.'));
}
/**
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/MethodSignature.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/MethodSignature.java (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/MethodSignature.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -0,0 +1,85 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+@SuppressWarnings("serial")
+@XmlType(name = "signature", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+(a)XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
+public class MethodSignature implements Serializable {
+
+ private ClassName returnType = ClassName.get(Void.class);
+
+ private List<ClassName> parameters = Lists.newArrayList();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the returnType
+ */
+ @XmlElement(name = "return-type", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public ClassName getReturnType() {
+ return this.returnType;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param returnType the returnType to set
+ */
+ public void setReturnType(ClassName returnType) {
+ this.returnType = returnType;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the parameters
+ */
+ @XmlElement(name = "param", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public List<ClassName> getParameters() {
+ return this.parameters;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param parameters the parameters to set
+ */
+ public void setParameters(List<ClassName> parameters) {
+ this.parameters = parameters;
+ }
+
+
+}
Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/MethodSignature.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/PropertyBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/PropertyBase.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/model/PropertyBase.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -22,12 +22,10 @@
package org.richfaces.cdk.model;
-import java.util.List;
import java.util.Set;
import org.richfaces.cdk.util.ComparatorUtils;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
/**
@@ -50,7 +48,7 @@
private boolean passThrough = false;
private Set<EventName> eventNames = Sets.newLinkedHashSet();
- private List<ClassName> signature = Lists.newArrayList();
+ private MethodSignature signature ;
private String defaultValue;
@@ -276,7 +274,7 @@
* @return the signature
*/
@Merge(true)
- public List<ClassName> getSignature() {
+ public MethodSignature getSignature() {
return signature;
}
@@ -285,7 +283,7 @@
*
* @param signature the signature to set
*/
- public void setSignature(List<ClassName> signature) {
+ public void setSignature(MethodSignature signature) {
this.signature = signature;
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -24,6 +24,7 @@
package org.richfaces.cdk.templatecompiler;
import java.io.File;
+import java.io.FileNotFoundException;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.List;
@@ -42,6 +43,7 @@
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.MethodSignature;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.PropertyModel;
import org.richfaces.cdk.model.RenderKitModel;
@@ -69,7 +71,7 @@
public class RendererTemplateParser implements ModelBuilder {
private static final Pattern PARAMETERS_STRING_PATTERN =
- Pattern.compile("\\( ( [^\\)]* ) \\) \\s*$", Pattern.COMMENTS);
+ Pattern.compile("^(\\S+)\\s+(\\S+)\\s*\\(([^\\)]*)\\)$", Pattern.COMMENTS);
private static final Pattern COMMA_SEPARATED_PATTERN = Pattern.compile("\\s*,\\s*", Pattern.COMMENTS);
@@ -121,28 +123,29 @@
return result;
}
- private List<ClassName> parseSignature(String signatureString) {
+ private MethodSignature parseSignature(String signatureString) {
- List<ClassName> result = Lists.newArrayList();
+ List<ClassName> parameters = Lists.newArrayList();
+ MethodSignature signature = new MethodSignature();
if (!Strings.isEmpty(signatureString)) {
Matcher parametersStringMatcher = PARAMETERS_STRING_PATTERN.matcher(signatureString);
if (!parametersStringMatcher.find()) {
- // TODO - handle exception
throw new IllegalArgumentException(MessageFormat.format("Signature string {0} cannot be parsed!",
signatureString));
}
-
- String parametersString = parametersStringMatcher.group(1);
+ signature.setReturnType(ClassName.parseName(parametersStringMatcher.group(1)));
+ String parametersString = parametersStringMatcher.group(3);
if (parametersString.trim().length() != 0) {
- String[] parameters = COMMA_SEPARATED_PATTERN.split(parametersString);
- for (String parameter : parameters) {
+ String[] parameterStrings = COMMA_SEPARATED_PATTERN.split(parametersString);
+ for (String parameter : parameterStrings) {
String trimmedParameter = parameter.trim();
- result.add(ClassName.parseName(trimmedParameter));
+ parameters.add(ClassName.parseName(trimmedParameter));
}
+ signature.setParameters(parameters);
}
}
- return result;
+ return signature;
}
/*
@@ -160,7 +163,7 @@
}
}
- public void build(File file, RendererModel rendererModel) {
+ public void build(File file, RendererModel rendererModel) throws CdkException {
log.debug("RendererTemplateParser.build");
final String absolutePath = file.getAbsolutePath();
log.debug(" - file = " + absolutePath);
@@ -183,9 +186,7 @@
}
Template template = parseTemplate(file);
-
template.setTemplatePath(absolutePath);
-
mergeTemplateIntoModel(template, rendererModel);
}
@@ -212,9 +213,14 @@
if (attributesImports != null) {
for (ImportAttributes attributesImport : attributesImports) {
String importURI = attributesImport.getSource();
- Collection<PropertyBase> properties = fragmentParser.parseProperties(importURI);
- if (properties != null) {
- renderer.getAttributes().addAll(properties);
+ Collection<PropertyBase> properties;
+ try {
+ properties = fragmentParser.parseProperties(importURI);
+ if (properties != null) {
+ renderer.getAttributes().addAll(properties);
+ }
+ } catch (FileNotFoundException e) {
+ throw new CdkException("File for import not found", e);
}
}
}
@@ -253,8 +259,8 @@
rendererProperty.setRequired(templateAttribute.isRequired());
- List<ClassName> parsedSignature = parseSignature(templateAttribute.getMethodSignature());
- rendererProperty.getSignature().addAll(parsedSignature);
+ MethodSignature parsedSignature = parseSignature(templateAttribute.getMethodSignature());
+ rendererProperty.setSignature(parsedSignature);
rendererProperty.setType(templateAttribute.getType());
return rendererProperty;
@@ -277,7 +283,11 @@
}
protected Template parseTemplate(File file) throws CdkException {
- return jaxbBinding.unmarshal(file, "http://richfaces.org/cdk/cdk-template.xsd", Template.class);
+ try {
+ return jaxbBinding.unmarshal(file, "http://richfaces.org/cdk/cdk-template.xsd", Template.class);
+ } catch (FileNotFoundException e) {
+ throw new CdkException("Template file not found " + file.getAbsolutePath(), e);
+ }
}
public NamingConventions getNamingConventions() {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -3,6 +3,9 @@
*/
package org.richfaces.cdk.templatecompiler;
+import java.io.FileNotFoundException;
+
+import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.attributes.Schema;
import org.richfaces.cdk.attributes.SchemaSet;
import org.richfaces.cdk.templatecompiler.model.Template;
@@ -26,7 +29,12 @@
@Override
public Schema get() {
- SchemaSet schemaSet = jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
+ SchemaSet schemaSet;
+ try {
+ schemaSet = jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
+ } catch (FileNotFoundException e) {
+ throw new CdkException(e);
+ }
return schemaSet.getSchemas().get(Template.XHTML_EL_NAMESPACE);
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FacesConfigParser.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -24,9 +24,11 @@
package org.richfaces.cdk.xmlconfig;
import java.io.File;
+import java.io.FileNotFoundException;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.FileManager;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.ModelBuilder;
import org.richfaces.cdk.Source;
import org.richfaces.cdk.Sources;
@@ -49,6 +51,9 @@
private static final FacesConfigAdapter ADAPTER = new FacesConfigAdapter();
@Inject
+ private Logger log;
+
+ @Inject
private JAXB jaxbBinding;
@Inject
@@ -66,35 +71,39 @@
@Override
public void build() throws CdkException {
for (File file : configFiles.getFiles()) {
- FacesConfigBean unmarshal = unmarshalFacesConfig(file);
- if (null != unmarshal) {
- ComponentLibrary facesConfig = ADAPTER.unmarshal(unmarshal);
- library.getComponents().addAll(facesConfig.getComponents());
- library.getRenderKits().addAll(facesConfig.getRenderKits());
- library.getConverters().addAll(facesConfig.getConverters());
- library.getValidators().addAll(facesConfig.getValidators());
- library.getBehaviors().addAll(facesConfig.getBehaviors());
- library.getFunctions().addAll(facesConfig.getFunctions());
- library.getEvents().addAll(facesConfig.getEvents());
- if (null != unmarshal.getMetadataComplete()) {
- library.setMetadataComplete(unmarshal.getMetadataComplete());
- }
- library.getExtension().getExtensions().addAll(facesConfig.getExtension().getExtensions());
- if (null != facesConfig.getTaglib()) {
- if (null == library.getTaglib()) {
- library.setTaglib(facesConfig.getTaglib());
- } else {
- JavaUtils.copyProperties(facesConfig.getTaglib(), library.getTaglib());
+ try {
+ FacesConfigBean unmarshal = unmarshalFacesConfig(file);
+ if (null != unmarshal) {
+ ComponentLibrary facesConfig = ADAPTER.unmarshal(unmarshal);
+ library.getComponents().addAll(facesConfig.getComponents());
+ library.getRenderKits().addAll(facesConfig.getRenderKits());
+ library.getConverters().addAll(facesConfig.getConverters());
+ library.getValidators().addAll(facesConfig.getValidators());
+ library.getBehaviors().addAll(facesConfig.getBehaviors());
+ library.getFunctions().addAll(facesConfig.getFunctions());
+ library.getEvents().addAll(facesConfig.getEvents());
+ if (null != unmarshal.getMetadataComplete()) {
+ library.setMetadataComplete(unmarshal.getMetadataComplete());
}
+ library.getExtension().getExtensions().addAll(facesConfig.getExtension().getExtensions());
+ if (null != facesConfig.getTaglib()) {
+ if (null == library.getTaglib()) {
+ library.setTaglib(facesConfig.getTaglib());
+ } else {
+ JavaUtils.copyProperties(facesConfig.getTaglib(), library.getTaglib());
+ }
+ }
+ if (null != facesConfig.getPrefix()) {
+ library.setPrefix(facesConfig.getPrefix());
+ }
}
- if (null != facesConfig.getPrefix()) {
- library.setPrefix(facesConfig.getPrefix());
- }
+ } catch (FileNotFoundException e) {
+ log.error("faces-config not found", e);
}
}
}
- protected FacesConfigBean unmarshalFacesConfig(File file) throws CdkException {
+ protected FacesConfigBean unmarshalFacesConfig(File file) throws CdkException, FileNotFoundException {
return jaxbBinding.unmarshal(file, ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION, FacesConfigBean.class);
}
}
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/FragmentParser.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -23,6 +23,7 @@
package org.richfaces.cdk.xmlconfig;
+import java.io.FileNotFoundException;
import java.util.Collection;
import java.util.Collections;
@@ -62,7 +63,7 @@
* @param url
* @return
*/
- public Collection<PropertyBase> parseProperties(String url) throws CdkException {
+ public Collection<PropertyBase> parseProperties(String url) throws CdkException, FileNotFoundException {
String schemaLocation = ComponentLibrary.FACES_CONFIG_SCHEMA_LOCATION;
Class<Fragment> bindClass = Fragment.class;
Fragment unmarshal = binding.unmarshal(url, schemaLocation, bindClass);
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXB.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -1,6 +1,7 @@
package org.richfaces.cdk.xmlconfig;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.Writer;
import javax.xml.transform.Result;
@@ -9,9 +10,9 @@
public interface JAXB {
- public abstract <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException;
+ public abstract <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException,FileNotFoundException;
- public abstract <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException;
+ public abstract <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException,FileNotFoundException;
public abstract <T> void marshal(Writer output, String schemaLocation, T model) throws CdkException;
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/JAXBBinding.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -21,8 +21,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
-
package org.richfaces.cdk.xmlconfig;
import java.io.File;
@@ -62,9 +60,9 @@
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
- *
+ *
*/
public class JAXBBinding implements JAXB {
public static final ImmutableSet<String> IGNORE_PROPERTIES = ImmutableSet.of("class", "extension");
@@ -72,36 +70,38 @@
@Inject
private EntityResolver2 resolver;
-
+
@Inject
private Logger log;
+ public JAXBBinding() {
+ }
- public JAXBBinding() { }
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.richfaces.cdk.xmlconfig.JAXB#unmarshal(java.io.File, java.lang.String, java.lang.Class)
*/
@Override
- public <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException {
- try {
- InputSource input = new InputSource(new FileInputStream(file));
+ public <T> T unmarshal(File file, String schemaLocation, Class<T> bindClass) throws CdkException,
+ FileNotFoundException {
+ InputSource input = new InputSource(new FileInputStream(file));
- input.setSystemId(file.toURI().toString());
+ input.setSystemId(file.toURI().toString());
- T unmarshal = unmarshal(schemaLocation, bindClass, input);
+ T unmarshal = unmarshal(schemaLocation, bindClass, input);
- return unmarshal;
- } catch (FileNotFoundException e) {
- throw new CdkException("XML file not found", e);
- }
+ return unmarshal;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.richfaces.cdk.xmlconfig.JAXB#unmarshal(java.lang.String, java.lang.String, java.lang.Class)
*/
@Override
- public <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException {
+ public <T> T unmarshal(String url, String schemaLocation, Class<T> bindClass) throws CdkException,
+ FileNotFoundException {
try {
InputSource inputSource;
try {
@@ -118,12 +118,12 @@
return unmarshal;
} catch (IOException e) {
- throw new CdkException("XML file not found", e);
+ throw new FileNotFoundException("XML file not found at " + url);
}
}
@SuppressWarnings("unchecked")
- //TODO nick - schemaLocation is unused
+ // TODO nick - schemaLocation is unused
<T> T unmarshal(String schemaLocation, Class<T> bindClass, InputSource inputSource) throws CdkException {
T unmarshal = null;
@@ -175,7 +175,9 @@
return unmarshal;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.richfaces.cdk.xmlconfig.JAXB#marshal(java.io.File, java.lang.String, T)
*/
@Override
@@ -193,7 +195,9 @@
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.richfaces.cdk.xmlconfig.JAXB#marshal(javax.xml.transform.Result, java.lang.String, T)
*/
@Override
@@ -205,7 +209,7 @@
marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
// TODO - let writer to define additional schemes.
-// marshaller.setProperty("jaxb.schemaLocation", Boolean.TRUE);
+ // marshaller.setProperty("jaxb.schemaLocation", Boolean.TRUE);
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
if (null != schemaLocation) {
@@ -227,7 +231,7 @@
* <p class="changed_added_4_0">
* Close input source after parsing.
* </p>
- *
+ *
* @param source
*/
private void closeSource(Source source) {
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/PropertyBase.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -23,19 +23,16 @@
package org.richfaces.cdk.xmlconfig.model;
-import java.util.List;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.richfaces.cdk.model.ClassName;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ConfigExtension;
import org.richfaces.cdk.model.EventName;
+import org.richfaces.cdk.model.MethodSignature;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
/**
@@ -139,7 +136,7 @@
public static class PropertyExtension extends ConfigExtension {
private Boolean passThrough;
private Set<EventName> eventNames = Sets.newLinkedHashSet();
- private List<ClassName> signature = Lists.newArrayList();
+ private MethodSignature signature ;
private String aliasFor ;
private Boolean generate;
private Boolean hidden;
@@ -285,10 +282,8 @@
*
* @return the signature
*/
- @XmlElementWrapper(name = "signature", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlElement(name = "param", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- @XmlJavaTypeAdapter(ClassAdapter.class)
- public List<ClassName> getSignature() {
+ @XmlElement(name = "signature", namespace = ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public MethodSignature getSignature() {
return signature;
}
@@ -297,7 +292,7 @@
*
* @param signature the signature to set
*/
- public void setSignature(List<ClassName> signature) {
+ public void setSignature(MethodSignature signature) {
this.signature = signature;
}
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/apt/processors/AttributesProcessorTest.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -105,7 +105,7 @@
}
@Test
- public void testProcessXmlFragment() {
+ public void testProcessXmlFragment() throws Exception {
BeanModelBase bean = new BeanModelBase();
Fragment fragment = new Fragment();
PropertyModel propertyModel = new PropertyModel();
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/ComponentClassGeneratorTest.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -43,6 +43,7 @@
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.FacesId;
+import org.richfaces.cdk.model.MethodSignature;
import org.richfaces.cdk.model.PropertyBase;
import com.google.inject.Inject;
@@ -86,7 +87,9 @@
attribute.setType(new ClassName(MethodExpression.class));
attribute.setGenerate(true);
attribute.setBindingAttribute(true);
- attribute.setSignature(Arrays.asList(new ClassName(String.class), new ClassName(Integer.class)));
+ MethodSignature signature = new MethodSignature();
+ signature.setParameters(Arrays.asList(new ClassName(String.class), new ClassName(Integer.class)));
+ attribute.setSignature(signature);
attribute = component.getOrCreateAttribute("id");
attribute.setType(new ClassName(String.class));
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/RendererTemplateParserTest.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -27,7 +27,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
import javax.faces.event.ActionEvent;
@@ -48,6 +47,7 @@
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.EventName;
import org.richfaces.cdk.model.FacesId;
+import org.richfaces.cdk.model.MethodSignature;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.model.RenderKitModel;
import org.richfaces.cdk.model.RendererModel;
@@ -95,9 +95,8 @@
}
private void assertNoSignature(PropertyBase property) {
- List<ClassName> signature = property.getSignature();
- assertNotNull(signature);
- assertTrue(signature.isEmpty());
+ MethodSignature signature = property.getSignature();
+ assertNull(signature);
}
private void assertNotRequired(PropertyBase property) {
@@ -127,7 +126,9 @@
assertNotNull(actionProperty);
assertNoEventNames(actionProperty);
- assertEquals(0, actionProperty.getSignature().size());
+ assertNotNull(actionProperty.getSignature());
+ assertEquals(0, actionProperty.getSignature().getParameters().size());
+ assertEquals(String.class.getName(), actionProperty.getSignature().getReturnType());
}
/**
Modified: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-07-22 21:32:57 UTC (rev 18206)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/FragmentParserTest.java 2010-07-22 23:30:41 UTC (rev 18207)
@@ -124,7 +124,7 @@
assertTrue(property.isPassThrough());
assertTrue(property.isRequired());
- List<ClassName> signature = property.getSignature();
+ List<ClassName> signature = property.getSignature().getParameters();
assertEquals(2, signature.size());
14 years, 5 months
JBoss Rich Faces SVN: r18206 - root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-22 17:32:57 -0400 (Thu, 22 Jul 2010)
New Revision: 18206
Modified:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
Log:
https://jira.jboss.org/browse/RF-8888
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-07-22 21:32:08 UTC (rev 18205)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-07-22 21:32:57 UTC (rev 18206)
@@ -45,30 +45,35 @@
* @author akolonitsky
* @since Feb 3, 2010
*/
-public class TaglibGeneratorVisitor extends SimpleVisitor<Boolean,ComponentLibrary> {
+public class TaglibGeneratorVisitor extends SimpleVisitor<Boolean, ComponentLibrary> {
private static final String COMPONENT = "component";
private static final String COMPONENT_TYPE = "component-type";
private static final String RENDERER_TYPE = "renderer-type";
private static final String HANDLER_CLASS = "handler-class";
/**
- * <p class="changed_added_4_0">Generated document.
- * IDEA - set document as visitor patameter, to reuse this object instance.</p>
- */
+ * <p class="changed_added_4_0">
+ * Generated document. IDEA - set document as visitor patameter, to reuse this object instance.
+ * </p>
+ */
private Document document = DocumentHelper.createDocument();
/**
- * <p class="changed_added_4_0">faces-config element in document.</p>
- */
+ * <p class="changed_added_4_0">
+ * faces-config element in document.
+ * </p>
+ */
private Element faceletTaglib;
- private boolean empty=true;
+ private boolean empty = true;
public TaglibGeneratorVisitor() {
}
/**
- * <p class="changed_added_4_0"></p>
+ * <p class="changed_added_4_0">
+ * </p>
+ *
* @return the empty
*/
public boolean isEmpty() {
@@ -84,11 +89,12 @@
}
@Override
- public Boolean visitComponentLibrary(ComponentLibrary model,ComponentLibrary componentLibrary) {
+ public Boolean visitComponentLibrary(ComponentLibrary model, ComponentLibrary componentLibrary) {
faceletTaglib = document.addElement("facelet-taglib", "http://java.sun.com/xml/ns/javaee");
faceletTaglib.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
- faceletTaglib.addAttribute("xsi:schemaLocation", "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd");
+ faceletTaglib.addAttribute("xsi:schemaLocation",
+ "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd");
faceletTaglib.addAttribute("version", "2.0");
faceletTaglib.addAttribute("id", model.getTaglib().getShortName());
@@ -98,56 +104,56 @@
}
@Override
- public Boolean visitComponent(ComponentModel model,ComponentLibrary componentLibrary) {
+ public Boolean visitComponent(ComponentModel model, ComponentLibrary componentLibrary) {
for (TagModel tagModel : model.getTags()) {
- if (TagType.Facelets != tagModel.getType()
- && TagType.All != tagModel.getType()) {
-
- continue;
+ if (isFaceletsTag(tagModel)) {
+ Element tag = createTag(tagModel.getName());
+ // TODO - investigate proper usage of the <handler-class> element.
+ // Most libraries use <handler-class> INSTEAD of <component>
+ Element component = tag.addElement(COMPONENT);
+ addDescription(component, model);
+ component.addElement(COMPONENT_TYPE).addText(model.getId().getType());
+ FacesId rendererType = model.getRendererType();
+ // RendererModel renderer = componentLibrary.getRenderer(model.getFamily(), model.getId().getType());
+ if (null != rendererType) {
+ component.addElement(RENDERER_TYPE).addText(rendererType.toString());
+ }
+ addTagHandler(component, tagModel);
+ appendAttributes(tag, model);
}
-
- Element tag = createTag(tagModel.getName());
- // TODO - investigate proper usage of the <handler-class> element.
- // Most libraries use <handler-class> INSTEAD of <component>
- Element component = tag.addElement(COMPONENT);
- component.addElement(COMPONENT_TYPE).addText(model.getId().getType());
- FacesId rendererType = model.getRendererType();
-// RendererModel renderer = componentLibrary.getRenderer(model.getFamily(), model.getId().getType());
- if (null != rendererType) {
- component.addElement(RENDERER_TYPE).addText(rendererType.toString());
- }
- addTagHandler(component, tagModel);
- appendAttributs(tag, model);
}
return null;
}
/**
- * <p class="changed_added_4_0"></p>
- * @param parent DOM element for which <handler-class> element should be appended.
- * @param tag model.
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param parent
+ * DOM element for which <handler-class> element should be appended.
+ * @param tag
+ * model.
* @return true is explicit handler class definition was generated.
*/
private boolean addTagHandler(Element parent, TagModel tag) {
if (tag != null && tag.getTargetClass() != null) {
- parent.addElement(HANDLER_CLASS).addText(tag.getTargetClass().toString());
+ parent.addElement(HANDLER_CLASS).addText(tag.getTargetClass().getName());
return true;
} else {
return false;
}
}
-
-
@Override
- public Boolean visitConverter(ConverterModel model,ComponentLibrary componentLibrary) {
+ public Boolean visitConverter(ConverterModel model, ComponentLibrary componentLibrary) {
for (TagModel tagModel : model.getTags()) {
- if (TagType.Facelets.equals(tagModel.getType())) {
+ if (isFaceletsTag(tagModel)) {
Element tag = createTag(tagModel.getName());
+ addDescription(tag, model);
Element converter = tag.addElement("converter");
converter.addElement("converter-id", model.getId().toString());
addTagHandler(converter, tagModel);
- appendAttributs(tag, model);
+ appendAttributes(tag, model);
}
}
return null;
@@ -155,36 +161,38 @@
/**
* This method generates validator tag.
- * <pre>
+ *
+ * <pre>
* <tag>
* <tag-name>formatValidator</tag-name>
* <validator>
* <validator-id></validator-id>
* <handler-class></handler-class>
* </validator>
- *
+ *
* <attribute>
* ...
* </attribute>
- * </tag>
- * <pre>
- *
+ * </tag>
+ *
+ * <pre>
+ *
* */
- public Boolean visitValidator(ValidatorModel model,ComponentLibrary componentLibrary) {
+ public Boolean visitValidator(ValidatorModel model, ComponentLibrary componentLibrary) {
for (TagModel tagModel : model.getTags()) {
- if (TagType.Facelets.equals(tagModel.getType())) {
+ if (isFaceletsTag(tagModel)) {
Element tag = createTag(tagModel.getName());
+ addDescription(tag, model);
Element validator = tag.addElement("validator");
validator.addElement("validator-id", model.getId().toString());
addTagHandler(validator, tagModel);
- appendAttributs(tag, model);
+ appendAttributes(tag, model);
}
}
return null;
}
-
- private void appendAttributs(Element tag, BeanModelBase model) {
+ private void appendAttributes(Element tag, BeanModelBase model) {
for (PropertyBase entry : model.getAttributes()) {
if (!entry.isHidden() && !entry.isReadOnly()) {
createAttributeElement(tag, entry.getName(), entry);
@@ -193,60 +201,57 @@
}
/**
- * <attribute>
- * <description></description>
- * <name>formatPatterns</name>
- * <required>true</required>
- * <type>String</type>
- * </attribute>
- *
+ * <attribute> <description></description> <name>formatPatterns</name> <required>true</required> <type>String</type>
+ * </attribute>
+ *
* @param tag
* @param name
* @param attribute
- *
+ *
* @return
* */
private Element createAttributeElement(Element tag, String name, PropertyBase attribute) {
Element attr = tag.addElement("attribute");
- if (attribute.getDescription() != null) {
- attr.addElement("description").addText(attribute.getDescription());
+ addDescription(attr, attribute);
+ attr.addElement("name").addText(name);
+ attr.addElement("type").addText(attribute.getType().getName());
+ if (attribute.isRequired()) {
+ attr.addElement("required").addText("true");
}
- attr.addElement("name").addText(name);
- attr.addElement("type").addText(attribute.getType().toString());
return attr;
}
private Element createTag(String tagName) {
Element tag = faceletTaglib.addElement("tag");
tag.addElement("tag-name").addText(tagName);
- empty=false;
+ empty = false;
return tag;
}
@Override
- public Boolean visitBehavior(BehaviorModel model,ComponentLibrary componentLibrary) {
+ public Boolean visitBehavior(BehaviorModel model, ComponentLibrary componentLibrary) {
for (TagModel tagModel : model.getTags()) {
- if (TagType.Facelets.equals(tagModel.getType())) {
+ if (isFaceletsTag(tagModel)) {
Element tag = createTag(tagModel.getName());
+ addDescription(tag, model);
Element behavior = tag.addElement("behavior");
behavior.addElement("behavior-id").addText(model.getId().toString());
addTagHandler(behavior, tagModel);
- appendAttributs(tag, model);
+ appendAttributes(tag, model);
}
}
return null;
}
-
@Override
- public Boolean visitFunction(FunctionModel model,ComponentLibrary componentLibrary) {
- if(TagType.Facelets.equals(model.getType())||TagType.All.equals(model.getType())){
+ public Boolean visitFunction(FunctionModel model, ComponentLibrary componentLibrary) {
+ if (isFaceletsTag(model.getType())) {
Element functionElement = faceletTaglib.addElement("function");
addDescription(functionElement, model);
functionElement.addElement("function-name").addText(model.getName());
- functionElement.addElement("function-class").addText(model.getFunctionClass().toString());
+ functionElement.addElement("function-class").addText(model.getFunctionClass().getName());
functionElement.addElement("function-signature").addText(model.getSignature());
- empty=false;
+ empty = false;
}
return null;
}
@@ -254,35 +259,48 @@
@Override
public Boolean visitEvent(EventModel model, ComponentLibrary param) {
for (TagModel tagModel : model.getTags()) {
- if (TagType.Facelets.equals(tagModel.getType())) {
+ if (isFaceletsTag(tagModel)) {
Element tag = createTag(tagModel.getName());
addTagHandler(tag, tagModel);
}
}
return null;
}
+
+ private boolean isFaceletsTag(TagType type) {
+
+ return TagType.Facelets.equals(type) || TagType.All.equals(type);
+ }
+
+ private boolean isFaceletsTag(TagModel tagModel) {
+ return isFaceletsTag(tagModel.getType());
+ }
+
/**
- * <p class="changed_added_4_0">Add common description elements.</p>
+ * <p class="changed_added_4_0">
+ * Add common description elements.
+ * </p>
+ *
* @param parant
* @param model
*/
- private void addDescription(Element parent, DescriptionGroup model){
- if(!Strings.isEmpty(model.getDescription())){
+ private void addDescription(Element parent, DescriptionGroup model) {
+ if (!Strings.isEmpty(model.getDescription())) {
parent.addElement("description").addText(model.getDescription());
}
- if(!Strings.isEmpty(model.getDisplayname())){
+ if (!Strings.isEmpty(model.getDisplayname())) {
parent.addElement("display-name").addText(model.getDisplayname());
}
- if(null != model.getIcon()){
+ if (null != model.getIcon()) {
Element iconElement = parent.addElement("icon");
- if(!Strings.isEmpty(model.getIcon().getSmallIcon())){
+ if (!Strings.isEmpty(model.getIcon().getSmallIcon())) {
iconElement.addElement("small-icon").addText(model.getIcon().getSmallIcon());
}
- if(!Strings.isEmpty(model.getIcon().getLargeIcon())){
+ if (!Strings.isEmpty(model.getIcon().getLargeIcon())) {
iconElement.addElement("large-icon").addText(model.getIcon().getLargeIcon());
}
-
+
}
}
-
+
}
14 years, 5 months
JBoss Rich Faces SVN: r18205 - root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-22 17:32:08 -0400 (Thu, 22 Jul 2010)
New Revision: 18205
Modified:
root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagLibrary.java
Log:
https://jira.jboss.org/browse/RF-8959
Modified: root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagLibrary.java
===================================================================
--- root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagLibrary.java 2010-07-22 21:31:25 UTC (rev 18204)
+++ root/cdk/trunk/plugins/annotations/src/main/java/org/richfaces/cdk/annotations/TagLibrary.java 2010-07-22 21:32:08 UTC (rev 18205)
@@ -55,7 +55,7 @@
* <p class="changed_added_4_0">Default preffix for package names and JSF ids in the library</p>
* @return
*/
- public String preffix() default "";
+ public String prefix() default "";
/**
* <p class="changed_added_4_0">Implementation version of the generated taglib.</p>
14 years, 5 months