JBoss Rich Faces SVN: r5046 - trunk/sandbox/samples.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-12-27 13:48:31 -0500 (Thu, 27 Dec 2007)
New Revision: 5046
Modified:
trunk/sandbox/samples/pom.xml
Log:
add pickList-sample module
Modified: trunk/sandbox/samples/pom.xml
===================================================================
--- trunk/sandbox/samples/pom.xml 2007-12-27 18:47:21 UTC (rev 5045)
+++ trunk/sandbox/samples/pom.xml 2007-12-27 18:48:31 UTC (rev 5046)
@@ -21,5 +21,6 @@
<module>fileUploadDemo</module>
<module>combobox-sample</module>
<module>progressBarDemo</module>
+ <module>pickList-sample</module>
</modules>
</project>
\ No newline at end of file
16 years, 5 months
JBoss Rich Faces SVN: r5045 - trunk/sandbox/ui.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-12-27 13:47:21 -0500 (Thu, 27 Dec 2007)
New Revision: 5045
Modified:
trunk/sandbox/ui/pom.xml
Log:
add module pickList
Modified: trunk/sandbox/ui/pom.xml
===================================================================
--- trunk/sandbox/ui/pom.xml 2007-12-27 18:46:57 UTC (rev 5044)
+++ trunk/sandbox/ui/pom.xml 2007-12-27 18:47:21 UTC (rev 5045)
@@ -23,5 +23,6 @@
<module>fileUpload</module>
<module>combobox</module>
<module>progressBar</module>
+ <module>pickList</module>
</modules>
</project>
\ No newline at end of file
16 years, 5 months
JBoss Rich Faces SVN: r5044 - trunk/sandbox/ui/pickList.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-12-27 13:46:57 -0500 (Thu, 27 Dec 2007)
New Revision: 5044
Added:
trunk/sandbox/ui/pickList/pom.xml
Log:
Added: trunk/sandbox/ui/pickList/pom.xml
===================================================================
--- trunk/sandbox/ui/pickList/pom.xml (rev 0)
+++ trunk/sandbox/ui/pickList/pom.xml 2007-12-27 18:46:57 UTC (rev 5044)
@@ -0,0 +1,57 @@
+<?xml version="1.0"?><project>
+ <parent>
+ <artifactId>ui</artifactId>
+ <groupId>org.richfaces.sandbox</groupId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces</groupId>
+ <artifactId>pickList</artifactId>
+ <name>pickList</name>
+ <version>3.2.0-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <library>
+ <prefix>org.richfaces</prefix>
+ <taglib>
+ <shortName>pickList</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-impl</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_07</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
16 years, 5 months
JBoss Rich Faces SVN: r5043 - in trunk/sandbox/samples: pickList-sample and 13 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-12-27 13:34:04 -0500 (Thu, 27 Dec 2007)
New Revision: 5043
Added:
trunk/sandbox/samples/pickList-sample/
trunk/sandbox/samples/pickList-sample/pom.xml
trunk/sandbox/samples/pickList-sample/src/
trunk/sandbox/samples/pickList-sample/src/main/
trunk/sandbox/samples/pickList-sample/src/main/java/
trunk/sandbox/samples/pickList-sample/src/main/java/org/
trunk/sandbox/samples/pickList-sample/src/main/java/org/richfaces/
trunk/sandbox/samples/pickList-sample/src/main/java/org/richfaces/Bean.java
trunk/sandbox/samples/pickList-sample/src/main/resources/
trunk/sandbox/samples/pickList-sample/src/main/webapp/
trunk/sandbox/samples/pickList-sample/src/main/webapp/META-INF/
trunk/sandbox/samples/pickList-sample/src/main/webapp/META-INF/MANIFEST.MF
trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/
trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/web.xml
trunk/sandbox/samples/pickList-sample/src/main/webapp/index.jsp
trunk/sandbox/samples/pickList-sample/src/main/webapp/pages/
trunk/sandbox/samples/pickList-sample/src/main/webapp/pages/index.jsp
trunk/sandbox/samples/pickList-sample/src/test/
trunk/sandbox/samples/pickList-sample/src/test/java/
trunk/sandbox/samples/pickList-sample/src/test/java/org/
trunk/sandbox/samples/pickList-sample/src/test/java/org/richfaces/
trunk/sandbox/samples/pickList-sample/src/test/java/org/richfaces/BeanTest.java
Log:
initial commit
Added: trunk/sandbox/samples/pickList-sample/pom.xml
===================================================================
--- trunk/sandbox/samples/pickList-sample/pom.xml (rev 0)
+++ trunk/sandbox/samples/pickList-sample/pom.xml 2007-12-27 18:34:04 UTC (rev 5043)
@@ -0,0 +1,64 @@
+<?xml version="1.0"?><project>
+ <parent>
+ <artifactId>samples</artifactId>
+ <groupId>org.richfaces.sandbox</groupId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces</groupId>
+ <artifactId>pickList-sample</artifactId>
+ <packaging>war</packaging>
+ <name>JSF Maven Webapp</name>
+ <version>1.0-SNAPSHOT</version>
+ <build>
+ <finalName>webapp</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.1</version>
+ <configuration>
+ <scanIntervalSeconds>10</scanIntervalSeconds>
+ <connectors>
+ <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
+ <port>8080</port>
+ <maxIdleTime>60000</maxIdleTime>
+ </connector>
+ </connectors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>mortbay-repo</id>
+ <name>mortbay-repo</name>
+ <url>http://www.mortbay.org/maven2/snapshot</url>
+ </pluginRepository>
+ <pluginRepository>
+ <id>repository.jboss.com</id>
+ <name>Jboss Repository for Maven Artifacts</name>
+ <url>http://repository.jboss.com/maven2</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.samples</groupId>
+ <artifactId>skins</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>core</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.richfaces.sandbox.ui</groupId>
+ <artifactId>pickList</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: trunk/sandbox/samples/pickList-sample/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox/samples/pickList-sample/src/main/java/org/richfaces/Bean.java (rev 0)
+++ trunk/sandbox/samples/pickList-sample/src/main/java/org/richfaces/Bean.java 2007-12-27 18:34:04 UTC (rev 5043)
@@ -0,0 +1,29 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - 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;
+/**
+ * @author $Autor$
+ *
+ */
+public class Bean {
+
+}
\ No newline at end of file
Added: trunk/sandbox/samples/pickList-sample/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- trunk/sandbox/samples/pickList-sample/src/main/webapp/META-INF/MANIFEST.MF (rev 0)
+++ trunk/sandbox/samples/pickList-sample/src/main/webapp/META-INF/MANIFEST.MF 2007-12-27 18:34:04 UTC (rev 5043)
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
Added: trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/faces-config.xml 2007-12-27 18:34:04 UTC (rev 5043)
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+<faces-config>
+ <managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>org.richfaces.Bean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+</faces-config>
Added: trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/sandbox/samples/pickList-sample/src/main/webapp/WEB-INF/web.xml 2007-12-27 18:34:04 UTC (rev 5043)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>Archetype Created Web Application</display-name>
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Added: trunk/sandbox/samples/pickList-sample/src/main/webapp/index.jsp
===================================================================
--- trunk/sandbox/samples/pickList-sample/src/main/webapp/index.jsp (rev 0)
+++ trunk/sandbox/samples/pickList-sample/src/main/webapp/index.jsp 2007-12-27 18:34:04 UTC (rev 5043)
@@ -0,0 +1,13 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+
+<html>
+
+<head></head>
+
+ <body>
+
+ <jsp:forward page="/pages/index.jsf" />
+
+ </body>
+
+</html>
\ No newline at end of file
Added: trunk/sandbox/samples/pickList-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/pickList-sample/src/main/webapp/pages/index.jsp (rev 0)
+++ trunk/sandbox/samples/pickList-sample/src/main/webapp/pages/index.jsp 2007-12-27 18:34:04 UTC (rev 5043)
@@ -0,0 +1,17 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://labs.jboss.com/jbossrichfaces/ui/ui/pickList" prefix="pickList"%>
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <pickList:pickList>
+ <f:selectItem itemValue="test" itemLabel="cats"/>
+ <f:selectItem itemValue="test" itemLabel="dogs"/>
+ </pickList:pickList>
+
+ </f:view>
+ </body>
+</html>
Added: trunk/sandbox/samples/pickList-sample/src/test/java/org/richfaces/BeanTest.java
===================================================================
--- trunk/sandbox/samples/pickList-sample/src/test/java/org/richfaces/BeanTest.java (rev 0)
+++ trunk/sandbox/samples/pickList-sample/src/test/java/org/richfaces/BeanTest.java 2007-12-27 18:34:04 UTC (rev 5043)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - 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;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+*/
+public class BeanTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public BeanTest( String testName )
+ {
+ super( testName );
+ }
+
+ public void testStub() throws Exception {
+
+ }
+}
16 years, 5 months
JBoss Rich Faces SVN: r5042 - in trunk/sandbox/ui: pickList and 17 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-12-27 13:32:54 -0500 (Thu, 27 Dec 2007)
New Revision: 5042
Added:
trunk/sandbox/ui/pickList/
trunk/sandbox/ui/pickList/src/
trunk/sandbox/ui/pickList/src/main/
trunk/sandbox/ui/pickList/src/main/config/
trunk/sandbox/ui/pickList/src/main/config/component/
trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml
trunk/sandbox/ui/pickList/src/main/java/
trunk/sandbox/ui/pickList/src/main/java/org/
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/
trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
trunk/sandbox/ui/pickList/src/main/resources/
trunk/sandbox/ui/pickList/src/main/resources/org/
trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/
trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/
trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/
trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/
trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/picklist.js
Log:
initial commit
Added: trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml
===================================================================
--- trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/config/component/picklist.xml 2007-12-27 18:32:54 UTC (rev 5042)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
+<components>
+ <component>
+ <name>org.richfaces.PickList</name>
+ <family>org.richfaces.PickList</family>
+ <classname>
+ org.richfaces.component.html.HtmlPickList
+ </classname>
+ <superclass>org.richfaces.component.UIPickList</superclass>
+ <test>
+ <classname>org.richfaces.component.html.HtmlPickListComponentTest</classname>
+ <superclassname>org.ajax4jsf.tests.AbstractAjax4JsfTestCase</superclassname>
+ </test>
+ <description>
+ <![CDATA[ ]]>
+ </description>
+ <renderer generate="false" override="false">
+ <name>org.richfaces.PickList</name>
+ <classname>org.richfaces.renderkit.PickListRenderer</classname>
+ </renderer>
+
+ <tag>
+ <name>pickList</name>
+ <classname>org.richfaces.taglib.PickListTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+ </tag>
+
+ <properties>
+ <property>
+ <name>displayValueOnly</name>
+ <classname>boolean</classname>
+ <defaultvalue>false</defaultvalue>
+ </property>
+ <property>
+ <name>displayValueOnlyStyle</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>""</defaultvalue>
+ </property>
+ <property>
+ <name>displayValueOnlyStyleClass</name>
+ <classname>java.lang.String</classname>
+ <defaultvalue>""</defaultvalue>
+ </property>
+ <property>
+ <name>size</name>
+ <classname>int</classname>
+ </property>
+ <property hidden="true">
+ <name>selectedValues</name>
+ <classname>java.lang.Object</classname>
+ </property>
+
+ </properties>
+
+ </component>
+</components>
Added: trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java
===================================================================
--- trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/java/org/richfaces/component/UIPickList.java 2007-12-27 18:32:54 UTC (rev 5042)
@@ -0,0 +1,35 @@
+package org.richfaces.component;
+
+import javax.faces.component.UISelectMany;
+import javax.faces.context.FacesContext;
+
+public abstract class UIPickList extends UISelectMany{
+
+ @Override
+ public String getClientId(FacesContext context) {
+ //TODO forceId?
+ return super.getClientId(context);
+ }
+
+ @Override
+ public boolean isRendered() {
+ // TODO userRoles?
+ return super.isRendered();
+ }
+
+ public abstract boolean isDisplayValueOnly();
+ public abstract void setDisplayValueOnly(boolean displayValueOnly);
+
+ public abstract String getDisplayValueOnlyStyle();
+ public abstract void setDisplayValueOnlyStyle(String style);
+
+ public abstract String getDisplayValueOnlyStyleClass();
+ public abstract void setDisplayValueOnlyStyleClass(String styleClass);
+
+ public abstract int getSize();
+ public abstract void setSize(int size);
+
+ public abstract boolean isDisabled();
+ public abstract void setDisabled(boolean disabled);
+
+}
Added: trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java
===================================================================
--- trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/java/org/richfaces/picklist/util/PickListUtils.java 2007-12-27 18:32:54 UTC (rev 5042)
@@ -0,0 +1,281 @@
+package org.richfaces.picklist.util;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UISelectMany;
+import javax.faces.component.UISelectOne;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.el.ValueBinding;
+import javax.faces.model.SelectItem;
+
+import org.ajax4jsf.util.SelectUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+
+
+
+public class PickListUtils {
+
+ private static final Log log = LogFactory.getLog(PickListUtils.class);
+ public static final Object NOTHING = new Serializable() {};
+
+ public static Converter findUISelectManyConverter(FacesContext context, UISelectMany component) {
+
+ Converter converter = component.getConverter();
+
+ if (converter != null) return converter;
+ //Try to find out by value binding
+ ValueBinding vb = component.getValueBinding("value");
+ if (vb == null) return null;
+
+ Class valueType = vb.getType(context);
+ if (valueType == null) return null;
+
+ if (List.class.isAssignableFrom(valueType)) {
+ List selectItems = SelectUtils.getSelectItems(context, component);
+
+ if (selectItems != null && selectItems.size() > 0) {
+ SelectItem selectItem = (SelectItem) selectItems.get(0);
+ Class listComponentType = selectItem.getValue().getClass();
+
+ if (!(String.class.equals(listComponentType))) {
+ try {
+ return context.getApplication().createConverter(listComponentType);
+ }
+ catch (FacesException e) {
+ log.error("No Converter for type " + listComponentType.getName() + " found", e);
+ return null;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ if (!valueType.isArray()) {
+ throw new IllegalArgumentException("ValueBinding for UISelectMany : must be of type List or Array");
+ }
+
+ Class arrayComponentType = valueType.getComponentType();
+ if (String.class.equals(arrayComponentType)) return null; //No converter needed for String type
+ if (Object.class.equals(arrayComponentType)) return null; //There is no converter for Object class
+
+ try {
+ return context.getApplication().createConverter(arrayComponentType);
+ } catch (FacesException e) {
+ log.error("No Converter for type " + arrayComponentType.getName() + " found", e);
+ return null;
+ }
+ }
+
+ public static Converter findUISelectManyConverterFailsafe(FacesContext facesContext, UIComponent uiComponent) {
+ Converter converter;
+ try {
+ converter = findUISelectManyConverter(
+ facesContext, (UISelectMany) uiComponent);
+ }
+ catch (FacesException e) {
+ log.error("Error finding Converter for component with id "
+ + uiComponent.getClientId(facesContext), e);
+ converter = null;
+ }
+ return converter;
+ }
+
+ public static Set getSubmittedOrSelectedValuesAsSet(boolean selectMany, UIComponent uiComponent, FacesContext facesContext, Converter converter) {
+ Set lookupSet;
+
+ if (selectMany) {
+ UISelectMany uiSelectMany = (UISelectMany) uiComponent;
+ lookupSet = getSubmittedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
+ if (lookupSet == null) {
+ lookupSet = getSelectedValuesAsSet(facesContext, uiComponent, converter, uiSelectMany);
+ }
+ }
+ else {
+ UISelectOne uiSelectOne = (UISelectOne) uiComponent;
+ Object lookup = uiSelectOne.getSubmittedValue();
+ if (lookup == null) {
+ lookup = uiSelectOne.getValue();
+ String lookupString = getConvertedStringValue(facesContext, uiComponent, converter, lookup);
+ lookupSet = Collections.singleton(lookupString);
+ }
+ else if (NOTHING.equals(lookup)) {
+ lookupSet = Collections.EMPTY_SET;
+ }
+ else {
+ lookupSet = Collections.singleton(lookup);
+ }
+ }
+ return lookupSet;
+ }
+
+ public static Set getSubmittedValuesAsSet(FacesContext context, UIComponent component, Converter converter, UISelectMany uiSelectMany) {
+ Object submittedValues = uiSelectMany.getSubmittedValue();
+ if (submittedValues == null) {
+ return null;
+ }
+
+ if(converter != null) {
+ converter = new PassThroughAsStringConverter(converter);
+ }
+
+ return internalSubmittedOrSelectedValuesAsSet(context, component, converter, uiSelectMany, submittedValues);
+ }
+
+ private static class PassThroughAsStringConverter implements Converter {
+ private final Converter converter;
+
+ public PassThroughAsStringConverter(Converter converter) {
+ this.converter = converter;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException {
+ return converter.getAsObject(context, component, value);
+ }
+
+ public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
+ return (String)value;
+ }
+
+ }
+
+ public static Set getSelectedValuesAsSet(FacesContext context, UIComponent component, Converter converter, UISelectMany uiSelectMany) {
+ Object selectedValues = uiSelectMany.getValue();
+ return internalSubmittedOrSelectedValuesAsSet(context, component, converter, uiSelectMany, selectedValues);
+ }
+
+ private static Set internalSubmittedOrSelectedValuesAsSet(FacesContext context, UIComponent component, Converter converter, UISelectMany uiSelectMany,Object values) {
+
+ if (values == null || "".equals(values)) {
+ return Collections.EMPTY_SET;
+ } else if (values instanceof Object[]) {
+ //Object array
+ Object[] ar = (Object[]) values;
+ if (ar.length == 0) {
+ return Collections.EMPTY_SET;
+ }
+
+ HashSet set = new HashSet(calcCapacity(ar.length));
+ for (int i = 0; i < ar.length; i++) {
+ set.add(getConvertedStringValue(context, component, converter, ar[i]));
+ }
+ return set;
+ } else if (values.getClass().isArray()) {
+ //primitive array
+ int len = Array.getLength(values);
+ HashSet set = new HashSet(calcCapacity(len));
+ for (int i = 0; i < len; i++) {
+ set.add(getConvertedStringValue(context, component, converter, Array.get(values, i)));
+ }
+ return set;
+ } else if (values instanceof List) {
+ List lst = (List) values;
+ if (lst.size() == 0) {
+ return Collections.EMPTY_SET;
+ } else {
+ HashSet set = new HashSet(calcCapacity(lst.size()));
+ for (Iterator i = lst.iterator(); i.hasNext();) {
+ set.add(getConvertedStringValue(context, component, converter, i.next()));
+ }
+ return set;
+ }
+ } else {
+ throw new IllegalArgumentException("Value of UISelectMany component : is not of type Array or List");
+ }
+ }
+
+ public static final int calcCapacity(int size) {
+ return ((size * 4) + 3) / 3;
+ }
+
+ public static String getConvertedStringValue(FacesContext context, UIComponent component, Converter converter, Object value) {
+ if (converter == null) {
+ if (value == null) {
+ return "";
+ } else if (value instanceof String) {
+ return (String) value;
+ } else {
+ throw new IllegalArgumentException(
+ "Value is not String (class=" + value.getClass().getName() + ", value=" + value + ") and component "
+ + component.getClientId(context) + " does not have a Converter");
+ }
+ }
+
+ return converter.getAsString(context, component, value);
+ }
+// public static boolean renderHTMLAttributes(ResponseWriter writer,
+// UIComponent component, String[] attributes) throws IOException {
+// boolean somethingDone = false;
+// for (int i = 0, len = attributes.length; i < len; i++) {
+// String attrName = attributes[i];
+// if (renderHTMLAttribute(writer, component, attrName, attrName)) {
+// somethingDone = true;
+// }
+// }
+// return somethingDone;
+// }
+//
+// public static boolean renderHTMLAttribute(ResponseWriter writer,
+// UIComponent component, String componentProperty, String htmlAttrName) throws IOException {
+// Object value = component.getAttributes().get(componentProperty);
+// return renderHTMLAttribute(writer, componentProperty, htmlAttrName, value);
+// }
+//
+// public static boolean renderHTMLAttribute(ResponseWriter writer,
+// String componentProperty, String attrName, Object value) throws IOException {
+// if (!isDefaultAttributeValue(value)) {
+// // render JSF "styleClass" and "itemStyleClass" attributes as "class"
+// String htmlAttrName =
+// attrName.equals("styleClass") ? "class" : attrName;
+// writer.writeAttribute(htmlAttrName, value, componentProperty);
+// return true;
+// }
+//
+// return false;
+// }
+//
+// public static boolean isDefaultAttributeValue(Object value) {
+// if (value == null) {
+// return true;
+// }
+// else if (value instanceof Boolean) {
+// return !((Boolean) value).booleanValue();
+// }
+// else if (value instanceof Number) {
+// if (value instanceof Integer) {
+// return ((Number) value).intValue() == Integer.MIN_VALUE;
+// }
+// else if (value instanceof Double) {
+// return ((Number) value).doubleValue() == Double.MIN_VALUE;
+// }
+// else if (value instanceof Long) {
+// return ((Number) value).longValue() == Long.MIN_VALUE;
+// }
+// else if (value instanceof Byte) {
+// return ((Number) value).byteValue() == Byte.MIN_VALUE;
+// }
+// else if (value instanceof Float) {
+// return ((Number) value).floatValue() == Float.MIN_VALUE;
+// }
+// else if (value instanceof Short) {
+// return ((Number) value).shortValue() == Short.MIN_VALUE;
+// }
+// }
+// return false;
+// }
+
+}
Added: trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
===================================================================
--- trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2007-12-27 18:32:54 UTC (rev 5042)
@@ -0,0 +1,238 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
+import javax.faces.model.SelectItem;
+import javax.faces.model.SelectItemGroup;
+
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.util.SelectUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.richfaces.component.UIPickList;
+import org.richfaces.picklist.util.PickListUtils;
+
+public class PickListRenderer extends HeaderResourcesRendererBase {
+
+ private static final String AVAILABLE_SUFFIX = "_AVAILABLE";
+ private static final String SELECTED_SUFFIX = "_SELECTED";
+ private static final String HIDDEN_SUFFIX = "_HIDDEN";
+ private static final String FUNCTION_ADD_TO_SELECTED = "myfaces_picklist_addToSelected";
+ private static final String FUNCTION_REMOVE_FROM_SELECTED = "myfaces_picklist_removeFromSelected";
+ private final InternetResource[] scripts = {getResource("/org/richfaces/renderkit/html/scripts/picklist.js")};
+
+
+ protected InternetResource[] getScripts() {
+ return scripts;
+ }
+
+ protected List selectItemsForSelectedList(FacesContext facesContext,UIComponent uiComponent, List selectItemList, Converter converter, Set lookupSet) {
+ List selectItemForSelectedValues = new ArrayList(lookupSet.size());
+ for (Iterator i = selectItemList.iterator(); i.hasNext();) {
+ SelectItem selectItem = (SelectItem) i.next();
+ String itemStrValue = PickListUtils.getConvertedStringValue(facesContext, uiComponent,converter, selectItem.getValue());
+ for (Iterator i2 = lookupSet.iterator(); i2.hasNext();) {
+ Object value = i2.next();
+ if (value.equals(itemStrValue)) {
+ selectItemForSelectedValues.add(selectItem);
+ }
+ }
+ }
+ return selectItemForSelectedValues;
+ }
+
+ protected List selectItemsForAvailableList(FacesContext facesContext, UIComponent uiComponent, List selectItemList, List selectItemsForSelectedList, Converter converter) {
+ return new ArrayList(CollectionUtils.subtract(selectItemList, selectItemsForSelectedList));
+ }
+
+ protected List getSelectItemsList(FacesContext context,UIComponent component) {
+ return SelectUtils.getSelectItems(context, component);
+ }
+
+ private void encodeSelect(FacesContext facesContext, UIComponent uiComponent, String clientId, boolean disabled,
+ int size, List selectItemsToDisplay, Converter converter, ResponseWriter writer) throws IOException {
+
+ writer.startElement("select", uiComponent);
+ writer.writeAttribute("id", clientId, "id");
+ writer.writeAttribute("name", clientId, null);
+ writer.writeAttribute("multiple", "true", null);
+
+ if (size == 0) {
+ writer.writeAttribute("size", Integer.toString(selectItemsToDisplay.size()), null);
+ } else {
+ writer.writeAttribute("size", Integer.toString(size), null);
+ }
+ if (disabled) {
+ writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
+ }
+
+ renderSelectOptions(facesContext, uiComponent, converter, Collections.EMPTY_SET, selectItemsToDisplay);
+ writer.writeText("", null);
+ writer.endElement("select");
+ }
+
+ public void renderSelectOptions(FacesContext context, UIComponent component, Converter converter, Set lookupSet,
+ List selectItemList) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ for (Iterator it = selectItemList.iterator(); it.hasNext();) {
+ SelectItem selectItem = (SelectItem) it.next();
+
+ if (selectItem instanceof SelectItemGroup) {
+ writer.startElement("optgroup", component);
+ writer.writeAttribute("label", selectItem.getLabel(), null);
+ SelectItem[] selectItems = ((SelectItemGroup) selectItem).getSelectItems();
+ renderSelectOptions(context, component, converter, lookupSet, Arrays.asList(selectItems));
+ writer.endElement("optgroup");
+ } else {
+ String itemStrValue = PickListUtils.getConvertedStringValue(context, component, converter, selectItem.getValue());
+ writer.write('\t');
+ writer.startElement("option", component);
+
+ if (itemStrValue != null) {
+ writer.writeAttribute(HTML.value_ATTRIBUTE, itemStrValue, null);
+ }
+
+ if (lookupSet.contains(itemStrValue))
+ { //TODO/FIX: we always compare the String vales, better fill lookupSet with Strings only when useSubmittedValue==true, else use the real item value Objects
+ writer.writeAttribute("selected", "selected", null);
+ }
+
+ boolean disabled = selectItem.isDisabled();
+ if (disabled) {
+ writer.writeAttribute(HTML.DISABLED_ATTR, HTML.DISABLED_ATTR, null);
+ }
+
+ String labelClass;
+ boolean componentDisabled = ((Boolean)component.getAttributes().get("disabled")).booleanValue();
+
+ if (componentDisabled || disabled) {
+ labelClass = (String) component.getAttributes().get("disabledClass");
+ } else {
+ labelClass = (String) component.getAttributes().get("enabled");
+ }
+
+ if (labelClass != null) {
+ writer.writeAttribute("class", labelClass, "labelClass");
+ }
+
+ Boolean booleanValue = (Boolean)component.getAttributes().get("escape");
+ boolean escape = booleanValue != null ? booleanValue.booleanValue():true; //default is to escape
+
+ if (escape) {
+ writer.writeText(selectItem.getLabel(), null);
+ } else {
+ writer.write(selectItem.getLabel());
+ }
+
+ writer.endElement("option");
+ }
+ }
+ }
+
+ @Override
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+
+ UIPickList picklist = (UIPickList) component;
+
+ String availableListClientId = picklist.getClientId(context) + AVAILABLE_SUFFIX;
+ String selectedListClientId = picklist.getClientId(context) + SELECTED_SUFFIX;
+ String hiddenFieldCliendId = picklist.getClientId(context) + HIDDEN_SUFFIX;
+
+ List selectItemList = SelectUtils.getSelectItems(context,picklist);
+ Converter converter = PickListUtils.findUISelectManyConverterFailsafe(context, picklist);
+ Set lookupSet = PickListUtils.getSubmittedOrSelectedValuesAsSet(true, picklist, context, converter);
+ List selectItemsForSelectedValues = selectItemsForSelectedList(context, picklist, selectItemList, converter, lookupSet);
+ List selectItemsForAvailableList = selectItemsForAvailableList(context, picklist, selectItemList, selectItemsForSelectedValues, converter);
+
+ writer.startElement("table", picklist);
+ writer.startElement(HTML.TR_ELEMENT, picklist);
+ writer.startElement(HTML.td_ELEM, picklist);
+
+ encodeSelect(context, picklist, availableListClientId, picklist.isDisabled(), picklist.getSize(), selectItemsForAvailableList, converter, writer);
+
+ writer.endElement(HTML.td_ELEM);
+
+ // encode buttons
+ writer.startElement(HTML.td_ELEM, picklist);
+
+ String javascriptAddToSelected = FUNCTION_ADD_TO_SELECTED + "('"
+ + availableListClientId + "','" + selectedListClientId + "','"
+ + hiddenFieldCliendId + "')";
+ String javascriptRemoveFromSelected = FUNCTION_REMOVE_FROM_SELECTED
+ + "('" + availableListClientId + "','" + selectedListClientId
+ + "','" + hiddenFieldCliendId + "')";
+
+ encodeSwapButton(context, picklist, javascriptAddToSelected,">",writer);
+
+ writer.startElement("br", picklist);
+ writer.endElement("br");
+
+ encodeSwapButton(context, picklist, javascriptRemoveFromSelected, "<", writer);
+
+ writer.endElement(HTML.td_ELEM);
+
+ // encode selected list
+ writer.startElement(HTML.td_ELEM, picklist);
+
+ encodeSelect(context, picklist, selectedListClientId, picklist.isDisabled(), picklist.getSize(),
+ selectItemsForSelectedValues, converter, writer);
+
+ // hidden field with the selected values
+ encodeHiddenField(context, picklist, hiddenFieldCliendId, lookupSet,writer);
+
+ writer.endElement(HTML.td_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
+ writer.endElement("table");
+ }
+
+ private void encodeSwapButton(FacesContext facesContext, UIComponent uiComponent, String javaScriptFunction,
+ String text,ResponseWriter writer) throws IOException {
+
+ writer.startElement(HTML.INPUT_ELEM, uiComponent);
+ writer.writeAttribute(HTML.TYPE_ATTR,"button","type");
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, javaScriptFunction, null);
+ writer.writeAttribute(HTML.value_ATTRIBUTE, text, null);
+ writer.endElement(HTML.INPUT_ELEM);
+ }
+
+ private void encodeHiddenField(FacesContext facesContext, UIComponent component,
+ String hiddenFieldCliendId, Set lookupSet, ResponseWriter writer) throws IOException {
+
+ writer.startElement(HTML.INPUT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "hidden", "type");
+ writer.writeAttribute(HTML.id_ATTRIBUTE, hiddenFieldCliendId, "id");
+ writer.writeAttribute("name", hiddenFieldCliendId, null);
+
+ StringBuffer sb = new StringBuffer();
+ int n = 0;
+ for (Iterator i = lookupSet.iterator(); i.hasNext();) {
+ if (n > 0) {
+ sb.append(",");
+ }
+ String value = (String) i.next();
+ sb.append(value);
+ n++;
+ }
+
+ writer.writeAttribute(HTML.value_ATTRIBUTE, sb.toString(), null);
+ writer.endElement(HTML.INPUT_ELEM);
+
+ }
+
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIPickList.class;
+ }
+ }
Added: trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/picklist.js
===================================================================
--- trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/picklist.js (rev 0)
+++ trunk/sandbox/ui/pickList/src/main/resources/org/richfaces/renderkit/html/scripts/picklist.js 2007-12-27 18:32:54 UTC (rev 5042)
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ /**
+ * @author Bruno Aranda (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+// moves an item to the selected list
+function myfaces_picklist_addToSelected(availableListId, selectedListId, hiddenId)
+{
+ var availableList = document.getElementById(availableListId);
+ var selectedList = document.getElementById(selectedListId);
+
+ myfaces_picklist_move(availableList, selectedList, hiddenId);
+ myfaces_picklist_updateHidden(selectedList, hiddenId);
+}
+
+// removes an item from the selected list
+function myfaces_picklist_removeFromSelected(availableListId, selectedListId, hiddenId)
+{
+ var availableList = document.getElementById(availableListId);
+ var selectedList = document.getElementById(selectedListId);
+
+ myfaces_picklist_move(selectedList, availableList, hiddenId);
+ myfaces_picklist_updateHidden(selectedList, hiddenId);
+}
+
+function myfaces_picklist_move(fromList, toList, hiddenId) {
+ // Return, if no items selected
+ var selectedIndex = fromList.selectedIndex;
+ if(selectedIndex < 0) { return; }
+
+ // Decremental loop, so the index is not affected in the moves
+ for(var i = fromList.length - 1; i >= 0; i--) {
+ if(fromList.options.item(i).selected) {
+ toList.appendChild(fromList.options.item(i));
+ }
+ }
+
+}
+
+// Selection - invoked on submit
+function myfaces_picklist_updateHidden(selectedList, hiddenId) {
+ var hiddenField = document.getElementById(hiddenId);
+
+ var arrValues = new Array(selectedList.options.length);
+ for (var i = 0; i<selectedList.options.length; i++) {
+ arrValues[i] = selectedList.options[i].value;
+ }
+
+ hiddenField.value = arrValues.join();
+}
\ No newline at end of file
16 years, 5 months
JBoss Rich Faces SVN: r5041 - in trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html: scripts and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2007-12-27 12:43:13 -0500 (Thu, 27 Dec 2007)
New Revision: 5041
Modified:
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
Log:
RF-1725
Modified: trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss
===================================================================
--- trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-12-27 16:31:16 UTC (rev 5040)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/css/calendar.xcss 2007-12-27 17:43:13 UTC (rev 5041)
@@ -273,7 +273,7 @@
<u:style name="vertical-align" value="middle"/>
</u:selector>
- <u:selector name=".rich-calendar-time-shadow">
+ <u:selector name=".rich-calendar-editor-shadow">
<u:style name="background" skin="tableBackgroundColor"/>
<u:style name="opacity" value="0.5"/>
<u:style name="filter" value="alpha(opacity=50)"/>
@@ -286,7 +286,7 @@
<u:style name="position" value="relative"/>
</u:selector>
- <u:selector name=".rich-calendar-time-layout-container">
+ <u:selector name=".rich-calendar-editor-container">
</u:selector>
<u:selector name=".rich-calendar-time-layout, .rich-calendar-time-layout input">
@@ -382,11 +382,30 @@
<u:style name="border-right-color" skin="subBorderColor" />
</u:selector>
- <u:selector name=".rich-calendar-time-layout-shadow">
+ <u:selector name=".rich-calendar-editor-layout-shadow">
<u:style name="background-color" skin="shadowBackgroundColor" />
<u:style name="opacity" value="0.3" />
<u:style name="filter" value="alpha(opacity=30)"/>
<u:style name="position" value="absolute"/>
</u:selector>
+
+ <u:selector name=".rich-calendar-editor-btn">
+ <u:style name="width" value="40px" />
+ <u:style name="padding" value="2px" />
+ <u:style name="text-align" value="center"/>
+ </u:selector>
+ <u:selector name=".rich-calendar-editor-btn-over">
+ <u:style name="padding" value="1px" />
+ <u:style name="border" value="1px solid"/>
+ <u:style name="border-color" skin="panelBorderColor"/>
+ <u:style name="cursor" value="pointer"/>
+ </u:selector>
+
+ <u:selector name=".rich-calendar-editor-btn-selected">
+ <u:style name="background-color" skin="calendarCurrentBackgroundColor" />
+ <u:style name="color" skin="calendarCurrentTextColor" />
+ <u:style name="font-weight" value="bold"/>
+ </u:selector>
+
</f:template>
Modified: trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js
===================================================================
--- trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-27 16:31:16 UTC (rev 5040)
+++ trunk/ui/calendar/src/main/resources/org/richfaces/renderkit/html/scripts/calendar.js 2007-12-27 17:43:13 UTC (rev 5041)
@@ -606,12 +606,14 @@
this.POPUP_BUTTON_ID = this.id+'PopupButton';
this.INPUT_DATE_ID = this.id+'InputDate';
this.IFRAME_ID = this.id+'IFrame';
- this.TIME_EDITOR_ID = this.id+'TimeEditor';
- this.TIME_EDITOR_SHADOW_ID = this.id+'TimeEditorShadow';
+ this.EDITOR_ID = this.id+'Editor';
+ this.EDITOR_SHADOW_ID = this.id+'EditorShadow';
this.TIME_EDITOR_LAYOUT_ID = this.id+'TimeEditorLayout';
- this.TIME_EDITOR_LAYOUT_SHADOW_ID = this.id+'TimeEditorLayoutShadow';
+ this.DATE_EDITOR_LAYOUT_ID = this.id+'DateEditorLayout';
+ this.EDITOR_LAYOUT_SHADOW_ID = this.id+'EditorLayoutShadow';
+
//this.popupIntervalId=null;
this.firstDateIndex = 0;
@@ -745,7 +747,81 @@
}
},
+
+ dateEditorSelectYear: function(value)
+ {
+ if (this.dateEditorYearID)
+ {
+ Element.removeClassName(this.dateEditorYearID, 'rich-calendar-editor-btn-selected');
+ }
+ this.dateEditorYear = this.dateEditorStartYear + value;
+ this.dateEditorYearID = this.DATE_EDITOR_LAYOUT_ID+'Y'+value;
+ Element.addClassName(this.dateEditorYearID, 'rich-calendar-editor-btn-selected');
+ },
+
+ dateEditorSelectMonth: function(value)
+ {
+ this.dateEditorMonth = value;
+ Element.removeClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+ this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+value;
+ Element.addClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+ },
+
+ scrollEditorYear: function(value)
+ {
+ var element = $(this.DATE_EDITOR_LAYOUT_ID+'TR');
+ if (this.dateEditorYearID)
+ {
+ Element.removeClassName(this.dateEditorYearID, 'rich-calendar-editor-btn-selected');
+ this.dateEditorYearID='';
+ }
+
+ if (!value)
+ {
+ // update month selection when open editor (value == 0)
+ if (this.dateEditorMonth != this.getCurrentMonth())
+ {
+ this.dateEditorMonth = this.getCurrentMonth();
+ Element.removeClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+ this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+this.dateEditorMonth;
+ Element.addClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+ }
+ }
+
+ if (element)
+ {
+ var div;
+ var year = this.dateEditorStartYear = this.dateEditorStartYear+value*10;
+ for (var i=0;i<5;i++)
+ {
+ element = element.nextSibling;
+ div = element.firstChild.nextSibling.nextSibling;
+ div.firstChild.innerHTML=year;
+ if (year == this.dateEditorYear)
+ {
+ Element.addClassName(div.firstChild, 'rich-calendar-editor-btn-selected');
+ this.dateEditorYearID = div.firstChild.id;
+ }
+ div = div.nextSibling;
+ div.firstChild.innerHTML=year+5;
+ if (year+5 == this.dateEditorYear)
+ {
+ Element.addClassName(div.firstChild, 'rich-calendar-editor-btn-selected');
+ this.dateEditorYearID = div.firstChild.id;
+ }
+ year++;
+ }
+ }
+ },
+
+ updateDateEditor: function()
+ {
+ this.dateEditorYear = this.getCurrentYear();
+ this.dateEditorStartYear = this.getCurrentYear() - 4;
+ this.scrollEditorYear(0);
+ },
+
updateTimeEditor: function()
{
var th=$(this.id+'TimeHours');
@@ -764,18 +840,29 @@
tm.value = (m<10 ? '0'+m : m);
},
- createTimeEditor: function(element)
+
+ createEditor: function()
{
var element = $(this.id);
- var htmlBegin = '<div id="'+this.TIME_EDITOR_SHADOW_ID+'" class="rich-calendar-time-shadow" style="position:absolute; display:none;"></div><table border="0" cellpadding="0" cellspacing="0" id="'+this.TIME_EDITOR_ID+'" style="position:absolute; display:none;"><tbody><tr><td class="rich-calendar-time-layout-container" align="center"><div style="position:relative; width:100%">';
+ var htmlBegin = '<div id="'+this.EDITOR_SHADOW_ID+'" class="rich-calendar-editor-shadow" style="position:absolute; display:none;"></div><table border="0" cellpadding="0" cellspacing="0" id="'+this.EDITOR_ID+'" style="position:absolute; display:none;"><tbody><tr><td class="rich-calendar-editor-container" align="center"><div style="position:relative; width:100%">';
+ var htmlContent = '<div id="'+this.EDITOR_LAYOUT_SHADOW_ID+'" class="rich-calendar-editor-layout-shadow"></div>';
+
var htmlEnd = '</div></td></tr></tbody></table>';
- new Insertion.After(element, htmlBegin+this.evaluateMarkup(CalendarView.timeEditor, this.calendarContext)+htmlEnd);
- var te_shadow = $(this.TIME_EDITOR_SHADOW_ID);
- var te = $(this.TIME_EDITOR_ID);
+ new Insertion.After(element, htmlBegin+htmlContent+htmlEnd);
+ //+this.evaluateMarkup(CalendarView.timeEditor, this.calendarContext)+
+ var editor_shadow = $(this.EDITOR_SHADOW_ID);
+ var editor = $(this.EDITOR_ID);
var zindex = element.getStyle('z-index');
- te_shadow.style.zIndex = zindex;
- te.style.zIndex = parseInt(zindex,10)+1;
+ editor_shadow.style.zIndex = zindex;
+ editor.style.zIndex = parseInt(zindex,10)+1;
+ this.isEditorCreated = true;
+ },
+
+ createTimeEditorLayout: function()
+ {
+ Element.insert(this.EDITOR_LAYOUT_SHADOW_ID, {after:this.evaluateMarkup(this.calendarContext.timeEditorLayout, this.calendarContext)});
+
var th=$(this.id+'TimeHours');
var ts;
var tm=$(this.id+'TimeMinutes');
@@ -791,9 +878,57 @@
}
sbjQuery(tm).SpinButton({digits:2,min:0,max:59});
- this.isTimeEditorCreated = true;
+ this.isTimeEditorLayoutCreated = true;
},
+ createDECell: function(id, value, buttonType, param, className)
+ {
+ var onclick = (buttonType==0 ? '$(\''+this.id+'\').component.scrollEditorYear('+param+');' :
+ buttonType==1 ? '$(\''+this.id+'\').component.dateEditorSelectMonth('+param+');':
+ '$(\''+this.id+'\').component.dateEditorSelectYear('+param+');' );
+ return '<td><div id="'+id+'" class="rich-calendar-editor-btn'+(className ? ' '+className : '')+'" onmouseover="Element.addClassName(this, \'rich-calendar-editor-btn-over\');" onmouseout="Element.removeClassName(this, \'rich-calendar-editor-btn-over\');" onclick="'+onclick+'">'+value+'</div></td>';
+ },
+
+ createDateEditorLayout: function()
+ {
+ var htmlBegin = '<table id="'+this.DATE_EDITOR_LAYOUT_ID+'" class="rich-calendar-time-layout" border="0" cellpadding="0" cellspacing="0"><tbody><tr id="'+this.DATE_EDITOR_LAYOUT_ID+'TR">';
+ var htmlEnd = '</tr></tbody></table>';
+ var month = 0;
+ this.dateEditorYear = this.getCurrentYear();
+ var year = this.dateEditorStartYear = this.dateEditorYear-4;
+ var htmlContent = this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)
+ +this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)
+ +this.createDECell('','<', 0, -1)
+ +this.createDECell('','>', 0, 1);
+ month++;
+
+ for (var i=0;i<5;i++)
+ {
+ htmlContent+='</tr><tr>'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)
+ +this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)
+ +this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+i, year, 2, i, (i==4 ? 'rich-calendar-editor-btn-selected' : ''))
+ +this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+(i+5), year+5, 2, i+5);
+ month++;
+ year++;
+ }
+ this.dateEditorYearID = this.DATE_EDITOR_LAYOUT_ID+'Y4';
+ this.dateEditorMonth = this.getCurrentMonth();
+ this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+this.dateEditorMonth;
+
+ htmlContent+='</tr><tr><td colspan="2" class="rich-calendar-time-layout-ok">'+
+ '<div class="rich-calendar-time-btn" style="float:right;" onmousedown="Element.addClassName(this, \'rich-calendar-time-btn-press\');" onmouseout="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onmouseup="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onclick="$(\''+this.id+'\').component.hideDateEditor(true);">OK</div>'+
+ '</td><td colspan="2" class="rich-calendar-time-layout-cancel">'+
+ '<div class="rich-calendar-time-btn" style="float:left;" onmousedown="Element.addClassName(this, \'rich-calendar-time-btn-press\');" onmouseout="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onmouseup="Element.removeClassName(this, \'rich-calendar-time-btn-press\');" onclick="$(\''+this.id+'\').component.hideDateEditor(false);">Cancel</div>'+
+ '</td>';
+
+
+ Element.insert(this.EDITOR_LAYOUT_SHADOW_ID, {after:htmlBegin+htmlContent+htmlEnd});
+
+ Element.addClassName(this.dateEditorMonthID, 'rich-calendar-editor-btn-selected');
+
+ this.isDateEditorLayoutCreated = true;
+ },
+
createSpinnerTable: function(id) {
return '<table cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
'<td class="rich-calendar-spinner-input-container">'+
@@ -904,7 +1039,7 @@
doCollapse: function() {
if (!this.params.popup || !this.isVisible) return;
- if (this.isTimeEditorCreated) this.hideTimeEditor();
+ if (this.isEditorVisible) this.hideEditor();
/*this.stopTimer();
this.stopPopupEvents($(this.id));
@@ -1582,22 +1717,34 @@
},
nextMonth: function() {
- this.changeCurrentDate(0,1);
+ this.changeCurrentDateOffset(0,1);
},
prevMonth: function() {
- this.changeCurrentDate(0,-1);
+ this.changeCurrentDateOffset(0,-1);
},
nextYear: function() {
- this.changeCurrentDate(1,0);
+ this.changeCurrentDateOffset(1,0);
},
prevYear: function() {
- this.changeCurrentDate(-1,0);
+ this.changeCurrentDateOffset(-1,0);
},
- changeCurrentDate: function(yearOffset, monthOffset) {
+ changeCurrentDate: function(year, month) {
+ if (this.getCurrentMonth()!=month || this.getCurrentYear()!=year)
+ {
+ var date = new Date(year, month,1);
+ if (this.invokeEvent("currentdateselect", $(this.id), null, date))
+ {
+ this.currentDate = date;
+ this.onUpdate();
+ }
+ }
+ },
+
+ changeCurrentDateOffset: function(yearOffset, monthOffset) {
var date = new Date(this.currentDate.getFullYear()+yearOffset, this.currentDate.getMonth()+monthOffset,1);
if (this.invokeEvent("currentdateselect", $(this.id), null, date))
{
@@ -1605,7 +1752,7 @@
this.onUpdate();
}
},
-
+
today: function(noUpdate, noHighlight) {
var now = new Date();
@@ -1847,35 +1994,51 @@
this.doCollapse();
},
+ setEditorPosition: function (element, editor, shadow)
+ {
+ element;
+
+ var dim = Richfaces.Calendar.getOffsetDimensions(element);
+ editor.style.width = shadow.style.width = dim.width + 'px';
+ editor.style.height = shadow.style.height = dim.height + 'px';
+
+ Richfaces.Calendar.clonePosition([editor,shadow], element);
+ },
+
showTimeEditor: function()
{
if (this.timeType==0) return;
- if (!this.isTimeEditorCreated) this.createTimeEditor();
+ if (!this.isEditorCreated) this.createEditor();
+ if (!this.isTimeEditorLayoutCreated) this.createTimeEditorLayout();
- var element = $(this.id);
+ $(this.TIME_EDITOR_LAYOUT_ID).show();
- var te = $(this.TIME_EDITOR_ID);
- var te_shadow = $(this.TIME_EDITOR_SHADOW_ID);
+ var editor = $(this.EDITOR_ID);
+ var editor_shadow = $(this.EDITOR_SHADOW_ID);
- var dim = Richfaces.Calendar.getOffsetDimensions(element);
- te.style.width = te_shadow.style.width = dim.width + 'px';
- te.style.height = te_shadow.style.height = dim.height + 'px';
+ this.setEditorPosition($(this.id), editor, editor_shadow);
- Richfaces.Calendar.clonePosition([te,te_shadow], element);
-
this.updateTimeEditor();
- te_shadow.show();
- te.show();
+ editor_shadow.show();
+ editor.show();
- Element.clonePosition(this.TIME_EDITOR_LAYOUT_SHADOW_ID, this.TIME_EDITOR_LAYOUT_ID, {offsetLeft: 3, offsetTop: 3});
+ Element.clonePosition(this.EDITOR_LAYOUT_SHADOW_ID, this.TIME_EDITOR_LAYOUT_ID, {offsetLeft: 3, offsetTop: 3});
+ this.isEditorVisible = true;
},
+
+ hideEditor: function()
+ {
+ $(this.EDITOR_ID).hide();
+ $(this.EDITOR_SHADOW_ID).hide();
+ if (this.isTimeEditorLayoutCreated) $(this.TIME_EDITOR_LAYOUT_ID).hide();
+ if (this.isDateEditorLayoutCreated) $(this.DATE_EDITOR_LAYOUT_ID).hide();
+ this.isEditorVisible = false;
+ },
hideTimeEditor: function(updateTime)
{
- $(this.TIME_EDITOR_ID).hide();
- $(this.TIME_EDITOR_SHADOW_ID).hide();
-
+ this.hideEditor();
if (updateTime && this.selectedDate)
{
var m = parseInt($(this.id+'TimeMinutes').value,10);
@@ -1897,6 +2060,36 @@
}
if (this.params.popup && !this.showApplyButton && updateTime) this.close(true);
+ },
+
+ showDateEditor: function()
+ {
+ if (!this.isEditorCreated) this.createEditor();
+ if (!this.isDateEditorLayoutCreated) this.createDateEditorLayout();
+ else this.updateDateEditor();
+
+ $(this.DATE_EDITOR_LAYOUT_ID).show();
+
+ var editor = $(this.EDITOR_ID);
+ var editor_shadow = $(this.EDITOR_SHADOW_ID);
+
+ this.setEditorPosition($(this.id), editor, editor_shadow);
+
+ editor_shadow.show();
+ editor.show();
+
+ Element.clonePosition(this.EDITOR_LAYOUT_SHADOW_ID, this.DATE_EDITOR_LAYOUT_ID, {offsetLeft: 3, offsetTop: 3});
+
+ this.isEditorVisible = true;
+ },
+
+ hideDateEditor: function(updateCurrentDate)
+ {
+ this.hideEditor();
+ if (updateCurrentDate)
+ {
+ this.changeCurrentDate(this.dateEditorYear, this.dateEditorMonth);
+ }
}
});
@@ -1940,7 +2133,7 @@
CalendarView.previousYearControl = CalendarView.getControl("<<", CalendarView.toolButtonAttributes, "prevYear");
CalendarView.nextMonthControl = CalendarView.getControl(">", CalendarView.toolButtonAttributes, "nextMonth");
CalendarView.previousMonthControl = CalendarView.getControl("<", CalendarView.toolButtonAttributes, "prevMonth");
-CalendarView.currentMonthControl = function (context) { return Richfaces.Calendar.formatDate(context.calendar.getCurrentDate(), "MMMM, yyyy", context.monthLabels, context.monthLabelsShort);};
+CalendarView.currentMonthControl = function (context) { return CalendarView.getControl(Richfaces.Calendar.formatDate(context.calendar.getCurrentDate(), "MMMM, yyyy", context.monthLabels, context.monthLabelsShort), CalendarView.toolButtonAttributes, "showDateEditor");};
CalendarView.todayControl = function (context) { return (context.calendar.todayControlMode!='hidden' ? CalendarView.getControl(context.controlLabels.today, CalendarView.toolButtonAttributes, "today") : "");};
CalendarView.selectedDateControl = function (context) { return CalendarView.getSelectedDateControl(context.calendar);};
CalendarView.timeControl = function (context) { return CalendarView.getTimeControl(context.calendar);};
@@ -2018,10 +2211,8 @@
]
)];
-CalendarView.timeEditor = [
+CalendarView.timeEditorLayout = [
- new E('div',{'id': function(context){return context.calendar.TIME_EDITOR_LAYOUT_SHADOW_ID}, 'class': 'rich-calendar-time-layout-shadow'},null),
-
new E('table',{'id': function(context){return context.calendar.TIME_EDITOR_LAYOUT_ID}, 'border': '0', 'cellpadding': '0', 'cellspacing': '0', 'class': 'rich-calendar-time-layout'},
[
new E('tbody',{},
@@ -2081,5 +2272,6 @@
todayControl: CalendarView.todayControl,
closeControl: CalendarView.closeControl,
applyControl: CalendarView.applyControl,
- timeEditorFields: CalendarView.timeEditorFields
+ timeEditorFields: CalendarView.timeEditorFields,
+ timeEditorLayout: CalendarView.timeEditorLayout
});
\ No newline at end of file
16 years, 5 months
JBoss Rich Faces SVN: r5040 - in trunk/ui/calendar/src/main: java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: akushunin
Date: 2007-12-27 11:31:16 -0500 (Thu, 27 Dec 2007)
New Revision: 5040
Modified:
trunk/ui/calendar/src/main/config/component/calendar.xml
trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
Log:
RF-1675
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2007-12-27 15:42:50 UTC (rev 5039)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2007-12-27 16:31:16 UTC (rev 5040)
@@ -60,9 +60,9 @@
disabled
</description>
</property>
- <property elonly="true">
+ <property>
<name>locale</name>
- <classname>java.util.Locale</classname>
+ <classname>java.lang.Object</classname>
<description>Used for locale definition</description>
<defaultvalue>getDefaultLocale()</defaultvalue>
</property>
Modified: trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-12-27 15:42:50 UTC (rev 5039)
+++ trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-12-27 16:31:16 UTC (rev 5040)
@@ -75,9 +75,9 @@
private final static Log log = LogFactory.getLog(UICalendar.class);
- public abstract Locale getLocale();
+ public abstract Object getLocale();
- public abstract void setLocale(Locale locale);
+ public abstract void setLocale(Object locale);
public abstract TimeZone getTimeZone();
@@ -205,7 +205,7 @@
// currentDate processing -------------------------------------------------
public Calendar getCalendar() {
- return Calendar.getInstance(getTimeZone(), getLocale());
+ return Calendar.getInstance(getTimeZone(), getAsLocale(getLocale()));
}
public Date getConvertedValue(FacesContext context, String currentDateString)
@@ -241,7 +241,7 @@
if (vb != null) {
if (vb.getType(context).equals(String.class)) {
DateTimeConverter convert = new DateTimeConverter();
- convert.setLocale(getLocale());
+ convert.setLocale(getAsLocale(getLocale()));
convert.setPattern(getDatePattern());
vb.setValue(context, convert.getAsString(context, this,
currentDate));
@@ -302,7 +302,7 @@
if (date instanceof String) {
DateTimeConverter converter = new DateTimeConverter();
converter.setPattern(this.getDatePattern());
- converter.setLocale(this.getLocale());
+ converter.setLocale(getAsLocale(this.getLocale()));
converter.setTimeZone(this.getTimeZone());
FacesContext context = FacesContext.getCurrentInstance();
return (Date) converter.getAsObject(context, this,
@@ -342,7 +342,7 @@
}
protected Date getDefaultPreloadBegin(Date date) {
- Calendar calendar = Calendar.getInstance(getTimeZone(), getLocale());
+ Calendar calendar = Calendar.getInstance(getTimeZone(), getAsLocale(getLocale()));
calendar.setTime(date);
calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE));
/*
@@ -353,7 +353,7 @@
}
protected Date getDefaultPreloadEnd(Date date) {
- Calendar calendar = Calendar.getInstance(getTimeZone(), getLocale());
+ Calendar calendar = Calendar.getInstance(getTimeZone(), getAsLocale(getLocale()));
calendar.setTime(date);
calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
/*
@@ -525,8 +525,7 @@
List dates = new ArrayList();
- Calendar calendar = Calendar.getInstance(this.getTimeZone(), this
- .getLocale());
+ Calendar calendar = Calendar.getInstance(this.getTimeZone(), getAsLocale(this.getLocale()));
Calendar calendar2 = (Calendar) calendar.clone();
calendar.setTime(dateRangeBegin);
calendar2.setTime(dateRangeEnd);
@@ -552,5 +551,64 @@
CurrentDateChangeListener listener) {
removeFacesListener(listener);
}
+
+ /**
+ *Parse Locale from String.
+ *String must be represented as Locale.toString(); xx_XX_XXXX
+ */
+
+ public Locale parseLocale(String localeStr){
+
+ int length = localeStr.length();
+ if(null==localeStr||length<2){
+ return Locale.getDefault();
+ }
+
+ //Lookup index of first '_' in string locale representation.
+ int index1 = localeStr.indexOf("_");
+ //Get first charters (if exist) from string
+ String language = null;
+ if(index1!=-1){
+ language = localeStr.substring(0, index1);
+ }else{
+ return new Locale(localeStr);
+ }
+ //Lookup index of second '_' in string locale representation.
+ int index2 = localeStr.indexOf("_", index1+1);
+ String country = null;
+ if(index2!=-1){
+ country = localeStr.substring(index1+1, index2);
+ String variant = localeStr.substring(index2+1);
+ return new Locale(language, country, variant);
+ }else{
+ country = localeStr.substring(index1+1);
+ return new Locale(language, country);
+ }
+ }
+
+ public Locale getAsLocale(Object locale) {
+ if (locale instanceof Locale) {
+
+ return (Locale) locale;
+
+ } else if (locale instanceof String) {
+
+ return parseLocale((String) locale);
+
+ } else {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ Application application = context.getApplication();
+ Converter converter = application
+ .createConverter(locale.getClass());
+ if (null != converter) {
+ return parseLocale(converter.getAsString(context, this, locale));
+ } else {
+ throw new FacesException(
+ "Wrong locale attibute type or there is no converter for custom attibute type");
+ }
+ }
+ }
+
}
Modified: trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-12-27 15:42:50 UTC (rev 5039)
+++ trunk/ui/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-12-27 16:31:16 UTC (rev 5040)
@@ -118,7 +118,7 @@
} else {
DateTimeConverter converter = new DateTimeConverter();
converter.setPattern(calendar.getDatePattern());
- converter.setLocale(calendar.getLocale());
+ converter.setLocale(calendar.getAsLocale(calendar.getLocale()));
converter.setTimeZone(calendar.getTimeZone());
return converter.getAsObject(context, component,
(String) submittedValue);
@@ -352,7 +352,8 @@
DateTimeConverter converter = new DateTimeConverter();
converter.setPattern(input.getDatePattern());
- converter.setLocale(input.getLocale());
+ Object locale = input.getLocale();
+ converter.setLocale(input.getAsLocale(locale));
converter.setTimeZone(input.getTimeZone());
if (value == null) {
return converter.getAsString(context, input, curVal);
@@ -395,7 +396,7 @@
protected Map getSymbolsMap(FacesContext facesContext, UICalendar calendar) {
Map map = new HashMap();
- Locale locale = calendar.getLocale();
+ Locale locale = calendar.getAsLocale(calendar.getLocale());
Calendar cal = calendar.getCalendar();
int maximum = cal.getActualMaximum(Calendar.DAY_OF_WEEK);
int minimum = cal.getActualMinimum(Calendar.DAY_OF_WEEK);
@@ -558,11 +559,12 @@
ResourceBundle bundle2 = null;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
String messageBundle = context.getApplication().getMessageBundle();
+ Object locale = calendar.getLocale();
if (null != messageBundle) {
- bundle1 = ResourceBundle.getBundle(messageBundle, calendar.getLocale(), loader);
+ bundle1 = ResourceBundle.getBundle(messageBundle, calendar.getAsLocale(locale), loader);
}
try {
- bundle2 = ResourceBundle.getBundle(CALENDAR_BUNDLE, calendar.getLocale(), loader);
+ bundle2 = ResourceBundle.getBundle(CALENDAR_BUNDLE, calendar.getAsLocale(locale), loader);
} catch (MissingResourceException e) {
//No external bundle was found, ignore this exception.
16 years, 5 months
JBoss Rich Faces SVN: r5039 - management/design/progressBar.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-12-27 10:42:50 -0500 (Thu, 27 Dec 2007)
New Revision: 5039
Modified:
management/design/progressBar/Func-Spec-ProgressBar.doc
Log:
RF-1689 ?\226?\128?\147 progress bar spec update
Modified: management/design/progressBar/Func-Spec-ProgressBar.doc
===================================================================
(Binary files differ)
16 years, 5 months
JBoss Rich Faces SVN: r5038 - management/design/comboBox.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-12-27 10:16:41 -0500 (Thu, 27 Dec 2007)
New Revision: 5038
Modified:
management/design/comboBox/comboBox.doc
Log:
RF-1215-combobox spec update
Modified: management/design/comboBox/comboBox.doc
===================================================================
(Binary files differ)
16 years, 5 months
JBoss Rich Faces SVN: r5037 - management/design/comboBox.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2007-12-27 10:11:08 -0500 (Thu, 27 Dec 2007)
New Revision: 5037
Modified:
management/design/comboBox/comboBox.doc
Log:
RF-1215-combobox spec update
Modified: management/design/comboBox/comboBox.doc
===================================================================
(Binary files differ)
16 years, 5 months