JBoss Rich Faces SVN: r18174 - in root/core/trunk: api/src/main/java/org/ajax4jsf/javascript and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-21 09:01:03 -0400 (Wed, 21 Jul 2010)
New Revision: 18174
Modified:
root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
root/core/trunk/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java
root/core/trunk/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
Log:
https://jira.jboss.org/browse/RF-8946
Modified: root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
===================================================================
--- root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2010-07-21 12:27:44 UTC (rev 18173)
+++ root/core/trunk/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2010-07-21 13:01:03 UTC (rev 18174)
@@ -27,7 +27,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -44,7 +43,6 @@
* Key for keep request state information in request-scope attributes.
*/
public static final String AJAX_CONTEXT_KEY = "ajaxContext";
- public static final String RESPONSE_DATA_KEY = "_ajax:data";
static final String SERVICE_RESOURCE = "META-INF/services/" + AjaxContext.class.getName();
private static final String DEFAULT_CONTEXT_CLASS = "org.ajax4jsf.context.AjaxContextImpl";
private static Map<ClassLoader, Class<? extends AjaxContext>> ajaxContextClasses =
@@ -113,7 +111,7 @@
public abstract void release();
- public abstract Map<String, Object> getResponseDataMap();
+ public abstract Map<String, Object> getResponseComponentDataMap();
public abstract void setAjaxRequest(boolean b);
Modified: root/core/trunk/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java
===================================================================
--- root/core/trunk/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java 2010-07-21 12:27:44 UTC (rev 18173)
+++ root/core/trunk/api/src/main/java/org/ajax4jsf/javascript/ScriptUtils.java 2010-07-21 13:01:03 UTC (rev 18174)
@@ -243,9 +243,9 @@
}
public static void writeEncodedString(Writer w, Object obj) throws IOException {
- w.write("'");
+ w.write("\"");
writeEncoded(w, obj);
- w.write("'");
+ w.write("\"");
}
public static void addEncodedString(StringBuilder buff, Object obj) {
Modified: root/core/trunk/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java
===================================================================
--- root/core/trunk/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java 2010-07-21 12:27:44 UTC (rev 18173)
+++ root/core/trunk/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java 2010-07-21 13:01:03 UTC (rev 18174)
@@ -125,7 +125,7 @@
public void testStringToScript() {
Object obj = "foo";
- assertEquals("'foo'", ScriptUtils.toScript(obj));
+ assertEquals("\"foo\"", ScriptUtils.toScript(obj));
}
/**
@@ -174,13 +174,13 @@
{"one", "two"}, {"three", "four"}
};
- assertEquals("[['one','two'] ,['three','four'] ] ", ScriptUtils.toScript(obj));
+ assertEquals("[[\"one\",\"two\"] ,[\"three\",\"four\"] ] ", ScriptUtils.toScript(obj));
Map<String, Object> map = new TreeMap<String, Object>();
map.put("a", obj);
map.put("b", "c");
- assertEquals("{'a':[['one','two'] ,['three','four'] ] ,'b':'c'} ", ScriptUtils.toScript(map));
+ assertEquals("{\"a\":[[\"one\",\"two\"] ,[\"three\",\"four\"] ] ,\"b\":\"c\"} ", ScriptUtils.toScript(map));
}
/**
@@ -217,7 +217,7 @@
public void testObjectArrayToScript() {
Bean[] obj = {new Bean(1, true, "foo"), new Bean(2, false, "bar")};
- assertEquals("[{'bool':true,'foo':'foo',\'integer\':1} ,{'bool':false,'foo':'bar','integer':2} ] ",
+ assertEquals("[{\"bool\":true,\"foo\":\"foo\",\"integer\":1} ,{\"bool\":false,\"foo\":\"bar\",\"integer\":2} ] ",
ScriptUtils.toScript(obj));
}
@@ -228,7 +228,7 @@
Bean[] array = {new Bean(1, true, "foo"), new Bean(2, false, "bar")};
List<Bean> obj = Arrays.asList(array);
- assertEquals("[{'bool':true,'foo':'foo',\'integer\':1} ,{'bool':false,'foo':'bar','integer':2} ] ",
+ assertEquals("[{\"bool\":true,\"foo\":\"foo\",\"integer\":1} ,{\"bool\":false,\"foo\":\"bar\",\"integer\":2} ] ",
ScriptUtils.toScript(obj));
}
@@ -241,7 +241,7 @@
obj.put("a", "foo");
obj.put("b", "bar");
obj.put("c", "baz");
- assertEquals("{'a':'foo','b':'bar','c':'baz'} ", ScriptUtils.toScript(obj));
+ assertEquals("{\"a\":\"foo\",\"b\":\"bar\",\"c\":\"baz\"} ", ScriptUtils.toScript(obj));
}
/**
@@ -251,7 +251,7 @@
StringBuilder buff = new StringBuilder();
ScriptUtils.addEncodedString(buff, "foo");
- assertEquals("'foo'", buff.toString());
+ assertEquals("\"foo\"", buff.toString());
}
/**
@@ -282,7 +282,7 @@
* Test method for {@link ScriptUtils#toScript(Object)}
*/
public void testEnum() throws Exception {
- assertEquals("'TestEnum: B'", ScriptUtils.toScript(TestEnum.B));
+ assertEquals("\"TestEnum: B\"", ScriptUtils.toScript(TestEnum.B));
}
private void assertCaptureEquals(Capture<? extends Object> capture, String expected) {
@@ -329,7 +329,7 @@
environment.replay();
ScriptUtils.writeToStream(mockWriter, Collections.singletonMap("delay", Integer.valueOf(1500)));
environment.verify();
- assertCaptureEquals(capture, "{'delay':1500}");
+ assertCaptureEquals(capture, "{\"delay\":1500}");
environment.release();
}
@@ -401,7 +401,7 @@
ReferenceHolderBean parent = new ReferenceHolderBean("parent");
ReferencedBean child = new ReferencedBean("child", parent);
- assertEquals(dehydrate("{'name': 'child', 'parent': {'name': 'parent', 'reference': null}}"),
+ assertEquals(dehydrate("{\"name\": \"child\", \"parent\": {\"name\": \"parent\", \"reference\": null}}"),
dehydrate(ScriptUtils.toScript(child)));
}
@@ -411,7 +411,7 @@
parent.setReference(child);
- assertEquals(dehydrate("{'name': 'parent', 'reference': {'name': 'child', 'parent': null}}"),
+ assertEquals(dehydrate("{\"name\": \"parent\", \"reference\": {\"name\": \"child\", \"parent\": null}}"),
dehydrate(ScriptUtils.toScript(parent)));
}
@@ -421,7 +421,7 @@
parent.setReference(new Object[] {child});
- assertEquals(dehydrate("{'name': 'parent', 'reference': [{'name': 'child', 'parent': null}]}"),
+ assertEquals(dehydrate("{\"name\": \"parent\", \"reference\": [{\"name\": \"child\", \"parent\": null}]}"),
dehydrate(ScriptUtils.toScript(parent)));
}
@@ -433,7 +433,7 @@
set.add(child);
parent.setReference(set);
- assertEquals(dehydrate("{'name': 'parent', 'reference': [{'name': 'child', 'parent': null}]}"),
+ assertEquals(dehydrate("{\"name\": \"parent\", \"reference\": [{\"name\": \"child\", \"parent\": null}]}"),
dehydrate(ScriptUtils.toScript(parent)));
}
@@ -445,7 +445,7 @@
map.put("key", child);
parent.setReference(map);
- assertEquals(dehydrate("{'name': 'parent', 'reference': {'key': {'name': 'child', 'parent': null}}}"),
+ assertEquals(dehydrate("{\"name\": \"parent\", \"reference\": {\"key\": {\"name\": \"child\", \"parent\": null}}}"),
dehydrate(ScriptUtils.toScript(parent)));
}
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-07-21 12:27:44 UTC (rev 18173)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-07-21 13:01:03 UTC (rev 18174)
@@ -21,14 +21,17 @@
package org.ajax4jsf.context;
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.application.AjaxViewHandler;
-import org.ajax4jsf.renderkit.AjaxContainerRenderer;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
@@ -44,18 +47,16 @@
import javax.faces.render.RenderKitFactory;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.application.AjaxViewHandler;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
+
/**
* This class incapsulated
*
@@ -76,9 +77,10 @@
String submittedRegionClientId = null;
ViewIdHolder viewIdHolder = null;
Integer viewSequence = new Integer(1);
- Map<String, Object> responseDataMap = new HashMap<String, Object>();
+ Map<String, Object> responseComponentDataMap = new HashMap<String, Object>();
Map<String, Object> commonAjaxParameters = new HashMap<String, Object>();
-
+ Object responseData = null;
+
public void release() {
ajaxAreasToRender = new LinkedHashSet<String>();
ajaxAreasToProcess = null;
@@ -88,8 +90,9 @@
viewSequence = new Integer(1);
submittedRegionClientId = null;
viewIdHolder = null;
- responseDataMap = new HashMap<String, Object>();
+ responseComponentDataMap = new HashMap<String, Object>();
commonAjaxParameters = new HashMap<String, Object>();
+ responseData = null;
}
/*
@@ -476,21 +479,21 @@
* @return the responseData
*/
public Object getResponseData() {
- return responseDataMap.get(RESPONSE_DATA_KEY);
+ return responseData;
}
/**
* @param responseData the responseData to set
*/
public void setResponseData(Object responseData) {
- this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
+ this.responseData = responseData;
}
/**
* @return the responseDataMap
*/
- public Map<String, Object> getResponseDataMap() {
- return responseDataMap;
+ public Map<String, Object> getResponseComponentDataMap() {
+ return responseComponentDataMap;
}
/**
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2010-07-21 12:27:44 UTC (rev 18173)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2010-07-21 13:01:03 UTC (rev 18174)
@@ -136,6 +136,7 @@
private static final String BEFOREDOMUPDATE_ELEMENT_NAME = "beforedomupdate";
private static final String COMPLETE_ELEMENT_NAME = "complete";
private static final String DATA_ELEMENT_NAME = "data";
+ private static final String COMPONENT_DATA_ELEMENT_NAME = "componentData";
private static final RendererUtils RENDERER_UTILS = RendererUtils.getInstance();
private static final Class<?> OBJECT_ARRAY_CLASS = new Object[0].getClass();
@@ -974,7 +975,7 @@
}
}
- Map<String, Object> responseDataMap = ajaxContext.getResponseDataMap();
+ Map<String, Object> responseDataMap = ajaxContext.getResponseComponentDataMap();
// Get data serializer instance
AJAXDataSerializer serializer = ServiceTracker.getService(context, AJAXDataSerializer.class);
@@ -1168,18 +1169,24 @@
Object onbeforedomupdate = ajaxContext.getOnbeforedomupdate();
if (onbeforedomupdate != null) {
- startExtensionElementIfNecessary(writer, attributes, writingState);
- writer.startElement(BEFOREDOMUPDATE_ELEMENT_NAME, component);
- writer.writeText(onbeforedomupdate, null);
- writer.endElement(BEFOREDOMUPDATE_ELEMENT_NAME);
+ String string = onbeforedomupdate.toString();
+ if (string.length() != 0) {
+ startExtensionElementIfNecessary(writer, attributes, writingState);
+ writer.startElement(BEFOREDOMUPDATE_ELEMENT_NAME, component);
+ writer.writeText(onbeforedomupdate, null);
+ writer.endElement(BEFOREDOMUPDATE_ELEMENT_NAME);
+ }
}
Object oncomplete = ajaxContext.getOncomplete();
if (oncomplete != null) {
- startExtensionElementIfNecessary(writer, attributes, writingState);
- writer.startElement(COMPLETE_ELEMENT_NAME, component);
- writer.writeText(oncomplete, null);
- writer.endElement(COMPLETE_ELEMENT_NAME);
+ String string = oncomplete.toString();
+ if (string.length() != 0) {
+ startExtensionElementIfNecessary(writer, attributes, writingState);
+ writer.startElement(COMPLETE_ELEMENT_NAME, component);
+ writer.writeText(oncomplete, null);
+ writer.endElement(COMPLETE_ELEMENT_NAME);
+ }
}
Object responseData = ajaxContext.getResponseData();
@@ -1187,13 +1194,23 @@
startExtensionElementIfNecessary(writer, attributes, writingState);
writer.startElement(DATA_ELEMENT_NAME, component);
- //TODO - encode response data map
AJAXDataSerializer serializer = ServiceTracker.getService(facesContext, AJAXDataSerializer.class);
writer.writeText(serializer.asString(responseData), null);
writer.endElement(DATA_ELEMENT_NAME);
}
+ Map<String, Object> responseComponentDataMap = ajaxContext.getResponseComponentDataMap();
+ if (responseComponentDataMap != null && !responseComponentDataMap.isEmpty()) {
+ startExtensionElementIfNecessary(writer, attributes, writingState);
+ writer.startElement(COMPONENT_DATA_ELEMENT_NAME, component);
+
+ AJAXDataSerializer serializer = ServiceTracker.getService(facesContext, AJAXDataSerializer.class);
+ writer.writeText(serializer.asString(responseComponentDataMap), null);
+
+ writer.endElement(COMPONENT_DATA_ELEMENT_NAME);
+ }
+
endExtensionElementIfNecessary(writer, writingState);
}
Modified: root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
--- root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2010-07-21 12:27:44 UTC (rev 18173)
+++ root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2010-07-21 13:01:03 UTC (rev 18174)
@@ -432,6 +432,30 @@
error: ['error', 'complete']
};
+ var getExtensionResponseElement = function(responseXML) {
+ return jQuery("partial-response > extension#org\\.richfaces\\.extension", responseXML);
+ };
+
+ var JSON_STRING_START = /^\s*(\[|\{)/;
+
+ var getJSONData = function(extensionElement, elementName) {
+ var dataString = jQuery.trim(extensionElement.children(elementName).text());
+ extensionElement.end();
+ try {
+ if (dataString) {
+ if (JSON_STRING_START.test(dataString)) {
+ return jQuery.parseJSON(dataString);
+ } else {
+ var parsedData = jQuery.parseJSON("{\"root\": " + dataString + "}");
+ return parsedData.root;
+ }
+ }
+ } catch (e) {
+ richfaces.log.warn("Error evaluating JSON data from element <" + elementName + ">: " + e.message);
+ }
+ return null;
+ };
+
richfaces.createJSFEventsAdapter = function(handlers) {
//hash of handlers
//supported are:
@@ -461,6 +485,15 @@
event.type = eventType;
if (type != 'error') {
delete event.status;
+
+ if (event.responseXML) {
+ var xml = getExtensionResponseElement(event.responseXML);
+ var data = getJSONData(xml, "data");
+ var componentData = getJSONData(xml, "componentData");
+
+ event.data = data;
+ event.componentData = componentData || {};
+ }
}
handler.call(source, event);
@@ -520,7 +553,7 @@
var createEventHandler = function(handlerCode) {
if (handlerCode) {
- return new Function("event", "data", handlerCode);
+ return new Function("event", handlerCode);
}
return null;
@@ -529,29 +562,17 @@
//TODO take events just from .java code using EL-expression
var AJAX_EVENTS = (function() {
var serverEventHandler = function(clientHandler, event) {
- var xml = jQuery("partial-response > extension#org\\.richfaces\\.extension", event.responseXML);
+ var xml = getExtensionResponseElement(event.responseXML);
var serverHandler = createEventHandler(xml.children(event.type).text());
xml.end();
- var dataString = xml.children("data").text();
- xml.end();
-
- var data = null;
- if (dataString) {
- try {
- data = window["eval"]("(" + dataString + ")");
- } catch (e) {
- richfaces.log.warn("Error evaluating custom response data: " + e.message);
- }
- }
-
if (clientHandler) {
- clientHandler.call(window, event, data);
+ clientHandler.call(window, event);
}
if (serverHandler) {
- serverHandler.call(window, event, data);
+ serverHandler.call(window, event);
}
};
14 years, 5 months
JBoss Rich Faces SVN: r18173 - root/core/trunk/impl/src/main/resources/META-INF/resources.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-07-21 08:27:44 -0400 (Wed, 21 Jul 2010)
New Revision: 18173
Modified:
root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
Log:
detach method was added
Modified: root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
===================================================================
--- root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-07-21 12:22:40 UTC (rev 18172)
+++ root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-07-21 12:27:44 UTC (rev 18173)
@@ -209,6 +209,20 @@
}
return element;
},
+
+ /**
+ * Detach component object from DOM element by component id, DOM element or jQuery object
+ *
+ * @function
+ * @name RichFaces.BaseComponent#detach
+ * @param {string|DOMElement|jQuery} source - component id, DOM element or DOM elements wrapped by jQuery
+ *
+ * */
+ detach: function(source) {
+ source = source || this.id;
+ var element = richfaces.getDomElement(source);
+ element && element.richfaces && (element.richfaces.component=null);
+ }
/**
* Destroy method. Will be called before remove component from the page
@@ -218,6 +232,7 @@
*
* */
destroy: function() {
+ detach();
}
};
})(params));
14 years, 5 months
JBoss Rich Faces SVN: r18172 - root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-07-21 08:22:40 -0400 (Wed, 21 Jul 2010)
New Revision: 18172
Modified:
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
Log:
https://jira.jboss.org/browse/RF-8875
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-07-21 12:15:26 UTC (rev 18171)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-07-21 12:22:40 UTC (rev 18172)
@@ -186,115 +186,116 @@
rf.ajax(this.componentId, event, {parameters: params, error: ajaxError, complete:ajaxSuccess});
};
+ /*
+ * public API functions definition
+ */
+
+ var selectItem = function(index, isOffset, noAutoFill) {
+ if (this.items.length==0) return;
+
+ if (this.index!=-1) {
+ this.items.eq(this.index).removeClass(this.options.selectedItemClass);
+ }
+
+ if (index==undefined) {
+ this.index = -1;
+ return;
+ }
+
+ if (isOffset) {
+ this.index += index;
+ if ( this.index<0 ) {
+ this.index = this.items.length - 1;
+ } else if (this.index >= this.items.length) {
+ this.index = 0;
+ }
+ } else {
+ if (index<0) {
+ index = 0;
+ } else if (index>=this.items.length) {
+ index = this.items.length - 1;
+ }
+ this.index = index;
+ }
+ var item = this.items.eq(this.index);
+ item.addClass(this.options.selectedItemClass);
+ scrollToSelectedItem.call(this);
+ !noAutoFill && autoFill.call(this, this.inputValue, this.getSelectedItemValue());
+ };
+
+ var changeValue = function (event, value) {
+ this.selectItem();
+
+ if (typeof value == "undefined") {
+ // called from show method, not actually value changed
+ if (this.items.length==0 && this.inputValue.length>=this.options.minChars && this.isFirstAjax) {
+ this.options.ajaxMode && callAjax.call(this, event);
+ }
+ return;
+ }
+
+ // TODO: ajax call here if needed
+ if (( value.toLowerCase().indexOf(this.cache.key.toLowerCase())!=0 || this.inputValue.length==0) &&
+ value.length>=this.options.minChars) {
+ this.inputValue = value;
+ this.options.ajaxMode && callAjax.call(this, event);
+ return;
+ }
+
+ var newItems = this.cache.getItems(value);
+ this.items = $(newItems);
+ //TODO: works only with simple markup, not with <tr>
+ $(rf.getDomElement(this.componentId+ID.ITEMS)).empty().append(newItems);
+ this.index = -1;
+ this.inputValue = value;
+ if (this.options.selectFirst) {
+ this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
+ }
+ };
+
+ var getSelectedItemValue = function () {
+ if ( this.index>=0) {
+ var element = this.items.eq(this.index);
+ return element.data(DATA_TAG) || getData(element)[0];
+ }
+ return undefined;
+ };
+ /*
+ * Prototype definition
+ */
$.extend(rf.ui.AutoComplete.prototype, (function () {
return {
+ /*
+ * public API functions
+ */
name:"AutoComplete",
- destroy: function () {
- //TODO: add all unbind
- this.items = null;
- this.cache = null;
- rf.Event.unbind(rf.getDomElement(this.componentId+ID.ITEMS).parentNode, this.namespace);
- $super.destroy.call(this);
- },
- getNamespace: function () {
- return this.namespace;
- },
-
- selectItem: function(index, isOffset, noAutoFill) {
- if (this.items.length==0) return;
-
- if (this.index!=-1) {
- this.items.eq(this.index).removeClass(this.options.selectedItemClass);
- }
-
- if (index==undefined) {
- this.index = -1;
- return;
- }
-
- if (isOffset) {
- this.index += index;
- if ( this.index<0 ) {
- this.index = this.items.length - 1;
- } else if (this.index >= this.items.length) {
- this.index = 0;
- }
- } else {
- if (index<0) {
- index = 0;
- } else if (index>=this.items.length) {
- index = this.items.length - 1;
- }
- this.index = index;
- }
- var item = this.items.eq(this.index);
- item.addClass(this.options.selectedItemClass);
-
- scrollToSelectedItem.call(this);
- !noAutoFill && autoFill.call(this, this.inputValue, this.getSelectedItemValue());
- },
-
- selectPrevItem: function () {
+ selectItem: selectItem,
+ changeValue: changeValue,
+ getSelectedItemValue: getSelectedItemValue,
+ /*
+ * Protected methods
+ */
+ __onKeyUp: function () {
this.selectItem(-1, true);
},
- selectNextItem: function () {
+ __onKeyDown: function () {
this.selectItem(1, true);
},
- selectPageUp: function () {
+ __onPageUp: function () {
},
- selectPageDown: function () {
+ __onPageDown: function () {
},
- onBeforeShow: function (event) {
+ __onBeforeShow: function (event) {
},
-
- onEnter: function (event) {
+ __onEnter: function (event) {
this.changeValue(event, this.getSelectedItemValue());
rf.getDomElement(this.fieldId).blur();
rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
rf.getDomElement(this.fieldId).focus();
},
-
- changeValue: function (event, value) {
- this.selectItem();
-
- if (typeof value == "undefined") {
- // called from show method, not actually value changed
- if (this.items.length==0 && this.inputValue.length>=this.options.minChars && this.isFirstAjax) {
- this.options.ajaxMode && callAjax.call(this, event);
- }
- return;
- }
-
- // TODO: ajax call here if needed
- if (( value.toLowerCase().indexOf(this.cache.key.toLowerCase())!=0 || this.inputValue.length==0) &&
- value.length>=this.options.minChars) {
- this.inputValue = value;
- this.options.ajaxMode && callAjax.call(this, event);
- return;
- }
-
- var newItems = this.cache.getItems(value);
- this.items = $(newItems);
- //TODO: works only with simple markup, not with <tr>
- $(rf.getDomElement(this.componentId+ID.ITEMS)).empty().append(newItems);
- this.index = -1;
- this.inputValue = value;
- if (this.options.selectFirst) {
- this.selectItem(0, false, event.which == rf.KEYS.BACKSPACE);
- }
- },
-
- getSelectedItemValue: function () {
- if ( this.index>=0) {
- var element = this.items.eq(this.index);
- return element.data(DATA_TAG) || getData(element)[0];
- }
- return undefined;
- },
-
- onShow: function (event) {
+ __onShow: function (event) {
if (this.items && this.items.length>0) {
//??TODO it's nessesary only if not changed value
if (this.options.selectFirst) {
@@ -302,9 +303,18 @@
}
}
},
-
- onHide: function () {
+ __onHide: function () {
this.selectItem();
+ },
+ /*
+ * Destructor
+ */
+ destroy: function () {
+ //TODO: add all unbind
+ this.items = null;
+ this.cache = null;
+ rf.Event.unbind(rf.getDomElement(this.componentId+ID.ITEMS).parentNode, this.namespace);
+ $super.destroy.call(this);
}
};
})());
Modified: root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
===================================================================
--- root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-07-21 12:15:26 UTC (rev 18171)
+++ root/ui-sandbox/inputs/trunk/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-07-21 12:22:40 UTC (rev 18172)
@@ -149,13 +149,13 @@
case rf.KEYS.UP:
event.preventDefault();
if (this.isVisible) {
- this.selectPrevItem();
+ this.__onKeyUp(event);
}
break;
case rf.KEYS.DOWN:
event.preventDefault();
if (this.isVisible) {
- this.selectNextItem();
+ this.__onKeyDown(event);
} else {
onShow.call(this, event);
}
@@ -163,20 +163,20 @@
case rf.KEYS.PAGEUP:
event.preventDefault();
if (this.isVisible) {
- this.selectPageUp();
+ this.__onPageUp(event);
}
break;
case rf.KEYS.PAGEDOWN:
event.preventDefault();
if (this.isVisible) {
- this.selectPageDown();
+ this.__onPageDown(event);
}
break;
case rf.KEYS.TAB:
case rf.KEYS.RETURN:
//TODO draft code, merge with code from combobox.js
event.preventDefault();
- this.onEnter(event);
+ this.__onEnter(event);
/*if( selectCurrentItem() ) {
event.preventDefault();
//TODO: bind form submit event handler to cancel form submit under the opera
@@ -198,72 +198,63 @@
break;
}
}
-
+
+ /*
+ * public API functions definition
+ */
+ var show = function (event) {
+ if (!this.isVisible) {
+ if (this.__onBeforeShow(event)!=false) {
+ this.scrollElements = rf.Event.bindScrollEventHandlers(this.selectId, this.hide, this, this.namespace);
+ if (this.options.attachToBody) {
+ var element = rf.getDomElement(this.selectId);
+ this.parentElement = element.parentNode;
+ $(element).detach().appendTo("body");
+ }
+ $(rf.getDomElement(this.selectId)).setPosition({id: this.fieldId}, {type:"DROPDOWN", offset:[0,20]}).show();
+ this.isVisible = true;
+ this.__onShow(event);
+ }
+ }
+ };
+ var hide = function (event) {
+ if (this.isVisible) {
+ rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
+ this.scrollElements = null;
+ $(rf.getDomElement(this.selectId)).hide();
+ this.isVisible = false;
+ if (this.options.attachToBody && this.parentElement) {
+ $(rf.getDomElement(this.selectId)).detach().appendTo(this.parentElement);
+ this.parentElement = null;
+ }
+ this.__onHide(event);
+ }
+ };
+
+ /*
+ * Prototype definition
+ */
$.extend(rf.ui.AutoCompleteBase.prototype, (function () {
return {
+ /*
+ * public API functions
+ */
name:"AutoCompleteBase",
- show: function (event) {
- if (!this.isVisible) {
- if (this.onBeforeShow(event)!=false) {
- this.scrollElements = rf.Event.bindScrollEventHandlers(this.selectId, this.hide, this, this.namespace);
- if (this.options.attachToBody) {
- var element = rf.getDomElement(this.selectId);
- this.parentElement = element.parentNode;
- $(element).detach().appendTo("body");
- }
- $(rf.getDomElement(this.selectId)).setPosition({id: this.fieldId}, {type:"DROPDOWN", offset:[0,20]}).show();
- this.isVisible = true;
- if (this.onShow) {
- this.onShow(event);
- }
- }
- }
- },
- hide: function (event) {
- if (this.isVisible) {
- rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
- this.scrollElements = null;
- $(rf.getDomElement(this.selectId)).hide();
- this.isVisible = false;
- if (this.options.attachToBody && this.parentElement) {
- $(rf.getDomElement(this.selectId)).detach().appendTo(this.parentElement);
- this.parentElement = null;
- }
- if (this.onHide) {
- this.onHide(event);
- }
- }
- },
- destroy: function () {
- //TODO: add all unbind
- this.parentNode = null;
- if (this.scrollElements) {
- rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
- this.scrollElements = null;
- }
- rf.Event.unbindById(this.options.buttonId, this.namespace);
- rf.Event.unbindById(this.fieldId, this.namespace);
- rf.Event.unbindById(this.selectId, this.namespace);
- $super.destroy.call(this);
- },
+ show: show,
+ hide: hide,
getNamespace: function () {
return this.namespace;
},
-
- selectPrevItem: function () {
- },
- selectNextItem: function () {
- },
- selectPageUp: function () {
- },
- selectPageDown: function () {
- },
- onBeforeShow: function () {
- },
getInputValue: function () {
return this.fieldId ? rf.getDomElement(this.fieldId).value : undefined;
},
- updateInputValue: function (value) {
+ setInputValue: function (value) {
+ this.currentValue = this.__updateInputValue(value);
+ },
+ /*
+ * Protected methods
+ */
+ __updateInputValue: function (value) {
if (this.fieldId) {
rf.getDomElement(this.fieldId).value = value;
return value;
@@ -271,8 +262,36 @@
return "";
}
},
- setInputValue: function (value) {
- this.currentValue = this.updateInputValue(value);
+ /*
+ * Protected abstract methods
+ */
+ __onKeyUp: function () {
+ },
+ __onKeyDown: function () {
+ },
+ __onPageUp: function () {
+ },
+ __onPageDown: function () {
+ },
+ __onBeforeShow: function () {
+ },
+ __onShow: function () {
+ },
+ __onHide: function () {
+ },
+ /*
+ * Destructor
+ */
+ destroy: function () {
+ this.parentNode = null;
+ if (this.scrollElements) {
+ rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
+ this.scrollElements = null;
+ }
+ rf.Event.unbindById(this.options.buttonId, this.namespace);
+ rf.Event.unbindById(this.fieldId, this.namespace);
+ rf.Event.unbindById(this.selectId, this.namespace);
+ $super.destroy.call(this);
}
};
})());
14 years, 5 months
JBoss Rich Faces SVN: r18171 - in root/tests/metamer/trunk/ftest-source/src/main/java/org: jboss/test/selenium/locator/reference and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-21 08:15:26 -0400 (Wed, 21 Jul 2010)
New Revision: 18171
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java
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/a4jActionListener/TestA4JActionListener.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/richExtendedDataTable/DataScroller.java
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
Log:
modified project to follow richfaces-checkstyle and formatting-rules
Modified: root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java
===================================================================
--- root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java 2010-07-21 12:14:26 UTC (rev 18170)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/SeleniumGetter.java 2010-07-21 12:15:26 UTC (rev 18171)
@@ -1,3 +1,24 @@
+/*
+ * 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.jboss.test.selenium;
import org.jboss.test.selenium.encapsulated.JavaScript;
@@ -7,6 +28,13 @@
import org.jboss.test.selenium.utils.PrimitiveUtils;
import org.jboss.test.selenium.waiting.conversion.Convertor;
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ *
+ * @param <P>
+ * type of parameter
+ */
public abstract class SeleniumGetter<P> {
protected AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
protected P parameter;
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-21 12:14:26 UTC (rev 18170)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java 2010-07-21 12:15:26 UTC (rev 18171)
@@ -26,21 +26,23 @@
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
+ *
+ * @param <T> type of referenced locator
*/
public class LocatorReference<T extends Locator> {
- private T reference;
+ private T reference;
- public LocatorReference(T reference) {
- super();
- this.reference = reference;
- }
+ public LocatorReference(T reference) {
+ super();
+ this.reference = reference;
+ }
- public T getLocator() {
- return reference;
- }
+ public T getLocator() {
+ return reference;
+ }
- public void setLocator(T locator) {
- this.reference = locator;
- }
+ public void setLocator(T locator) {
+ this.reference = locator;
+ }
}
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-21 12:14:26 UTC (rev 18170)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java 2010-07-21 12:15:26 UTC (rev 18171)
@@ -29,75 +29,75 @@
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
+ *
+ * @param <T> type of referenced locator
*/
-public class ReferencedLocator<T extends IterableLocator<T> & CompoundableLocator<T>>
- extends AbstractElementLocator implements IterableLocator<T>,
- CompoundableLocator<T> {
+public class ReferencedLocator<T extends IterableLocator<T> & CompoundableLocator<T>> extends AbstractElementLocator
+ implements IterableLocator<T>, CompoundableLocator<T> {
- private LocatorReference<T> reference;
- private String addition;
+ private LocatorReference<T> reference;
+ private String addition;
- public ReferencedLocator(LocatorReference<T> reference, String locator) {
- super("not-used");
- this.reference = reference;
- this.addition = locator;
- }
+ public ReferencedLocator(LocatorReference<T> reference, String locator) {
+ super("not-used");
+ this.reference = reference;
+ this.addition = locator;
+ }
- public static <N extends AbstractElementLocator & IterableLocator<N> & CompoundableLocator<N>> ReferencedLocator<N> ref(
- LocatorReference<N> reference, String locator) {
- return new ReferencedLocator<N>(reference, locator);
- }
+ public static <N extends IterableLocator<N> & CompoundableLocator<N>> ReferencedLocator<N> ref(
+ LocatorReference<N> reference, String locator) {
+ return new ReferencedLocator<N>(reference, locator);
+ }
- public T getReferenced() {
- T referencedLocator = reference.getLocator();
+ public T getReferenced() {
+ T referencedLocator = reference.getLocator();
- @SuppressWarnings("unchecked")
- Class<T> tClass = (Class<T>) referencedLocator.getClass();
+ @SuppressWarnings("unchecked")
+ Class<T> tClass = (Class<T>) referencedLocator.getClass();
- try {
- T newInstance = tClass.getConstructor(String.class).newInstance(
- addition);
+ try {
+ T newInstance = tClass.getConstructor(String.class).newInstance(addition);
- return referencedLocator.getDescendant(newInstance);
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
+ return referencedLocator.getDescendant(newInstance);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
- @Override
- public String getRawLocator() {
- return getReferenced().getRawLocator();
- }
+ @Override
+ public String getRawLocator() {
+ return getReferenced().getRawLocator();
+ }
- public LocationStrategy getLocationStrategy() {
- return reference.getLocator().getLocationStrategy();
- }
+ public LocationStrategy getLocationStrategy() {
+ return reference.getLocator().getLocationStrategy();
+ }
- public T getChild(T elementLocator) {
- return getReferenced().getChild(elementLocator);
- }
+ public T getChild(T elementLocator) {
+ return getReferenced().getChild(elementLocator);
+ }
- public T getDescendant(T elementLocator) {
- return getReferenced().getDescendant(elementLocator);
- }
+ public T getDescendant(T elementLocator) {
+ return getReferenced().getDescendant(elementLocator);
+ }
- public T getNthChildElement(int index) {
- return getReferenced().getNthChildElement(index);
- }
+ public T getNthChildElement(int index) {
+ return getReferenced().getNthChildElement(index);
+ }
- public T getNthOccurence(int index) {
- return getReferenced().getNthOccurence(index);
- }
+ public T getNthOccurence(int index) {
+ return getReferenced().getNthOccurence(index);
+ }
- public Iterable<T> getAllChildren() {
- return getReferenced().getAllChildren();
- }
+ public Iterable<T> getAllChildren() {
+ return getReferenced().getAllChildren();
+ }
- public Iterable<T> getChildren(T elementLocator) {
- return getReferenced().getChildren(elementLocator);
- }
+ public Iterable<T> getChildren(T elementLocator) {
+ return getReferenced().getChildren(elementLocator);
+ }
- public Iterable<T> getDescendants(T elementLocator) {
- return getReferenced().getDescendants(elementLocator);
- }
+ public Iterable<T> getDescendants(T elementLocator) {
+ return getReferenced().getDescendants(elementLocator);
+ }
}
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-21 12:14:26 UTC (rev 18170)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java 2010-07-21 12:15:26 UTC (rev 18171)
@@ -21,16 +21,13 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.a4jActionListener;
-import org.jboss.test.selenium.encapsulated.JavaScript;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
import java.net.URL;
import org.jboss.test.selenium.locator.ElementLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
-import org.jboss.test.selenium.waiting.ajax.JavaScriptCondition;
import org.jboss.test.selenium.waiting.selenium.SeleniumCondition;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.AfterMethod;
@@ -42,7 +39,6 @@
* @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
* @version $Revision$
*/
-@SuppressWarnings("unused")
public class TestA4JActionListener extends AbstractMetamerTest {
private ElementLocator invokeButtonType = pjq("input[id$=invokeByTypeButton]");
@@ -66,7 +62,7 @@
public void testInvokeListenerByType(String templates) {
final String hashCodeRegExp = "@[0-9a-fA-F]{1,}$";
final String msg = "Implementation of ActionListener created and called: "
- + "org.richfaces.tests.metamer.bean.A4JActionListenerBean$ActionListenerImpl";
+ + "org.richfaces.tests.metamer.bean.A4JActionListenerBean$ActionListenerImpl";
selenium.click(invokeButtonType);
waitGui.until(elementPresent.locator(message));
@@ -82,12 +78,12 @@
selenium.click(invokeButtonType);
waitModel.failWith("New object of class ActionListenerImpl should be instantiated.").until(
- new SeleniumCondition() {
+ new SeleniumCondition() {
- public boolean isTrue() {
- return !output1.equals(selenium.getText(message));
- }
- });
+ public boolean isTrue() {
+ return !output1.equals(selenium.getText(message));
+ }
+ });
count = selenium.getCount(message);
assertEquals(count, 1, "Only one message should be displayed on the page.");
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-21 12:14:26 UTC (rev 18170)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-21 12:15:26 UTC (rev 18171)
@@ -72,7 +72,7 @@
* panel (block or inline)
*/
@SuppressWarnings("unused")
- @DataProvider(name = "templatesEventsLayouts")
+ @DataProvider(name = "templatesEventsLayouts")
private Object[][] getTemplatesEventsLayouts() {
final int layoutsCount = 2;
// list of templates, e.g. {{"plain"}, {"richDataTable1,redDiv"}}
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-21 12:14:26 UTC (rev 18170)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-21 12:15:26 UTC (rev 18171)
@@ -37,78 +37,78 @@
*/
public class DataScroller {
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
- ReferencedLocator<JQueryLocator> pageNumbers = ref(root, "> .rf-ds-dtl"),
- firstPageButton = ref(root, "> .rf-ds-l[id$=ds_f]"),
- lastPageButton = ref(root, "> .rf-ds-r:eq(1)"),
- lastVisiblePage = ref(root, "> .rf-ds-dtl:last"),
- currentPage = ref(root, "> .rf-ds-cur");
+ LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
+ ReferencedLocator<JQueryLocator> pageNumbers = ref(root, "> .rf-ds-dtl");
+ ReferencedLocator<JQueryLocator> firstPageButton = ref(root, "> .rf-ds-l[id$=ds_f]");
+ ReferencedLocator<JQueryLocator> lastPageButton = ref(root, "> .rf-ds-r:eq(1)");
+ ReferencedLocator<JQueryLocator> lastVisiblePage = ref(root, "> .rf-ds-dtl:last");
+ ReferencedLocator<JQueryLocator> currentPage = ref(root, "> .rf-ds-cur");
- public DataScroller(JQueryLocator root) {
- setRoot(root);
- }
+ public DataScroller(JQueryLocator root) {
+ setRoot(root);
+ }
- public JQueryLocator getRoot() {
- return root.getLocator();
- }
+ public JQueryLocator getRoot() {
+ return root.getLocator();
+ }
- public void setRoot(JQueryLocator root) {
- this.root.setLocator(root);
- }
+ public void setRoot(JQueryLocator root) {
+ this.root.setLocator(root);
+ }
- public void gotoFirstPage() {
- if (!isFirstPage()) {
- clickFirstPageButton();
- }
- }
+ public void gotoFirstPage() {
+ if (!isFirstPage()) {
+ clickFirstPageButton();
+ }
+ }
- public void gotoLastPage() {
- if (!isLastPage()) {
- clickLastPageButton();
- }
- }
+ public void gotoLastPage() {
+ if (!isLastPage()) {
+ clickLastPageButton();
+ }
+ }
- public void clickLastPageButton() {
- guardXhr(selenium).click(lastPageButton);
- }
+ public void clickLastPageButton() {
+ guardXhr(selenium).click(lastPageButton);
+ }
- public void clickFirstPageButton() {
- guardXhr(selenium).click(firstPageButton);
- }
+ public void clickFirstPageButton() {
+ guardXhr(selenium).click(firstPageButton);
+ }
- public int getCountOfVisiblePages() {
- return selenium.getCount(pageNumbers);
- }
+ public int getCountOfVisiblePages() {
+ return selenium.getCount(pageNumbers);
+ }
- public boolean hasPages() {
- return selenium.isElementPresent(lastVisiblePage);
- }
+ public boolean hasPages() {
+ return selenium.isElementPresent(lastVisiblePage);
+ }
- public Integer getLastVisiblePage() {
- if (!hasPages()) {
- return null;
- }
- return integer(selenium.getText(lastVisiblePage));
- }
+ public Integer getLastVisiblePage() {
+ if (!hasPages()) {
+ return null;
+ }
+ return integer(selenium.getText(lastVisiblePage));
+ }
- public int getCurrentPage() {
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(currentPage));
- }
+ public int getCurrentPage() {
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(currentPage));
+ }
- public boolean isFirstPage() {
- return getCurrentPage() == 1;
- }
+ public boolean isFirstPage() {
+ return getCurrentPage() == 1;
+ }
- public boolean isLastPage() {
- return getCurrentPage() == getLastVisiblePage();
- }
+ public boolean isLastPage() {
+ return getCurrentPage() == getLastVisiblePage();
+ }
- public static int integer(String string) {
- return Integer.valueOf(string);
- }
+ public static int integer(String string) {
+ return Integer.valueOf(string);
+ }
}
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-21 12:14:26 UTC (rev 18170)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-21 12:15:26 UTC (rev 18171)
@@ -35,21 +35,21 @@
*/
public class DataTable {
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
- ReferencedLocator<JQueryLocator> tableRows = ref(root,
- "> div.rf-edt-b table table tr");
+ LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
+
+ ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b table table tr");
- public DataTable(JQueryLocator tableRoot) {
- root.setLocator(tableRoot);
- }
+ public DataTable(JQueryLocator tableRoot) {
+ root.setLocator(tableRoot);
+ }
- public int getCountOfTableRows() {
- return selenium.getCount(tableRows);
- }
+ public int getCountOfTableRows() {
+ return selenium.getCount(tableRows);
+ }
- public String getTableText() {
- return selenium.getText(root.getLocator());
- }
+ public String getTableText() {
+ return selenium.getText(root.getLocator());
+ }
}
14 years, 5 months
JBoss Rich Faces SVN: r18170 - in root/tests/metamer/trunk: ftest-source and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-21 08:14:26 -0400 (Wed, 21 Jul 2010)
New Revision: 18170
Modified:
root/tests/metamer/trunk/ftest-source/pom.xml
root/tests/metamer/trunk/ftest/pom.xml
Log:
tied on new development version of richfaces-selenium (1.5.0-SNAPSHOT)
Modified: root/tests/metamer/trunk/ftest/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest/pom.xml 2010-07-21 12:14:03 UTC (rev 18169)
+++ root/tests/metamer/trunk/ftest/pom.xml 2010-07-21 12:14:26 UTC (rev 18170)
@@ -25,7 +25,7 @@
<parent>
<artifactId>functional-test-jboss-ci-template</artifactId>
<groupId>org.jboss.test.richfaces-selenium</groupId>
- <version>1.5.0.Final</version>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.richfaces.tests</groupId>
Modified: root/tests/metamer/trunk/ftest-source/pom.xml
===================================================================
--- root/tests/metamer/trunk/ftest-source/pom.xml 2010-07-21 12:14:03 UTC (rev 18169)
+++ root/tests/metamer/trunk/ftest-source/pom.xml 2010-07-21 12:14:26 UTC (rev 18170)
@@ -37,7 +37,7 @@
<dependency>
<artifactId>root</artifactId>
<groupId>org.jboss.test.richfaces-selenium</groupId>
- <version>1.5.0.Final</version>
+ <version>1.5.1-SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
14 years, 5 months
JBoss Rich Faces SVN: r18169 - root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-21 08:14:03 -0400 (Wed, 21 Jul 2010)
New Revision: 18169
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java
Log:
DataTable refactored to locator reference pattern
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-21 12:13:19 UTC (rev 18168)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataTable.java 2010-07-21 12:14:03 UTC (rev 18169)
@@ -24,8 +24,10 @@
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.reference.LocatorReference;
+import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -33,21 +35,21 @@
*/
public class DataTable {
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- JQueryLocator tableRoot;
- JQueryLocator tableRows = jq("div.rf-edt-b table table tr");
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- public DataTable(JQueryLocator tableRoot) {
- super();
- this.tableRoot = tableRoot;
- }
+ LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
+ ReferencedLocator<JQueryLocator> tableRows = ref(root,
+ "> div.rf-edt-b table table tr");
- public int getCountOfTableRows() {
- JQueryLocator locator = tableRoot.getDescendant(tableRows);
- return selenium.getCount(locator);
- }
+ public DataTable(JQueryLocator tableRoot) {
+ root.setLocator(tableRoot);
+ }
- public String getTableText() {
- return selenium.getText(tableRoot);
- }
+ public int getCountOfTableRows() {
+ return selenium.getCount(tableRows);
+ }
+
+ public String getTableText() {
+ return selenium.getText(root.getLocator());
+ }
}
14 years, 5 months
JBoss Rich Faces SVN: r18168 - in root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: a4jOutputPanel and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-21 08:13:19 -0400 (Wed, 21 Jul 2010)
New Revision: 18168
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/a4jOutputPanel/TestA4JOutputPanel.java
Log:
@SupressWarnings("unused") on DataProviders and removed method testFireEvent() which had moved to AbstractMetamerTest
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-21 12:12:33 UTC (rev 18167)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jCommandLink/TestA4JCommandLink.java 2010-07-21 12:13:19 UTC (rev 18168)
@@ -318,19 +318,4 @@
assertEquals(selenium.getText(link), value, "Value of the button did not change");
}
-
- private void testFireEvent(Event event) {
- ElementLocator eventInput = pjq("input[id$=on" + event.getEventName() + "Input]");
- final String value = "alert('" + event.getEventName() + "')";
-
- selenium.type(eventInput, value);
- selenium.fireEvent(eventInput, Event.BLUR);
- selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.fireEvent(link, event);
-
- assertEquals(selenium.getAlert(), event.getEventName(), event.getEventName()
- + " attribute did not change correctly");
- }
-
}
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-21 12:12:33 UTC (rev 18167)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2010-07-21 12:13:19 UTC (rev 18168)
@@ -71,7 +71,8 @@
* plain template) if nothing is defined, JavaScript events that are defined for output panel and layout of
* panel (block or inline)
*/
- @DataProvider(name = "templatesEventsLayouts")
+ @SuppressWarnings("unused")
+ @DataProvider(name = "templatesEventsLayouts")
private Object[][] getTemplatesEventsLayouts() {
final int layoutsCount = 2;
// list of templates, e.g. {{"plain"}, {"richDataTable1,redDiv"}}
14 years, 5 months
JBoss Rich Faces SVN: r18167 - in root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richExtendedDataTable and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-21 08:12:33 -0400 (Wed, 21 Jul 2010)
New Revision: 18167
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/richExtendedDataTable/TestScroller.java
Log:
removed unused imports
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-21 12:11:34 UTC (rev 18166)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jActionListener/TestA4JActionListener.java 2010-07-21 12:12:33 UTC (rev 18167)
@@ -42,6 +42,7 @@
* @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
* @version $Revision$
*/
+@SuppressWarnings("unused")
public class TestA4JActionListener extends AbstractMetamerTest {
private ElementLocator invokeButtonType = pjq("input[id$=invokeByTypeButton]");
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-21 12:11:34 UTC (rev 18166)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-07-21 12:12:33 UTC (rev 18167)
@@ -27,7 +27,6 @@
import java.net.URL;
-import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.ElementLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.Test;
14 years, 5 months
JBoss Rich Faces SVN: r18166 - root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-21 08:11:34 -0400 (Wed, 21 Jul 2010)
New Revision: 18166
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java
Log:
DataScroller refactored to use referenced locator pattern
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-21 12:10:49 UTC (rev 18165)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/DataScroller.java 2010-07-21 12:11:34 UTC (rev 18166)
@@ -25,90 +25,90 @@
import org.jboss.test.selenium.framework.AjaxSelenium;
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.reference.LocatorReference;
+import org.jboss.test.selenium.locator.reference.ReferencedLocator;
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
public class DataScroller {
-
- AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
- JQueryLocator scrollerRoot;
- JQueryLocator pageNumbers = jq(".rf-ds-dtl");
- JQueryLocator firstPageButton = jq(".rf-ds-l[id$=ds_f]");
- JQueryLocator lastPageButton = jq(".rf-ds-r:eq(1)");
- JQueryLocator lastVisiblePage = jq(".rf-ds-dtl:last");
- JQueryLocator currentPage = jq(".rf-ds-cur");
- public DataScroller(JQueryLocator scrollerRoot) {
- this.scrollerRoot = scrollerRoot;
- }
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- public JQueryLocator getRoot() {
- return scrollerRoot;
- }
-
- public void gotoFirstPage() {
- if (!isFirstPage()) {
- clickFirstPageButton();
- }
- }
+ LocatorReference<JQueryLocator> root = new LocatorReference<JQueryLocator>(null);
+ ReferencedLocator<JQueryLocator> pageNumbers = ref(root, "> .rf-ds-dtl"),
+ firstPageButton = ref(root, "> .rf-ds-l[id$=ds_f]"),
+ lastPageButton = ref(root, "> .rf-ds-r:eq(1)"),
+ lastVisiblePage = ref(root, "> .rf-ds-dtl:last"),
+ currentPage = ref(root, "> .rf-ds-cur");
- public void gotoLastPage() {
- if (!isLastPage()) {
- clickLastPageButton();
- }
- }
+ public DataScroller(JQueryLocator root) {
+ setRoot(root);
+ }
- public void clickLastPageButton() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastPageButton);
- guardXhr(selenium).click(locator);
- }
+ public JQueryLocator getRoot() {
+ return root.getLocator();
+ }
- public void clickFirstPageButton() {
- JQueryLocator locator = scrollerRoot.getDescendant(firstPageButton);
- guardXhr(selenium).click(locator);
- }
+ public void setRoot(JQueryLocator root) {
+ this.root.setLocator(root);
+ }
- public int getCountOfVisiblePages() {
- JQueryLocator locator = scrollerRoot.getDescendant(pageNumbers);
- return selenium.getCount(locator);
- }
+ public void gotoFirstPage() {
+ if (!isFirstPage()) {
+ clickFirstPageButton();
+ }
+ }
- public boolean hasPages() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastVisiblePage);
- return selenium.isElementPresent(locator);
- }
+ public void gotoLastPage() {
+ if (!isLastPage()) {
+ clickLastPageButton();
+ }
+ }
- public Integer getLastVisiblePage() {
- JQueryLocator locator = scrollerRoot.getDescendant(lastVisiblePage);
- if (!hasPages()) {
- return null;
- }
- return integer(selenium.getText(locator));
- }
+ public void clickLastPageButton() {
+ guardXhr(selenium).click(lastPageButton);
+ }
- public int getCurrentPage() {
- JQueryLocator locator = scrollerRoot.getDescendant(currentPage);
- if (!hasPages()) {
- return 1;
- }
- return integer(selenium.getText(locator));
- }
+ public void clickFirstPageButton() {
+ guardXhr(selenium).click(firstPageButton);
+ }
- public boolean isFirstPage() {
- return getCurrentPage() == 1;
- }
+ public int getCountOfVisiblePages() {
+ return selenium.getCount(pageNumbers);
+ }
- public boolean isLastPage() {
- return getCurrentPage() == getLastVisiblePage();
- }
+ public boolean hasPages() {
+ return selenium.isElementPresent(lastVisiblePage);
+ }
- public static int integer(String string) {
- return Integer.valueOf(string);
- }
+ public Integer getLastVisiblePage() {
+ if (!hasPages()) {
+ return null;
+ }
+ return integer(selenium.getText(lastVisiblePage));
+ }
+
+ public int getCurrentPage() {
+ if (!hasPages()) {
+ return 1;
+ }
+ return integer(selenium.getText(currentPage));
+ }
+
+ public boolean isFirstPage() {
+ return getCurrentPage() == 1;
+ }
+
+ public boolean isLastPage() {
+ return getCurrentPage() == getLastVisiblePage();
+ }
+
+ public static int integer(String string) {
+ return Integer.valueOf(string);
+ }
}
14 years, 5 months
JBoss Rich Faces SVN: r18165 - in root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium: locator and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-07-21 08:10:49 -0400 (Wed, 21 Jul 2010)
New Revision: 18165
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/
root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/
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
Log:
introduced locator references implementation (for incubation for richfaces-selenium)
Added: 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 (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/LocatorReference.java 2010-07-21 12:10:49 UTC (rev 18165)
@@ -0,0 +1,46 @@
+/*
+ * 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.jboss.test.selenium.locator.reference;
+
+import org.jboss.test.selenium.locator.Locator;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class LocatorReference<T extends Locator> {
+
+ private T reference;
+
+ public LocatorReference(T reference) {
+ super();
+ this.reference = reference;
+ }
+
+ public T getLocator() {
+ return reference;
+ }
+
+ public void setLocator(T locator) {
+ this.reference = locator;
+ }
+}
Added: 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 (rev 0)
+++ root/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java 2010-07-21 12:10:49 UTC (rev 18165)
@@ -0,0 +1,103 @@
+/*
+ * 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.jboss.test.selenium.locator.reference;
+
+import org.jboss.test.selenium.locator.AbstractElementLocator;
+import org.jboss.test.selenium.locator.CompoundableLocator;
+import org.jboss.test.selenium.locator.IterableLocator;
+import org.jboss.test.selenium.locator.type.LocationStrategy;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class ReferencedLocator<T extends IterableLocator<T> & CompoundableLocator<T>>
+ extends AbstractElementLocator implements IterableLocator<T>,
+ CompoundableLocator<T> {
+
+ private LocatorReference<T> reference;
+ private String addition;
+
+ public ReferencedLocator(LocatorReference<T> reference, String locator) {
+ super("not-used");
+ this.reference = reference;
+ this.addition = locator;
+ }
+
+ public static <N extends AbstractElementLocator & IterableLocator<N> & CompoundableLocator<N>> ReferencedLocator<N> ref(
+ LocatorReference<N> reference, String locator) {
+ return new ReferencedLocator<N>(reference, locator);
+ }
+
+ public T getReferenced() {
+ T referencedLocator = reference.getLocator();
+
+ @SuppressWarnings("unchecked")
+ Class<T> tClass = (Class<T>) referencedLocator.getClass();
+
+ try {
+ T newInstance = tClass.getConstructor(String.class).newInstance(
+ addition);
+
+ return referencedLocator.getDescendant(newInstance);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Override
+ public String getRawLocator() {
+ return getReferenced().getRawLocator();
+ }
+
+ public LocationStrategy getLocationStrategy() {
+ return reference.getLocator().getLocationStrategy();
+ }
+
+ public T getChild(T elementLocator) {
+ return getReferenced().getChild(elementLocator);
+ }
+
+ public T getDescendant(T elementLocator) {
+ return getReferenced().getDescendant(elementLocator);
+ }
+
+ public T getNthChildElement(int index) {
+ return getReferenced().getNthChildElement(index);
+ }
+
+ public T getNthOccurence(int index) {
+ return getReferenced().getNthOccurence(index);
+ }
+
+ public Iterable<T> getAllChildren() {
+ return getReferenced().getAllChildren();
+ }
+
+ public Iterable<T> getChildren(T elementLocator) {
+ return getReferenced().getChildren(elementLocator);
+ }
+
+ public Iterable<T> getDescendants(T elementLocator) {
+ return getReferenced().getDescendants(elementLocator);
+ }
+}
14 years, 5 months