JBoss Rich Faces SVN: r11543 - trunk/ui/jQuery/src/main/templates.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-12-04 07:55:58 -0500 (Thu, 04 Dec 2008)
New Revision: 11543
Modified:
trunk/ui/jQuery/src/main/templates/jQuery.jspx
Log:
https://jira.jboss.org/jira/browse/RF-4810
Modified: trunk/ui/jQuery/src/main/templates/jQuery.jspx
===================================================================
--- trunk/ui/jQuery/src/main/templates/jQuery.jspx 2008-12-04 12:52:37 UTC (rev 11542)
+++ trunk/ui/jQuery/src/main/templates/jQuery.jspx 2008-12-04 12:55:58 UTC (rev 11543)
@@ -52,7 +52,7 @@
{
var selector = "#{selector}";
try {
- selector = eval("selector}");
+ selector = eval("#{selector}");
} catch (e) {}
jQuery(selector).#{query};
}
16 years, 1 month
JBoss Rich Faces SVN: r11542 - trunk/test-applications/seleniumTest/richfaces/src/test/testng/win.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-12-04 07:52:37 -0500 (Thu, 04 Dec 2008)
New Revision: 11542
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/testng/win/local_testng.xml
Log:
RF-5197
only for test
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/testng/win/local_testng.xml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/testng/win/local_testng.xml 2008-12-04 11:24:31 UTC (rev 11541)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/testng/win/local_testng.xml 2008-12-04 12:52:37 UTC (rev 11542)
@@ -6,11 +6,7 @@
<parameter name="loadScriptStrategy" value="DEFAULT"/>
<parameter name="filterPrefix" value="/faces/NONE/"/>
<classes>
- <class name="org.richfaces.testng.MessageTest">
- <methods>
- <include name="testHTMLAttributes" />
- </methods>
- </class>
+ <class name="org.richfaces.testng.MessageTest" />
</classes>
</test>
</suite>
16 years, 1 month
JBoss Rich Faces SVN: r11541 - in trunk/ui/hotKey/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2008-12-04 06:24:31 -0500 (Thu, 04 Dec 2008)
New Revision: 11541
Modified:
trunk/ui/hotKey/src/main/config/component/hotKey.xml
trunk/ui/hotKey/src/main/templates/org/richfaces/htmlHotKey.jspx
Log:
https://jira.jboss.org/jira/browse/RF-4811
Modified: trunk/ui/hotKey/src/main/config/component/hotKey.xml
===================================================================
--- trunk/ui/hotKey/src/main/config/component/hotKey.xml 2008-12-04 10:37:18 UTC (rev 11540)
+++ trunk/ui/hotKey/src/main/config/component/hotKey.xml 2008-12-04 11:24:31 UTC (rev 11541)
@@ -89,7 +89,6 @@
<name>disableInInputTypes</name>
<classname>java.lang.String</classname>
<description>Defines the types of the inputs not to be influenced with hotKey component. Possible values: buttons, texts and all (default). By default it is empty and this means ALL the types.</description>
- <defaultvalue>"all"</defaultvalue>
</property>
</component>
</components>
Modified: trunk/ui/hotKey/src/main/templates/org/richfaces/htmlHotKey.jspx
===================================================================
--- trunk/ui/hotKey/src/main/templates/org/richfaces/htmlHotKey.jspx 2008-12-04 10:37:18 UTC (rev 11540)
+++ trunk/ui/hotKey/src/main/templates/org/richfaces/htmlHotKey.jspx 2008-12-04 11:24:31 UTC (rev 11541)
@@ -74,6 +74,11 @@
org.richfaces.component.util.MessageUtil.getLabel(context, component) +
"', because value of disableInInput attribute is not 'true'");
}
+ }else if (Boolean.TRUE.equals(disableInInput)) {
+ options.append(",disableInInputTypes:");
+ options.append('\'');
+ options.append(getUtils().escapeJavaScript("all"));
+ options.append('\'');
}
Boolean checkParent = (Boolean) attributes.get("checkParent");
16 years, 1 month
JBoss Rich Faces SVN: r11540 - trunk/samples/editorSeam-sample/src/main/webapp/WEB-INF.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-12-04 05:37:18 -0500 (Thu, 04 Dec 2008)
New Revision: 11540
Modified:
trunk/samples/editorSeam-sample/src/main/webapp/WEB-INF/web.xml
Log:
use jsf impls from the war bundle
Modified: trunk/samples/editorSeam-sample/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/editorSeam-sample/src/main/webapp/WEB-INF/web.xml 2008-12-04 10:15:51 UTC (rev 11539)
+++ trunk/samples/editorSeam-sample/src/main/webapp/WEB-INF/web.xml 2008-12-04 10:37:18 UTC (rev 11540)
@@ -11,6 +11,10 @@
<param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
<param-value>false</param-value>
</context-param>
+ <context-param>
+ <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
+ <param-value>true</param-value>
+ </context-param>
<listener>
<listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
</listener>
16 years, 1 month
JBoss Rich Faces SVN: r11539 - trunk/framework/impl/src/main/java/org/ajax4jsf/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2008-12-04 05:15:51 -0500 (Thu, 04 Dec 2008)
New Revision: 11539
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/JSMin.java
Log:
https://jira.jboss.org/jira/browse/RF-4513
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/JSMin.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/JSMin.java 2008-12-04 10:01:06 UTC (rev 11538)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/javascript/JSMin.java 2008-12-04 10:15:51 UTC (rev 11539)
@@ -42,10 +42,9 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PushbackInputStream;
+import org.ajax4jsf.io.FastBufferOutputStream;
-
-
public class JSMin {
private static final int EOF = -1;
@@ -60,7 +59,7 @@
private int column;
public JSMin(InputStream in, OutputStream out) {
- this.in = new PushbackInputStream(in);
+ this.in = new PushbackInputStream(in,2);
this.out = out;
this.line = 0;
this.column = 0;
@@ -117,6 +116,10 @@
in.unread(lookaheadChar);
return lookaheadChar;
}
+
+ void back(byte[] b) throws IOException {
+ in.unread(b);
+ }
/**
* next -- get the next character, excluding comments. peek() is used to see
@@ -133,7 +136,6 @@
return c;
}
}
-
case '*':
get();
for (;;) {
@@ -144,6 +146,14 @@
return ' ';
}
break;
+ case '@':
+ // TODO: add spaces skipping
+ FastBufferOutputStream bs = new FastBufferOutputStream();
+ bs.write('*');
+ bs.write('@');
+ back(bs.toByteArray());
+ bs.close();
+ return c;
case EOF:
throw new UnterminatedCommentException(line,column);
}
16 years, 1 month
JBoss Rich Faces SVN: r11538 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/calendar and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2008-12-04 05:01:06 -0500 (Thu, 04 Dec 2008)
New Revision: 11538
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
fixed typos and some stuff added
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-03 22:31:51 UTC (rev 11537)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-04 10:01:06 UTC (rev 11538)
@@ -203,6 +203,7 @@
mode = UICalendar.AJAX_MODE;
status = "";
selectedDate = new Date();
+ isPopup = false;
}
public String resetAction() {
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-03 22:31:51 UTC (rev 11537)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-04 10:01:06 UTC (rev 11538)
@@ -84,7 +84,7 @@
String timeZoneId;
- String localId;
+ String localeId;
String currentDateHeaderXpath;
@@ -110,7 +110,7 @@
isPopupId = parentId + CONTROLS_FORM_ID + "isPopup";
datePatternId = parentId + CONTROLS_FORM_ID + "datePattern";
timeZoneId = parentId + CONTROLS_FORM_ID + "timeZone";
- localId = parentId + CONTROLS_FORM_ID + "local";
+ localeId = parentId + CONTROLS_FORM_ID + "locale";
currentDateHeaderXpath = "//td[@id='"+calendarHeaderId+"']/table/tbody/tr/td[3]/div";
}
@@ -334,10 +334,11 @@
@Test
public void testValueAndCurrentDateOfCalendarWithPopupFalse(Template template) {
- renderPage(template, RESET_METHOD);
+ renderPage(template, null);
initIds(getParentId());
String expectedSelectedDate = "03/03/2007 11:00";
String expectedCurrentDate = "04/04/2008 13:00";
+ setPopup(false);
//1. value != null + curr_date != null
writeStatus("Check whether the component is present and up to the mark if value and currentDate are defined");
@@ -345,6 +346,9 @@
setValueById(currentDateId, expectedCurrentDate);
clickCommandAndWait(setupActionId);
+ writeStatus("Check calendar panel has been rendered");
+ Assert.assertTrue(isVisible(calendarId), "Calendar panel is not visible");
+
writeStatus("Check selected date");
String date = selenium.getText(dateSelectionXpath);
String time = selenium.getText(timeSelectionXpath);
@@ -385,15 +389,19 @@
writeStatus("Check current month and year. Current date and value are not defined. Present (do not mix with current time 8))");
currentDate = selenium.getText(currentDateHeaderXpath);
- Locale locale = new Locale(selenium.getText(localId));
+ Locale locale = new Locale(selenium.getText(localeId));
Date presentTime = Calendar.getInstance(locale).getTime();
String month = DateUtils.month(presentTime, locale);
int year = DateUtils.year(presentTime);
String month_year = month + ", " + year;
- Assert.assertEquals(currentDate, month_year, "Calendar shows wrong current date");
+ Assert.assertEquals(currentDate, month_year, "Calendar shows wrong current date");
}
+ private void setPopup(boolean isPopup) {
+ runScript("$('" + isPopupId + "').checked=" + isPopup);
+ }
+
public String getTestUrl() {
return "pages/calendar/calendarTest.xhtml";
}
16 years, 1 month
JBoss Rich Faces SVN: r11537 - trunk/framework/impl/src/test/java/org/richfaces/json.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-12-03 17:31:51 -0500 (Wed, 03 Dec 2008)
New Revision: 11537
Added:
trunk/framework/impl/src/test/java/org/richfaces/json/SerializationTest.java
Log:
RF-5040
Added: trunk/framework/impl/src/test/java/org/richfaces/json/SerializationTest.java
===================================================================
--- trunk/framework/impl/src/test/java/org/richfaces/json/SerializationTest.java (rev 0)
+++ trunk/framework/impl/src/test/java/org/richfaces/json/SerializationTest.java 2008-12-03 22:31:51 UTC (rev 11537)
@@ -0,0 +1,111 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.json;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class SerializationTest extends TestCase {
+
+ private <T> T saveRestore(T t) throws IOException, ClassNotFoundException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(t);
+ oos.close();
+
+ ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ T restoredT = (T) t.getClass().cast(ois.readObject());
+
+ return restoredT;
+ }
+
+ public void testJSONObject() throws Exception {
+ JSONObject restoredObject = saveRestore(
+ new JSONObject("{a:null, b:'abc', c: {d: 'e', f: 'g'}, h: ['i', 'j']}"));
+
+ assertSame(JSONObject.NULL, restoredObject.get("a"));
+ assertEquals("abc", restoredObject.get("b"));
+
+ JSONObject nestedObject = (JSONObject) restoredObject.get("c");
+ assertEquals("e", nestedObject.get("d"));
+ assertEquals("g", nestedObject.get("f"));
+
+ JSONArray array = (JSONArray) restoredObject.get("h");
+ assertEquals(2, array.length());
+ assertEquals("i", array.get(0));
+ assertEquals("j", array.get(1));
+
+ }
+
+ public void testJSONCollection() throws Exception {
+ JSONCollection restored = saveRestore(new JSONCollection("[1, '2', null, [3, 4], {a: 'b', c: 'd'}]"));
+ Iterator iterator = restored.iterator();
+
+ assertEquals(Integer.valueOf(1), iterator.next());
+ assertEquals("2", iterator.next());
+ assertSame(JSONObject.NULL, iterator.next());
+
+ JSONCollection nestedCollection = (JSONCollection) iterator.next();
+ Iterator nestedIterator = nestedCollection.iterator();
+ assertEquals(Integer.valueOf(3), nestedIterator.next());
+ assertEquals(Integer.valueOf(4), nestedIterator.next());
+ assertFalse(nestedIterator.hasNext());
+
+ JSONMap nestedMap = (JSONMap) iterator.next();
+ assertEquals("b", nestedMap.get("a"));
+ assertEquals("d", nestedMap.get("c"));
+ assertEquals(2, nestedMap.size());
+
+ assertFalse(iterator.hasNext());
+ }
+
+ public void testJSONMap() throws Exception {
+ JSONMap restored = saveRestore(new JSONMap("{a: 'b', c: 3, d: null, e: [5, 'v'], f: {x: 'y', z: 2}}"));
+ assertEquals("b", restored.get("a"));
+ assertEquals(Integer.valueOf(3), restored.get("c"));
+ assertSame(JSONObject.NULL, restored.get("d"));
+
+ JSONCollection nestedCollection = (JSONCollection) restored.get("e");
+ Iterator nestedIterator = nestedCollection.iterator();
+ assertEquals(Integer.valueOf(5), nestedIterator.next());
+ assertEquals("v", nestedIterator.next());
+ assertFalse(nestedIterator.hasNext());
+
+ JSONMap nestedObject = (JSONMap) restored.get("f");
+ assertEquals("y", nestedObject.get("x"));
+ assertEquals(Integer.valueOf(2), nestedObject.get("z"));
+ assertEquals(2, nestedObject.size());
+
+ assertEquals(5, restored.size());
+ }
+}
16 years, 1 month
JBoss Rich Faces SVN: r11536 - in trunk/framework/impl/src/main/java/org: ajax4jsf/el and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-12-03 17:30:09 -0500 (Wed, 03 Dec 2008)
New Revision: 11536
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/el/
trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/CapturingELResolver.java
trunk/framework/impl/src/main/java/org/ajax4jsf/util/GenericsIntrospectionCache.java
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/util/ELUtils.java
trunk/framework/impl/src/main/java/org/richfaces/util/ReferenceMap.java
Log:
RF-4540
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java (from rev 11455, trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java 2008-12-03 22:30:09 UTC (rev 11536)
@@ -0,0 +1,98 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.ajax4jsf.el;
+
+import java.util.Locale;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.FunctionMapper;
+import javax.el.VariableMapper;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ELContextWrapper extends ELContext {
+
+ private final ELContext parent;
+
+ private final ELResolver resolver;
+
+ /**
+ * @param parent
+ */
+ public ELContextWrapper(ELContext parent,ELResolver resolver) {
+ super();
+ this.resolver = resolver;
+ this.parent = parent;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.ELContext#getELResolver()
+ */
+ @Override
+ public ELResolver getELResolver() {
+ return resolver;
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getFunctionMapper()
+ */
+ public FunctionMapper getFunctionMapper() {
+ return parent.getFunctionMapper();
+ }
+
+ /**
+ * @return
+ * @see javax.el.ELContext#getVariableMapper()
+ */
+ public VariableMapper getVariableMapper() {
+ return parent.getVariableMapper();
+ }
+
+ /**
+ * @param key
+ * @return
+ * @see javax.el.ELContext#getContext(java.lang.Class)
+ */
+ public Object getContext(Class key) {
+ return parent.getContext(key);
+ }
+
+ /**
+ * @param key
+ * @param contextObject
+ * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
+ */
+ public void putContext(Class key, Object contextObject) {
+ parent.putContext(key, contextObject);
+ }
+
+ public Locale getLocale() {
+ return parent.getLocale();
+ }
+
+ public void setLocale(Locale locale) {
+ parent.setLocale(locale);
+ }
+}
Property changes on: trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELContextWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:mergeinfo
+
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/el/ELResolverWrapper.java 2008-12-03 22:30:09 UTC (rev 11536)
@@ -0,0 +1,109 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.el;
+
+import java.beans.FeatureDescriptor;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class ELResolverWrapper extends ELResolver {
+
+ public ELResolverWrapper(ELResolver resolver) {
+ super();
+ this.resolver = resolver;
+ }
+
+ private ELResolver resolver;
+
+ /**
+ * @param context
+ * @param base
+ * @return
+ * @see javax.el.ELResolver#getCommonPropertyType(javax.el.ELContext, java.lang.Object)
+ */
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ return resolver.getCommonPropertyType(context, base);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @return
+ * @see javax.el.ELResolver#getFeatureDescriptors(javax.el.ELContext, java.lang.Object)
+ */
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
+ Object base) {
+ return resolver.getFeatureDescriptors(context, base);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @param property
+ * @return
+ * @see javax.el.ELResolver#getType(javax.el.ELContext, java.lang.Object, java.lang.Object)
+ */
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ return resolver.getType(context, base, property);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @param property
+ * @return
+ * @see javax.el.ELResolver#getValue(javax.el.ELContext, java.lang.Object, java.lang.Object)
+ */
+ public Object getValue(ELContext context, Object base, Object property) {
+ return resolver.getValue(context, base, property);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @param property
+ * @return
+ * @see javax.el.ELResolver#isReadOnly(javax.el.ELContext, java.lang.Object, java.lang.Object)
+ */
+ public boolean isReadOnly(ELContext context, Object base, Object property) {
+ return resolver.isReadOnly(context, base, property);
+ }
+
+ /**
+ * @param context
+ * @param base
+ * @param property
+ * @param value
+ * @see javax.el.ELResolver#setValue(javax.el.ELContext, java.lang.Object, java.lang.Object, java.lang.Object)
+ */
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) {
+ resolver.setValue(context, base, property, value);
+ }
+}
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/util/CapturingELResolver.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/CapturingELResolver.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/CapturingELResolver.java 2008-12-03 22:30:09 UTC (rev 11536)
@@ -0,0 +1,71 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util;
+
+import javax.el.ELContext;
+import javax.el.ELResolver;
+
+import org.ajax4jsf.el.ELResolverWrapper;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+class CapturingELResolver extends ELResolverWrapper {
+
+ private Object base;
+
+ private Object property;
+
+ public CapturingELResolver(ELResolver resolver) {
+ super(resolver);
+ }
+
+ @Override
+ public Object getValue(ELContext context, Object base, Object property) {
+ if (base != null && property != null) {
+ this.base = base;
+ this.property = property;
+ }
+
+ return super.getValue(context, base, property);
+ }
+
+ @Override
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ if (base != null && property != null) {
+ this.base = base;
+ this.property = property;
+ }
+
+ return super.getType(context, base, property);
+ }
+
+ public Object getBase() {
+ return base;
+ }
+
+ public Object getProperty() {
+ return property;
+ }
+}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/util/ELUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/ELUtils.java 2008-12-03 22:29:10 UTC (rev 11535)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/ELUtils.java 2008-12-03 22:30:09 UTC (rev 11536)
@@ -20,6 +20,25 @@
*/
package org.ajax4jsf.util;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.ref.SoftReference;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.HashMap;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.el.ELContextWrapper;
+import org.ajax4jsf.util.GenericsIntrospectionCache.GenericsCacheEntry;
+
/**
* @author asmirnov
*
@@ -54,4 +73,98 @@
return false;
}
+ private static Class<?> resolveType(Type type) {
+ Class<?> result = Object.class;
+
+ if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) type;
+ Type[] types = parameterizedType.getActualTypeArguments();
+ if (types != null && types.length != 0) {
+ Type actualType = types[0];
+ if (actualType instanceof Class) {
+ result = (Class<?>) actualType;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private static BeanInfo getBeanInfo(Class<?> beanClass, GenericsCacheEntry entry) {
+ BeanInfo beanInfo = null;
+
+ SoftReference<BeanInfo> beanInfoReference = entry.beanInfoReference;
+ if (beanInfoReference != null) {
+ beanInfo = beanInfoReference.get();
+ }
+
+ if (beanInfo == null) {
+ try {
+ beanInfo = Introspector.getBeanInfo(beanClass);
+ entry.beanInfoReference = new SoftReference<BeanInfo>(beanInfo);
+ } catch (IntrospectionException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+
+ return beanInfo;
+ }
+
+ private static Class<?> getGenericCollectionType(FacesContext context, Object base, String propertyName) {
+ Class<?> genericPropertyClass = null;
+
+ GenericsIntrospectionCache introspectionCache = GenericsIntrospectionCache.getInstance(context);
+ if (base != null && propertyName != null) {
+ Class<? extends Object> beanClass = base.getClass();
+
+ synchronized (introspectionCache) {
+ GenericsCacheEntry cacheEntry = introspectionCache.getGenericCacheEntry(beanClass);
+
+ if (cacheEntry.genericPropertiesClasses == null) {
+ cacheEntry.genericPropertiesClasses = new HashMap<String, Class<?>>();
+ } else {
+ genericPropertyClass = cacheEntry.genericPropertiesClasses.get(propertyName);
+ }
+
+ if (genericPropertyClass == null) {
+ BeanInfo beanInfo = getBeanInfo(beanClass, cacheEntry);
+
+ PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor pd : descriptors) {
+ if (propertyName.equals(pd.getName())) {
+ Method readMethod = pd.getReadMethod();
+
+ genericPropertyClass = resolveType(readMethod.getGenericReturnType());
+ break;
+ }
+ }
+
+ cacheEntry.genericPropertiesClasses.put(propertyName, genericPropertyClass);
+ }
+ }
+ }
+
+ return genericPropertyClass;
+ }
+
+ public static Class<?> getContainerClass(FacesContext facesContext, ValueExpression expression) {
+ ELContext initialELContext = facesContext.getELContext();
+
+ CapturingELResolver capturingELResolver = new CapturingELResolver(initialELContext.getELResolver());
+ Class<?> type = expression.getType(new ELContextWrapper(initialELContext, capturingELResolver));
+
+ Class<?> containerType = type.getComponentType();
+ if (containerType == null && type != null) {
+ if (Collection.class.isAssignableFrom(type)) {
+ Object base = capturingELResolver.getBase();
+ Object property = capturingELResolver.getProperty();
+
+ if (base != null && property != null) {
+ containerType = getGenericCollectionType(facesContext, base, property.toString());
+ }
+ }
+ }
+
+ return containerType;
+ }
}
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/util/GenericsIntrospectionCache.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/util/GenericsIntrospectionCache.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/util/GenericsIntrospectionCache.java 2008-12-03 22:30:09 UTC (rev 11536)
@@ -0,0 +1,101 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.util;
+
+import java.beans.BeanInfo;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.util.ReferenceMap;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+class GenericsIntrospectionCache {
+
+ private static final String INSTANCE_ATTRIBUTE_NAME = GenericsIntrospectionCache.class.getName();
+
+ private static final String CACHE_SIZE_PARAMETER = "org.richfaces.GenericsIntrospectionCacheSize";
+
+ private static final int DEFAULT_CACHE_SIZE = 256;
+
+ static final class GenericsCacheEntry {
+ SoftReference<BeanInfo> beanInfoReference;
+ Map<String, Class<?>> genericPropertiesClasses;
+ };
+
+ private Map<Class<?>, GenericsCacheEntry> genericsCache;
+
+ private static int getSize(ExternalContext externalContext) {
+ int cacheSize = DEFAULT_CACHE_SIZE;
+
+ String cacheSizeParameter = externalContext.getInitParameter(CACHE_SIZE_PARAMETER);
+ if (cacheSizeParameter != null && cacheSizeParameter.length() != 0) {
+ try {
+ cacheSize = Integer.valueOf(cacheSizeParameter);
+ } catch (NumberFormatException e) {
+ externalContext.log("Error converting " + CACHE_SIZE_PARAMETER + " init parameter to int: " + e.getMessage(),
+ e);
+ }
+ }
+
+ return cacheSize;
+ }
+
+ private GenericsIntrospectionCache(int cacheSize) {
+ genericsCache = new ReferenceMap<Class<?>, GenericsCacheEntry>(
+ new LRUMap<Class<?>, Reference<GenericsCacheEntry>>(cacheSize));
+ }
+
+ public GenericsCacheEntry getGenericCacheEntry(Class<?> beanClass) {
+ GenericsCacheEntry cacheEntry = genericsCache.get(beanClass);
+ if (cacheEntry == null) {
+ cacheEntry = new GenericsCacheEntry();
+ genericsCache.put(beanClass, cacheEntry);
+ }
+
+ return cacheEntry;
+ }
+
+ static GenericsIntrospectionCache getInstance(FacesContext facesContext) {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Map<String, Object> applicationMap = externalContext.getApplicationMap();
+
+ GenericsIntrospectionCache instance;
+ synchronized (applicationMap) {
+ instance = (GenericsIntrospectionCache) applicationMap.get(INSTANCE_ATTRIBUTE_NAME);
+ if (instance == null) {
+ instance = new GenericsIntrospectionCache(getSize(externalContext));
+ applicationMap.put(INSTANCE_ATTRIBUTE_NAME, instance);
+ }
+ }
+
+ return instance;
+ }
+
+}
Modified: trunk/framework/impl/src/main/java/org/richfaces/util/ReferenceMap.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/util/ReferenceMap.java 2008-12-03 22:29:10 UTC (rev 11535)
+++ trunk/framework/impl/src/main/java/org/richfaces/util/ReferenceMap.java 2008-12-03 22:30:09 UTC (rev 11536)
@@ -37,123 +37,138 @@
public class ReferenceMap<K, V> implements Map<K, V> {
- private Map<K, ReferenceMapSoftReference<K, V>> map = new HashMap<K, ReferenceMapSoftReference<K, V>>();
+ private Map<K, Reference<V>> map;
- private ReferenceQueue<V> queue = new ReferenceQueue<V>();
-
- private void purge() {
- Reference<? extends V> reference = null;
- while ((reference = queue.poll()) != null) {
- ReferenceMapSoftReference<?, ?> entry = (ReferenceMapSoftReference<?, ?>) reference;
- entry.clear();
- map.remove(entry.getKey());
+ private ReferenceQueue<V> queue = new ReferenceQueue<V>();
+
+ protected static class ReferenceMapSoftReference<K, V> extends SoftReference<V> {
+ private K key;
+
+ public K getKey() {
+ return key;
+ }
+
+ public ReferenceMapSoftReference(K key, V value, ReferenceQueue<? super V> queue) {
+ super(value, queue);
+ this.key = key;
+ }
+ }
+
+ public ReferenceMap() {
+ this(new HashMap<K, Reference<V>>());
}
- }
-
- public void clear() {
- map.clear();
- while (queue.poll() != null) {
- //release queue entries
+
+ public ReferenceMap(Map<K, Reference<V>> map) {
+ super();
+
+ this.map = map;
}
- }
-
- public boolean containsKey(Object key) {
- purge();
- return map.containsKey(key);
- }
+ private void purge() {
+ Reference<? extends V> reference = null;
+ while ((reference = queue.poll()) != null) {
+ ReferenceMapSoftReference<?, ?> entry = (ReferenceMapSoftReference<?, ?>) reference;
+ entry.clear();
+ map.remove(entry.getKey());
+ }
+ }
- public boolean containsValue(Object value) {
- throw new UnsupportedOperationException();
- }
+ public void clear() {
+ map.clear();
+
+ Reference<? extends V> reference = null;
+ while ((reference = queue.poll()) != null) {
+ //release queue entries
+ reference.clear();
+ }
+ }
- public Set<java.util.Map.Entry<K, V>> entrySet() {
- throw new UnsupportedOperationException();
- }
+ public boolean containsKey(Object key) {
+ purge();
- public V get(Object key) {
- purge();
-
- ReferenceMapSoftReference<K,V> reference = map.get(key);
- if (reference != null) {
- return reference.get();
+ return map.containsKey(key);
}
-
- return null;
- }
- public boolean isEmpty() {
- purge();
-
- return map.isEmpty();
- }
+ public boolean containsValue(Object value) {
+ throw new UnsupportedOperationException();
+ }
- public Set<K> keySet() {
- purge();
-
- return map.keySet();
- }
+ public Set<java.util.Map.Entry<K, V>> entrySet() {
+ throw new UnsupportedOperationException();
+ }
- private V doPut(K key, V value) {
- ReferenceMapSoftReference<K,V> reference = map.put(key,
- new ReferenceMapSoftReference<K, V>(key, value, queue));
-
- if (reference != null) {
- return reference.get();
+ public V get(Object key) {
+ purge();
+
+ Reference<V> reference = map.get(key);
+ if (reference != null) {
+ return reference.get();
+ }
+
+ return null;
}
-
- return null;
- }
-
- public V put(K key, V value) {
- purge();
-
- return doPut(key, value);
- }
- public void putAll(Map<? extends K, ? extends V> t) {
- purge();
-
- for (Map.Entry<? extends K, ? extends V> entry: t.entrySet()) {
- doPut(entry.getKey(), entry.getValue());
+ public boolean isEmpty() {
+ purge();
+
+ return map.isEmpty();
}
- }
- public V remove(Object key) {
- purge();
-
- ReferenceMapSoftReference<K,V> reference = map.remove(key);
- if (reference != null) {
- return reference.get();
+ public Set<K> keySet() {
+ purge();
+
+ return map.keySet();
}
- return null;
- }
+ private V doPut(K key, V value) {
+ Reference<V> reference = map.put(key, new ReferenceMapSoftReference<K, V>(key, value, queue));
- public int size() {
- purge();
+ if (reference != null) {
+ return reference.get();
+ }
+
+ return null;
+ }
+
+ public V put(K key, V value) {
+ purge();
+
+ V v = doPut(key, value);
- return map.size();
- }
+ purge();
+
+ return v;
+ }
- public Collection<V> values() {
- throw new UnsupportedOperationException();
- }
-}
+ public void putAll(Map<? extends K, ? extends V> t) {
+ purge();
-class ReferenceMapSoftReference<K, V> extends SoftReference<V> {
- private K key;
+ for (Map.Entry<? extends K, ? extends V> entry: t.entrySet()) {
+ doPut(entry.getKey(), entry.getValue());
+ }
+
+ purge();
+ }
- public K getKey() {
- return key;
- }
+ public V remove(Object key) {
+ purge();
- public ReferenceMapSoftReference(K key, V value) {
- this(key, value, null);
- }
+ Reference<V> reference = map.remove(key);
+ if (reference != null) {
+ return reference.get();
+ }
- public ReferenceMapSoftReference(K key, V value, ReferenceQueue<? super V> queue) {
- super(value, queue);
- this.key = key;
- }
+ return null;
+ }
+
+ public int size() {
+ purge();
+
+ return map.size();
+ }
+
+ public Collection<V> values() {
+ throw new UnsupportedOperationException();
+ }
+
}
\ No newline at end of file
16 years, 1 month
JBoss Rich Faces SVN: r11535 - in trunk/ui: listShuttle/src/main/java/org/richfaces/component and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-12-03 17:29:10 -0500 (Wed, 03 Dec 2008)
New Revision: 11535
Removed:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
trunk/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
trunk/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
Log:
RF-4540
Modified: trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
===================================================================
--- trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2008-12-03 18:59:50 UTC (rev 11534)
+++ trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2008-12-03 22:29:10 UTC (rev 11535)
@@ -36,6 +36,7 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.el.ELContextWrapper;
import org.hibernate.validator.ClassValidator;
import org.hibernate.validator.InvalidValue;
Deleted: trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java
===================================================================
--- trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java 2008-12-03 18:59:50 UTC (rev 11534)
+++ trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java 2008-12-03 22:29:10 UTC (rev 11535)
@@ -1,98 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.validator;
-
-import java.util.Locale;
-
-import javax.el.ELContext;
-import javax.el.ELResolver;
-import javax.el.FunctionMapper;
-import javax.el.VariableMapper;
-
-/**
- * @author asmirnov
- *
- */
-public class ELContextWrapper extends ELContext {
-
- private final ELContext parent;
-
- private final ELResolver resolver;
-
- /**
- * @param parent
- */
- public ELContextWrapper(ELContext parent,ELResolver resolver) {
- super();
- this.resolver = resolver;
- this.parent = parent;
- }
-
- /* (non-Javadoc)
- * @see javax.el.ELContext#getELResolver()
- */
- @Override
- public ELResolver getELResolver() {
- return resolver;
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getFunctionMapper()
- */
- public FunctionMapper getFunctionMapper() {
- return parent.getFunctionMapper();
- }
-
- /**
- * @return
- * @see javax.el.ELContext#getVariableMapper()
- */
- public VariableMapper getVariableMapper() {
- return parent.getVariableMapper();
- }
-
- /**
- * @param key
- * @return
- * @see javax.el.ELContext#getContext(java.lang.Class)
- */
- public Object getContext(Class key) {
- return parent.getContext(key);
- }
-
- /**
- * @param key
- * @param contextObject
- * @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
- */
- public void putContext(Class key, Object contextObject) {
- parent.putContext(key, contextObject);
- }
-
- public Locale getLocale() {
- return parent.getLocale();
- }
-
- public void setLocale(Locale locale) {
- parent.setLocale(locale);
- }
-}
Modified: trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
--- trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-12-03 18:59:50 UTC (rev 11534)
+++ trunk/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-12-03 22:29:10 UTC (rev 11535)
@@ -30,6 +30,7 @@
import java.util.Set;
import java.util.Map.Entry;
+import javax.el.ValueExpression;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
@@ -793,6 +794,15 @@
return super.getValueBinding(name);
}
+ @Override
+ public ValueExpression getValueExpression(String name) {
+ if ("value".equals(name)) {
+ return super.getValueExpression("sourceValue");
+ }
+
+ return super.getValueExpression(name);
+ }
+
public void setValue(Object value) {
this.valueHolder = (ValueHolder) value;
}
Modified: trunk/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
===================================================================
--- trunk/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2008-12-03 18:59:50 UTC (rev 11534)
+++ trunk/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2008-12-03 22:29:10 UTC (rev 11535)
@@ -113,7 +113,7 @@
ResponseWriter writer = context.getResponseWriter();
StringWriter stringWriter = new StringWriter();
context.setResponseWriter(writer.cloneWithWriter(stringWriter));
- encodeRows(context, shuttle, new ListShuttleRendererTableHolder(shuttle, getConverter(context, shuttle), source));
+ encodeRows(context, shuttle, new ListShuttleRendererTableHolder(shuttle, getConverter(context, shuttle, true), source));
context.getResponseWriter().flush();
context.setResponseWriter(writer);
@@ -322,7 +322,7 @@
boolean facadeSource = true;
- Converter converter = getConverter(context, listShuttle);
+ Converter converter = getConverter(context, listShuttle, false);
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
Modified: trunk/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java
===================================================================
--- trunk/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2008-12-03 18:59:50 UTC (rev 11534)
+++ trunk/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingBaseComponent.java 2008-12-03 22:29:10 UTC (rev 11535)
@@ -20,6 +20,7 @@
*/
package org.richfaces.component;
+import java.beans.FeatureDescriptor;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
@@ -29,6 +30,9 @@
import java.util.List;
import java.util.Map;
+import javax.el.ELContext;
+import javax.el.ELResolver;
+import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
@@ -41,7 +45,6 @@
import javax.faces.convert.ConverterException;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
import javax.faces.model.ArrayDataModel;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
@@ -51,6 +54,7 @@
import org.ajax4jsf.component.UIDataAdaptor;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.RepeatState;
+import org.ajax4jsf.util.ELUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.EmptyIterator;
import org.apache.commons.collections.iterators.FilterIterator;
@@ -584,21 +588,27 @@
return null;
}
+ private static final Converter noOpConverter = new Converter() {
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) {
+ return value;
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) {
+ return (String) value;
+ }
+ };
+
public Converter getConverterForValue(FacesContext context) {
- ValueBinding binding = this.getValueBinding("value");
- if (binding != null) {
- Class type = binding.getType(context);
- if (type != null) {
- Class componentType = type.getComponentType();
- if (componentType != null) {
- return getConverterForType(context, componentType);
- } else {
- //support for generics introspection
- }
- }
+ ValueExpression expression = this.getValueExpression("value");
+ Class<?> containerClass = ELUtils.getContainerClass(context, expression);
+
+ Converter converter = getConverterForType(context, containerClass);
+ if (converter == null && String.class.equals(containerClass)) {
+ converter = noOpConverter;
}
- return null;
+ return converter;
}
-
-}
+}
\ No newline at end of file
Modified: trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java
===================================================================
--- trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-12-03 18:59:50 UTC (rev 11534)
+++ trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingComponentRendererBase.java 2008-12-03 22:29:10 UTC (rev 11535)
@@ -45,6 +45,7 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIOrderingBaseComponent;
import org.richfaces.component.UIOrderingBaseComponent.ItemState;
+import org.richfaces.component.util.MessageUtil;
/**
* @author Nick Belaevski
@@ -566,7 +567,7 @@
}
protected Converter getConverter(FacesContext context,
- UIOrderingBaseComponent component) {
+ UIOrderingBaseComponent component, boolean warnOnDefaultConverter) {
Converter converter = component.getConverter();
if (converter == null) {
@@ -575,6 +576,13 @@
if (converter == null) {
converter = DEFAULT_CONVERTER;
+
+ if (warnOnDefaultConverter) {
+ Object componentLabel = MessageUtil.getLabel(context, component);
+ context.getExternalContext().log("Converter for component [" + componentLabel +
+ "] cannot be discovered, so default implementation of converter will be used." +
+ " Component items will be converted to String on decoding.");
+ }
}
return converter;
Modified: trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java
===================================================================
--- trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2008-12-03 18:59:50 UTC (rev 11534)
+++ trunk/ui/orderingList/src/main/java/org/richfaces/renderkit/OrderingListRendererBase.java 2008-12-03 22:29:10 UTC (rev 11535)
@@ -128,8 +128,10 @@
public void encodeRows(FacesContext context, UIComponent component)
throws IOException {
- super.encodeRows(context, component, new OrderingListRendererTableHolder((UIDataAdaptor) component,
- getConverter(context, (UIOrderingBaseComponent) component)));
+ UIOrderingBaseComponent orderingBaseComponent = (UIOrderingBaseComponent) component;
+
+ super.encodeRows(context, component, new OrderingListRendererTableHolder(orderingBaseComponent,
+ getConverter(context, orderingBaseComponent, true)));
}
public void encodeOneRow(FacesContext context, TableHolder holder)
@@ -255,7 +257,7 @@
Object activeItem = null;
String[] strings = (String[]) externalContext.getRequestParameterValuesMap().get(clientId);
Map map = new LinkedHashMap();
- Converter converter = getConverter(context, orderingList);
+ Converter converter = getConverter(context, orderingList, false);
for (int i = 0; i < strings.length; i++) {
String string = strings[i];
int idx = string.indexOf(':');
16 years, 1 month
JBoss Rich Faces SVN: r11534 - in trunk/test-applications/seleniumTest/richfaces/src: main/java/org/ajax4jsf/util and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2008-12-03 13:59:50 -0500 (Wed, 03 Dec 2008)
New Revision: 11534
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/util/DateUtils.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5153
https://jira.jboss.org/jira/browse/RF-5154
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-03 18:38:11 UTC (rev 11533)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-03 18:59:50 UTC (rev 11534)
@@ -93,7 +93,11 @@
}
public void resetSelectedDateString() {
- setSelectedDateString(DATE_FORMAT.format(getSelectedDate()));
+ if (getSelectedDate() != null) {
+ setSelectedDateString(DATE_FORMAT.format(getSelectedDate()));
+ } else {
+ setSelectedDateString("");
+ }
}
public String getSelectedDateString() {
@@ -251,4 +255,22 @@
this.currentDate = currentDate;
}
+ private boolean isPopup;
+
+ /**
+ * Gets value of isPopup field.
+ * @return value of isPopup field
+ */
+ public boolean isPopup() {
+ return isPopup;
+ }
+
+ /**
+ * Set a new value for isPopup field.
+ * @param isPopup a new value for isPopup field
+ */
+ public void setPopup(boolean isPopup) {
+ this.isPopup = isPopup;
+ }
+
}
Added: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/util/DateUtils.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/util/DateUtils.java (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/util/DateUtils.java 2008-12-03 18:59:50 UTC (rev 11534)
@@ -0,0 +1,44 @@
+package org.ajax4jsf.util;
+
+import java.text.DateFormatSymbols;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+
+public abstract class DateUtils {
+
+ /**
+ * Returns <code>Date</code> object according to given <code>dateString</code>
+ * @param dateString
+ * @param pattern
+ * @param locale
+ * @return
+ */
+ public static Date date(String dateString, String pattern, Locale locale) {
+ Date retVal = null;
+ try {
+ retVal = new SimpleDateFormat(pattern, locale).parse(dateString);
+ } catch (ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return retVal;
+ }
+
+ public static String month(Date date, Locale locale) {
+ Calendar c = Calendar.getInstance(locale);
+ c.setTime(date);
+ DateFormatSymbols symbols = new DateFormatSymbols(locale);
+ return symbols.getMonths()[c.get(Calendar.MONTH)];
+ }
+
+ public static int year(Date date) {
+ Calendar c = Calendar.getInstance();
+ c.setTime(date);
+ return c.get(Calendar.YEAR);
+ }
+
+}
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/util/DateUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/calendarTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-03 18:38:11 UTC (rev 11533)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-03 18:59:50 UTC (rev 11534)
@@ -22,10 +22,13 @@
package org.richfaces.testng;
import java.text.ParseException;
+import java.util.Calendar;
import java.util.Date;
+import java.util.Locale;
import org.ajax4jsf.bean.CalendarTestBean;
import org.ajax4jsf.template.Template;
+import org.ajax4jsf.util.DateUtils;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -33,13 +36,12 @@
public class CalendarTest extends SeleniumTestBase {
static final String RESET_METHOD = "#{calendarBean.reset}";
-
static final String FORM_ID = "_form:";
static final String CONTROLS_FORM_ID = "_controls:";
static final String availableDayCellClass = "rich-calendar-cell-size rich-calendar-cell rich-calendar-btn";
-
+
String calendarId;
String calendarHeaderId;
@@ -55,9 +57,15 @@
String resetActionId;
String testClientModeId;
-
+
+ String setupActionId;
+
+ String dateSelectionXpath;
+
String timeSelectionXpath;
-
+
+ String timeSelectionXpathMinusDiv;
+
String timeHoursSelectionId;
String timeMinutesSelectionId;
@@ -66,20 +74,44 @@
String timeSelectionCancelButtonId;
+ String selectedDateId;
+
+ String currentDateId;
+
+ String isPopupId;
+
+ String datePatternId;
+
+ String timeZoneId;
+
+ String localId;
+
+ String currentDateHeaderXpath;
+
void initIds(String parentId) {
calendarId = parentId + FORM_ID + "calendar";
calendarHeaderId = calendarId + "Header";
calendarFooterId = calendarId + "Footer";
+ dateSelectionXpath = "//td[@id='"+calendarFooterId+"']/table/tbody/tr/td[1]";
+ timeSelectionXpathMinusDiv = "//td[@id='"+calendarFooterId+"']/table/tbody/tr/td[3]";
timeSelectionXpath = "//td[@id='"+calendarFooterId+"']/table/tbody/tr/td[3]/div";
ajaxSubmitId = parentId + FORM_ID + "ajaxSubmit";
serverSubmitId = parentId + FORM_ID + "serverSubmit";
statusId = parentId + FORM_ID + "status";
resetActionId = parentId + CONTROLS_FORM_ID + "resetAction";
testClientModeId = parentId + CONTROLS_FORM_ID + "testClientMode";
+ setupActionId = parentId + CONTROLS_FORM_ID + "setup";
timeHoursSelectionId = calendarId + "TimeHours";
timeMinutesSelectionId = calendarId + "TimeMinutes";
timeSelectionOkButtonId = calendarId + "TimeEditorButtonOk";
timeSelectionCancelButtonId = calendarId + "TimeEditorButtonCancel";
+ selectedDateId = parentId + CONTROLS_FORM_ID + "selectedDate";
+ currentDateId = parentId + CONTROLS_FORM_ID + "currentDate";
+ isPopupId = parentId + CONTROLS_FORM_ID + "isPopup";
+ datePatternId = parentId + CONTROLS_FORM_ID + "datePattern";
+ timeZoneId = parentId + CONTROLS_FORM_ID + "timeZone";
+ localId = parentId + CONTROLS_FORM_ID + "local";
+ currentDateHeaderXpath = "//td[@id='"+calendarHeaderId+"']/table/tbody/tr/td[3]/div";
}
String getStatus() {
@@ -292,6 +324,76 @@
Assert.assertFalse(isVisibleById(calendarOpenedId), "Calendar window should NOT be visible on the component!");
}
+// @Test
+// public void testValueAndCurrentDateOfCalendarInCaseOfPopupTrue(Template template) {
+// renderPage(template);
+// //1. value != null + curr_date != null
+// //2. value != null + curr_date == null
+// //3. value == null + curr_date == null
+// }
+
+ @Test
+ public void testValueAndCurrentDateOfCalendarWithPopupFalse(Template template) {
+ renderPage(template, RESET_METHOD);
+ initIds(getParentId());
+ String expectedSelectedDate = "03/03/2007 11:00";
+ String expectedCurrentDate = "04/04/2008 13:00";
+
+ //1. value != null + curr_date != null
+ writeStatus("Check whether the component is present and up to the mark if value and currentDate are defined");
+ setValueById(selectedDateId, expectedSelectedDate);
+ setValueById(currentDateId, expectedCurrentDate);
+ clickCommandAndWait(setupActionId);
+
+ writeStatus("Check selected date");
+ String date = selenium.getText(dateSelectionXpath);
+ String time = selenium.getText(timeSelectionXpath);
+ String date_time = date + " " + time;
+ Assert.assertEquals(date_time, expectedSelectedDate, "Calendar shows wrong date");
+
+ writeStatus("Check current month and year");
+ String currentDate = selenium.getText(currentDateHeaderXpath);
+ Assert.assertEquals(currentDate, "April, 2008", "Calendar shows wrong current date");
+
+ //2. value != null + curr_date == null
+ writeStatus("Check whether the component is present and up to the mark if value is given but currentDate is not");
+
+ setValueById(selectedDateId, expectedSelectedDate);
+ setValueById(currentDateId, "");
+ clickCommandAndWait(setupActionId);
+
+ writeStatus("Check selected date");
+ date = selenium.getText(dateSelectionXpath);
+ time = selenium.getText(timeSelectionXpath);
+ date_time = date + " " + time;
+ Assert.assertEquals(date_time, expectedSelectedDate, "Calendar shows wrong date");
+
+ writeStatus("Check current month and year. Current date is not specified. Value date will be used instead");
+ currentDate = selenium.getText(currentDateHeaderXpath);
+ Assert.assertEquals(currentDate, "March, 2007", "Calendar shows wrong current date");
+
+ //3. value == null + curr_date == null
+ writeStatus("Check whether the component is present and up to the mark if value and currentDate are not defined");
+ setValueById(selectedDateId, "");
+ setValueById(currentDateId, "");
+ clickCommandAndWait(setupActionId);
+
+ writeStatus("Selected date is null. Selected value panel is not visible");
+ Assert.assertFalse(isVisible(dateSelectionXpath), "Footer with selected date has to be invisible");
+ Assert.assertFalse(isVisible(timeSelectionXpathMinusDiv), "Footer with selected date has to be invisible");
+
+ writeStatus("Check current month and year. Current date and value are not defined. Present (do not mix with current time 8))");
+ currentDate = selenium.getText(currentDateHeaderXpath);
+
+ Locale locale = new Locale(selenium.getText(localId));
+ Date presentTime = Calendar.getInstance(locale).getTime();
+ String month = DateUtils.month(presentTime, locale);
+ int year = DateUtils.year(presentTime);
+ String month_year = month + ", " + year;
+
+ Assert.assertEquals(currentDate, month_year, "Calendar shows wrong current date");
+ }
+
public String getTestUrl() {
return "pages/calendar/calendarTest.xhtml";
}
16 years, 1 month