JBoss Rich Faces SVN: r20323 - branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-02 19:28:30 -0500 (Thu, 02 Dec 2010)
New Revision: 20323
Removed:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java
Modified:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java
Log:
RESOLVED - issue RF-9612: Create JSF 2.0 resource loading extension to dynamically add scripts and its dependencies.
https://jira.jboss.org/browse/RF-9612
Modified: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java 2010-12-03 00:26:26 UTC (rev 20322)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java 2010-12-03 00:28:30 UTC (rev 20323)
@@ -8,6 +8,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import javax.faces.application.ResourceDependency;
+
/**
* This annotation describes client-side version of Converter/validator.
* @author asmirnov
@@ -17,10 +19,8 @@
@Target(ElementType.TYPE)
public @interface ClientSideScript {
- String library() default "";
- String resource();
-
String function();
+ ResourceDependency[] resources() default {};
}
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java 2010-12-03 00:26:26 UTC (rev 20322)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java 2010-12-03 00:28:30 UTC (rev 20323)
@@ -1,35 +0,0 @@
-/*
- * $Id$
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.javascript;
-
-/**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface FunctionDefWithDependencies extends ScriptWithDependencies {
-
- String getName();
-
-}
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java 2010-12-03 00:26:26 UTC (rev 20322)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java 2010-12-03 00:28:30 UTC (rev 20323)
@@ -1,14 +0,0 @@
-package org.richfaces.javascript;
-
-import org.ajax4jsf.javascript.ScriptString;
-import org.richfaces.resource.ResourceLibrary;
-
-/**
- * This interface describes JavaScript object with optional dependent resources.
- * @author asmirnov
- *
- */
-public interface ScriptWithDependencies extends ResourceLibrary, ScriptString {
-
-
-}
\ No newline at end of file
13 years, 6 months
JBoss Rich Faces SVN: r20322 - in branches/RF-8742-1/ui/validator/ui/src: main/java/org/richfaces/validator/model and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-02 19:26:26 -0500 (Thu, 02 Dec 2010)
New Revision: 20322
Added:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Resource.java
branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/csv.xml
branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/richfaces/
branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/
branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/ClientValidationTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/CustomValidator.java
branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Component.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
branches/RF-8742-1/ui/validator/ui/src/test/resources/badcsv.xml
branches/RF-8742-1/ui/validator/ui/src/test/resources/csv.xml
branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml
branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml
Log:
CODING IN PROGRESS - issue RF-9799: CSV code review
https://jira.jboss.org/browse/RF-9799
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java 2010-12-03 00:26:26 UTC (rev 20322)
@@ -3,14 +3,19 @@
*/
package org.richfaces.javascript;
+import java.util.List;
import java.util.Map;
import javax.faces.application.Resource;
+import javax.faces.application.ResourceDependency;
import javax.faces.application.ResourceHandler;
import javax.faces.context.FacesContext;
import org.richfaces.component.util.Strings;
+import org.richfaces.resource.ResourceKey;
+import com.google.common.collect.Lists;
+
/**
* @author asmirnov
*
@@ -52,7 +57,11 @@
private LibraryFunction getScriptFromAnnotation(Class<?> javaClass) throws ScriptNotFoundException {
if (javaClass.isAnnotationPresent(ClientSideScript.class)) {
ClientSideScript clientSideScript = javaClass.getAnnotation(ClientSideScript.class);
- return new LibraryFunctionImplementation(clientSideScript.function(), clientSideScript.resource(), clientSideScript.library());
+ List<ResourceKey> resources = Lists.newArrayList();
+ for(ResourceDependency dependency: clientSideScript.resources()){
+ resources.add(ResourceKey.create(dependency.name(),dependency.library()));
+ }
+ return new LibraryFunctionImplementation(clientSideScript.function(), resources);
} else {
throw new ScriptNotFoundException();
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java 2010-12-03 00:26:26 UTC (rev 20322)
@@ -12,11 +12,15 @@
import javax.faces.FacesException;
import javax.xml.bind.JAXB;
+import org.richfaces.resource.ResourceKey;
import org.richfaces.validator.model.ClientSideScripts;
import org.richfaces.validator.model.Component;
+import org.richfaces.validator.model.Resource;
+import com.google.common.base.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
/**
@@ -52,8 +56,15 @@
ClientSideScripts clientSideScripts = JAXB.unmarshal(url, ClientSideScripts.class);
for (Component component : clientSideScripts.getComponent()) {
Class<?> componentClass = loader.loadClass(component.getType());
+ Iterable<ResourceKey> resources = Iterables.transform(component.getResource(), new Function<Resource,ResourceKey>(){
+
+ public ResourceKey apply(Resource from) {
+ return ResourceKey.create(from.getName(),from.getLibrary());
+ }
+
+ });
LibraryFunctionImplementation function = new LibraryFunctionImplementation(component.getFunction(),
- component.getResource(), component.getLibrary());
+ resources);
result.put(componentClass, function);
}
} catch (ClassNotFoundException e) {
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java 2010-12-03 00:26:26 UTC (rev 20322)
@@ -4,13 +4,15 @@
import org.richfaces.resource.ResourceKey;
+import com.google.common.collect.ImmutableList;
+
final class LibraryFunctionImplementation implements LibraryFunction {
private final Iterable<ResourceKey> library;
private final String functionName;
- LibraryFunctionImplementation(String functionName, ResourceKey library) {
- this.library = Collections.singleton(library);
+ LibraryFunctionImplementation(String functionName, Iterable<ResourceKey> dependencies) {
+ this.library = ImmutableList.copyOf(dependencies);
this.functionName = functionName;
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Component.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Component.java 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Component.java 2010-12-03 00:26:26 UTC (rev 20322)
@@ -1,17 +1,18 @@
package org.richfaces.validator.model;
+import java.util.List;
+
import javax.xml.bind.annotation.XmlElement;
+import com.google.common.collect.Lists;
+
public class Component {
private String type;
private String function;
- private String library;
-
- private String resource;
-
+ private List<Resource> resource = Lists.newArrayList();
/**
* @return the type
*/
@@ -43,32 +44,19 @@
}
/**
- * @return the library
- */
- @XmlElement
- public String getLibrary() {
- return library;
- }
-
- /**
- * @param library the library to set
- */
- public void setLibrary(String library) {
- this.library = library;
- }
-
- /**
+ * <p class="changed_added_4_0"></p>
* @return the resource
*/
- @XmlElement
- public String getResource() {
- return resource;
+ public List<Resource> getResource() {
+ return this.resource;
}
/**
+ * <p class="changed_added_4_0"></p>
* @param resource the resource to set
*/
- public void setResource(String resource) {
+ @XmlElement
+ public void setResource(List<Resource> resource) {
this.resource = resource;
}
Added: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Resource.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Resource.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Resource.java 2010-12-03 00:26:26 UTC (rev 20322)
@@ -0,0 +1,45 @@
+package org.richfaces.validator.model;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class Resource {
+
+ private String name;
+
+ private String library;
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ @XmlElement
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the library
+ */
+ @XmlElement
+ public String getLibrary() {
+ return this.library;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param library the library to set
+ */
+ public void setLibrary(String library) {
+ this.library = library;
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/model/Resource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/csv.xml
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/csv.xml (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/csv.xml 2010-12-03 00:26:26 UTC (rev 20322)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<scripts>
+ <component>
+ <type>javax.faces.convert.NumberConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <resource>
+ <name>number-converter.js</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertNumber</function>
+ </component>
+ <component>
+ <type>javax.faces.validator.LengthValidator</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <resource>
+ <name>length-validator.js</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateLength</function>
+ </component>
+</scripts>
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/csv.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties 2010-12-03 00:26:26 UTC (rev 20322)
@@ -0,0 +1 @@
+resources=jquery.js, richfaces.js, richfaces-event.js, org.richfaces:richfaces-csv.js
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/ClientValidationTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/ClientValidationTest.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/ClientValidationTest.java 2010-12-03 00:26:26 UTC (rev 20322)
@@ -0,0 +1,90 @@
+package org.richfaces.component;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+import static org.junit.matchers.JUnitMatchers.*;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.hamcrest.Matcher;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+
+/**
+ * Test for dynamic add/remove {@link UIScripts} as view resource.
+ * @author asmirnov
+ *
+ */
+public class ClientValidationTest {
+
+ private HtmlUnitEnvironment environment;
+
+
+ @Before
+ public void setUp() {
+ this.environment = new HtmlUnitEnvironment();
+ this.environment.withWebRoot("org/richfaces/component/client-test.xhtml").start();
+ }
+
+ @After
+ public void thearDown() throws Exception{
+ environment.release();
+ environment = null;
+ }
+
+ @Test
+ public void testRequest() throws Exception {
+ HtmlPage page = requestPage();
+ HtmlInput input = hetInput(page);
+ assertNotNull(input);
+
+ }
+
+ @Test
+ public void testSubmitTooShortValue() throws Exception {
+ submitValueAndCheckMesage("",containsString("Error"));
+ }
+
+ @Test
+ public void testSubmitTooLongValue() throws Exception {
+ submitValueAndCheckMesage("123456",containsString("Error"));
+ }
+
+ @Test
+ public void testSubmitProperValue() throws Exception {
+ submitValueAndCheckMesage("ab",equalTo(""));
+ }
+
+ private void submitValueAndCheckMesage(String value, Matcher<String> matcher) throws Exception {
+ HtmlPage page = requestPage();
+ HtmlInput input = hetInput(page);
+ input.setValueAttribute(value);
+ input.fireEvent("keyup");
+ HtmlElement message = page.getElementById("form:message");
+ assertThat(message.getTextContent(), matcher);
+// System.out.println(page.asXml());
+ }
+ private HtmlInput hetInput(HtmlPage page) {
+ HtmlForm htmlForm = page.getFormByName("form");
+ assertNotNull(htmlForm);
+ HtmlInput input = htmlForm.getInputByName("form:text");
+ return input;
+ }
+
+ private HtmlPage requestPage() throws MalformedURLException, IOException {
+ HtmlPage page = environment.getPage("/client-test.jsf");
+ System.out.println(page.asXml());
+ return page;
+ }
+
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/ClientValidationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/CustomValidator.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/CustomValidator.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/CustomValidator.java 2010-12-03 00:26:26 UTC (rev 20322)
@@ -0,0 +1,39 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import javax.faces.validator.LengthValidator;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class CustomValidator extends LengthValidator {
+
+ public CustomValidator() {
+ setMinimum(1);
+ setMaximum(3);
+ }
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/CustomValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java 2010-12-03 00:26:26 UTC (rev 20322)
@@ -1,8 +1,10 @@
package org.richfaces.validator;
+import javax.faces.application.ResourceDependency;
+
import org.richfaces.javascript.ClientSideScript;
-@ClientSideScript(function="foo",library="bar",resource="baz.js")
+@ClientSideScript(function="foo",resources=@ResourceDependency(name="baz.js",library="bar"))
public class ValidatorWithFacesResource {
}
Modified: branches/RF-8742-1/ui/validator/ui/src/test/resources/badcsv.xml
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/resources/badcsv.xml 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/test/resources/badcsv.xml 2010-12-03 00:26:26 UTC (rev 20322)
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<scripts>
- <component>
- <type>non.existed.Class</type>
- <library>org.richfaces</library>
- <resource>csv.js</resource>
- <function>stringConverter</function>
- </component>
+ <component>
+ <type>non.existed.Class</type>
+ <resource>
+ <name>csv.js</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>stringConverter</function>
+ </component>
</scripts>
\ No newline at end of file
Modified: branches/RF-8742-1/ui/validator/ui/src/test/resources/csv.xml
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/resources/csv.xml 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/test/resources/csv.xml 2010-12-03 00:26:26 UTC (rev 20322)
@@ -2,14 +2,18 @@
<scripts>
<component>
<type>java.lang.String</type>
- <library>org.richfaces</library>
- <resource>csv.js</resource>
+ <resource>
+ <name>csv.js</name>
+ <library>org.richfaces</library>
+ </resource>
<function>stringConverter</function>
</component>
<component>
<type>java.lang.Integer</type>
- <library>org.richfaces</library>
- <resource>csv.js</resource>
+ <resource>
+ <name>csv.js</name>
+ <library>org.richfaces</library>
+ </resource>
<function>intConverter</function>
</component>
</scripts>
\ No newline at end of file
Modified: branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml 2010-12-03 00:26:26 UTC (rev 20322)
@@ -5,4 +5,8 @@
<managed-bean-class>org.richfaces.component.Bean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
+<validator>
+ <validator-id>custom</validator-id>
+ <validator-class>org.richfaces.component.CustomValidator</validator-class>
+</validator>
</faces-config>
\ No newline at end of file
Added: branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml 2010-12-03 00:26:26 UTC (rev 20322)
@@ -0,0 +1,16 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:csv="http://richfaces.org/csv">
+ <h:head><title>Ajax validator</title></h:head>
+ <h:body>
+ <h:form id="form">
+ <h:inputText id="text" value="#{test.value}">
+ <f:validateLength minimum="1" maximum="3"/>
+ <csv:validator event="keyup" />
+ </h:inputText>
+ <h:outputText id="out" value="#{test.value}"></h:outputText>
+ <h:message id="message" for="text" />
+ </h:form>
+ </h:body>
+</html>
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml 2010-12-02 23:10:02 UTC (rev 20321)
+++ branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml 2010-12-03 00:26:26 UTC (rev 20322)
@@ -6,7 +6,7 @@
<h:body>
<h:form id="form">
<h:inputText id="text" value="#{test.value}">
- <f:validateLength minimum="1" maximum="3"/>
+ <f:validator validatorId="custom" />
<csv:validator event="keyup" />
</h:inputText>
<h:outputText id="out" value="#{test.value}"></h:outputText>
13 years, 6 months
JBoss Rich Faces SVN: r20321 - in branches/RF-8742-1: core/api/src/main/java/org/richfaces/javascript and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-02 18:10:02 -0500 (Thu, 02 Dec 2010)
New Revision: 20321
Added:
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/FunctionDefWithDependencies.java
branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptWithDependencies.java
branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/ScriptsHolder.java
Modified:
branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/JavaScriptService.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/component/UIScripts.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
branches/RF-8742-1/core/impl/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml
Log:
RESOLVED - issue RF-9612: Create JSF 2.0 resource loading extension to dynamically add scripts and its dependencies.
https://jira.jboss.org/browse/RF-9612
Copied: branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/FunctionDefWithDependencies.java (from rev 20317, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java)
===================================================================
--- branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/FunctionDefWithDependencies.java (rev 0)
+++ branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/FunctionDefWithDependencies.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -0,0 +1,35 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.ajax4jsf.javascript;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface FunctionDefWithDependencies extends ScriptWithDependencies {
+
+ String getName();
+
+}
Property changes on: branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/FunctionDefWithDependencies.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptWithDependencies.java (from rev 20317, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java)
===================================================================
--- branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptWithDependencies.java (rev 0)
+++ branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptWithDependencies.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -0,0 +1,13 @@
+package org.ajax4jsf.javascript;
+
+import org.richfaces.resource.ResourceLibrary;
+
+/**
+ * This interface describes JavaScript object with optional dependent resources.
+ * @author asmirnov
+ *
+ */
+public interface ScriptWithDependencies extends ResourceLibrary, ScriptString {
+
+
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/core/api/src/main/java/org/ajax4jsf/javascript/ScriptWithDependencies.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/JavaScriptService.java
===================================================================
--- branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/JavaScriptService.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/JavaScriptService.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -53,4 +53,12 @@
* @return
*/
<S> S addPageReadyScript(FacesContext facesContext, S script);
+
+ /**
+ * <p class="changed_added_4_0">Get object with collection of scripts designeted for deffered rendering.</p>
+ * @param context
+ * @return ViewResource component that holds contect of all scripts, or special case object with empty collections.
+ */
+ ScriptsHolder getScriptsHolder(FacesContext context);
+
}
Added: branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/ScriptsHolder.java
===================================================================
--- branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/ScriptsHolder.java (rev 0)
+++ branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/ScriptsHolder.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -0,0 +1,15 @@
+package org.richfaces.javascript;
+
+import java.util.Collection;
+
+public interface ScriptsHolder {
+
+ Collection<Object> getScripts();
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the pageReadyScripts
+ */
+ Collection<Object> getPageReadyScripts();
+
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/core/api/src/main/java/org/richfaces/javascript/ScriptsHolder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742-1/core/impl/src/main/java/org/richfaces/component/UIScripts.java
===================================================================
--- branches/RF-8742-1/core/impl/src/main/java/org/richfaces/component/UIScripts.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/core/impl/src/main/java/org/richfaces/component/UIScripts.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -26,6 +26,8 @@
import java.util.Collection;
import java.util.List;
+import org.richfaces.javascript.ScriptsHolder;
+
import com.google.common.collect.Lists;
/**
@@ -37,7 +39,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class UIScripts extends UITransient {
+public class UIScripts extends UITransient implements ScriptsHolder {
public static final String COMPONENT_TYPE = "org.richfaces.Scripts";
@@ -50,13 +52,15 @@
private String target = "form";
+ /* (non-Javadoc)
+ * @see org.richfaces.component.ScriptsHolder#getScripts()
+ */
public Collection<Object> getScripts() {
return scripts;
}
- /**
- * <p class="changed_added_4_0"></p>
- * @return the pageReadyScripts
+ /* (non-Javadoc)
+ * @see org.richfaces.component.ScriptsHolder#getPageReadyScripts()
*/
public Collection<Object> getPageReadyScripts() {
return this.pageReadyScripts;
Modified: branches/RF-8742-1/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- branches/RF-8742-1/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -47,7 +47,11 @@
import javax.faces.event.PhaseId;
import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.richfaces.application.ServiceTracker;
import org.richfaces.component.MetaComponentEncoder;
+import org.richfaces.javascript.JavaScriptService;
+import org.richfaces.javascript.ScriptsHolder;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.renderkit.util.CoreAjaxRendererUtils;
@@ -425,6 +429,15 @@
}
protected void renderExtensions(FacesContext context, UIComponent component) throws IOException {
+ // ADD deffered scripts
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
+ ScriptsHolder scriptsHolder = ServiceTracker.getService(JavaScriptService.class).getScriptsHolder(context);
+ for (Object script : scriptsHolder.getScripts()) {
+ ajaxContext.appendOncomplete(ScriptUtils.toScript(script));
+ }
+ for (Object script : scriptsHolder.getPageReadyScripts()) {
+ ajaxContext.appendOncomplete(ScriptUtils.toScript(script));
+ }
CoreAjaxRendererUtils.renderAjaxExtensions(context, component);
}
Modified: branches/RF-8742-1/core/impl/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java
===================================================================
--- branches/RF-8742-1/core/impl/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/core/impl/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -24,6 +24,7 @@
package org.richfaces.javascript;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import javax.faces.FacesException;
@@ -42,6 +43,21 @@
*/
public class JavaScriptServiceImpl implements JavaScriptService {
+ /**
+ * <p class="changed_added_4_0">'Special Case' object to return if no Component with scripts added to View Root.</p>
+ *
+ */
+ private static final ScriptsHolder EMPTY_SCRIPTS_HOLDER = new ScriptsHolder(){
+
+ public Collection<Object> getScripts() {
+ return Collections.emptySet();
+ }
+
+ public Collection<Object> getPageReadyScripts() {
+ return Collections.emptySet();
+ }
+
+ };
/*
* (non-Javadoc)
*
@@ -89,20 +105,25 @@
if (null == viewRoot) {
throw new FacesException("View is not created");
}
+ UIScripts scriptResource = findScriptResource(facesContext, viewRoot);
+ if (null == scriptResource) {
+ scriptResource = (UIScripts) facesContext.getApplication().createComponent(UIScripts.COMPONENT_TYPE);
+ viewRoot.addComponentResource(facesContext, scriptResource);
+ }
+ return scriptResource;
+ }
+
+ private UIScripts findScriptResource(FacesContext facesContext, UIViewRoot viewRoot) {
List<UIComponent> componentResources = viewRoot.getComponentResources(facesContext, "form");
- UIScripts scriptResource = findScriptResource(componentResources);
+ UIScripts scriptResource = findScriptComponent(componentResources);
if (null == scriptResource) {
componentResources = viewRoot.getComponentResources(facesContext, "body");
- scriptResource = findScriptResource(componentResources);
- if (null == scriptResource) {
- scriptResource = (UIScripts) facesContext.getApplication().createComponent(UIScripts.COMPONENT_TYPE);
- viewRoot.addComponentResource(facesContext, scriptResource);
- }
+ scriptResource = findScriptComponent(componentResources);
}
return scriptResource;
}
- private UIScripts findScriptResource(List<UIComponent> componentResources) {
+ private UIScripts findScriptComponent(List<UIComponent> componentResources) {
for (UIComponent uiComponent : componentResources) {
if (uiComponent instanceof UIScripts) {
UIScripts script = (UIScripts) uiComponent;
@@ -112,4 +133,16 @@
return null;
}
+ public ScriptsHolder getScriptsHolder(FacesContext context) {
+ UIViewRoot viewRoot = context.getViewRoot();
+ ScriptsHolder result=null;
+ if (null != viewRoot) {
+ result = findScriptResource(context, viewRoot);
+ }
+ if(null == result){
+ result = EMPTY_SCRIPTS_HOLDER;
+ }
+ return result;
+ }
+
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -31,8 +31,6 @@
import org.richfaces.javascript.ClientScriptService;
import org.richfaces.javascript.ClientScriptServiceImpl;
import org.richfaces.javascript.ClientServiceConfigParser;
-import org.richfaces.javascript.JavaScriptService;
-import org.richfaces.javascript.JavaScriptServiceImpl;
import org.richfaces.javascript.LibraryFunction;
import org.richfaces.validator.BeanValidator;
import org.richfaces.validator.BeanValidatorFactory;
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -2,7 +2,7 @@
import java.util.Collection;
-import org.richfaces.javascript.ScriptWithDependencies;
+import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
import com.google.common.collect.Iterables;
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -3,7 +3,7 @@
import java.util.Collection;
import java.util.LinkedHashSet;
-import org.richfaces.javascript.ScriptWithDependencies;
+import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
import com.google.common.collect.Iterables;
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -19,6 +19,7 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.richfaces.application.ServiceTracker;
import org.richfaces.component.behavior.ClientValidatorBehavior;
import org.richfaces.component.behavior.ConverterNotFoundException;
@@ -26,7 +27,6 @@
import org.richfaces.javascript.JavaScriptService;
import org.richfaces.javascript.LibraryFunction;
import org.richfaces.javascript.ScriptNotFoundException;
-import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesObjectDescriptor;
import org.richfaces.validator.ValidatorDescriptor;
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -1,6 +1,6 @@
package org.richfaces.renderkit.html;
-import org.richfaces.javascript.FunctionDefWithDependencies;
+import org.ajax4jsf.javascript.FunctionDefWithDependencies;
public interface ComponentValidatorScript extends FunctionDefWithDependencies {
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -24,8 +24,8 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.richfaces.javascript.LibraryFunction;
-import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
/**
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -6,7 +6,7 @@
import java.util.Collections;
import org.ajax4jsf.javascript.JSLiteral;
-import org.richfaces.javascript.ScriptWithDependencies;
+import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
/**
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -3,15 +3,13 @@
*/
package org.richfaces.javascript;
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
import java.util.Map;
import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
-import javax.faces.context.FacesContext;
import javax.validation.constraints.Max;
import org.jboss.test.faces.mock.Environment;
@@ -24,9 +22,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.richfaces.javascript.ClientScriptServiceImpl;
-import org.richfaces.javascript.LibraryFunction;
-import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.resource.ResourceKey;
import org.richfaces.validator.ValidatorWithFacesResource;
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -3,9 +3,13 @@
import java.io.IOException;
import java.util.Collections;
+import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
final class Script implements ScriptWithDependencies {
+
+ static final ResourceKey FOO_RESOURCE = ResourceKey.create("foo","org.rf");
+
private final String name;
Script(String name) {
@@ -29,7 +33,7 @@
}
public Iterable<ResourceKey> getResources() {
- return Collections.singleton(JavaScriptServiceTest.FOO_RESOURCE);
+ return Collections.singleton(FOO_RESOURCE);
}
/* (non-Javadoc)
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -9,8 +9,6 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.richfaces.javascript.ClientServiceConfigParser;
-import org.richfaces.javascript.LibraryFunction;
import org.richfaces.resource.ResourceKey;
import com.google.common.collect.Iterables;
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -11,6 +11,7 @@
import javax.faces.convert.NumberConverter;
import javax.faces.validator.RegexValidator;
+import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.jboss.test.faces.mock.Mock;
import org.jboss.test.faces.mock.MockTestRunner;
import org.junit.After;
@@ -20,7 +21,6 @@
import org.richfaces.application.ServiceTracker;
import org.richfaces.javascript.ClientScriptService;
import org.richfaces.javascript.LibraryFunction;
-import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.ValidatorDescriptor;
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-12-02 23:10:02 UTC (rev 20321)
@@ -17,6 +17,7 @@
import javax.validation.constraints.Min;
import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
@@ -26,7 +27,6 @@
import org.junit.runner.RunWith;
import org.richfaces.javascript.LibraryFunction;
import org.richfaces.javascript.ScriptNotFoundException;
-import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesObjectDescriptor;
Modified: branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml 2010-12-02 19:50:37 UTC (rev 20320)
+++ branches/RF-8742-1/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml 2010-12-02 23:10:02 UTC (rev 20321)
@@ -11,7 +11,6 @@
</h:inputText>
<h:outputText id="out" value="#{test.value}"></h:outputText>
<h:message id="message" for="text" />
- <h:commandLink id="submit">Submit</h:commandLink>
</h:form>
</h:body>
</html>
13 years, 6 months
JBoss Rich Faces SVN: r20320 - in trunk/ui: iteration/ui/src/main/java/org/richfaces/component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-02 14:50:37 -0500 (Thu, 02 Dec 2010)
New Revision: 20320
Removed:
trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig
trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig
Log:
Finally delete *.orig files
Deleted: trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig 2010-12-02 19:07:45 UTC (rev 20319)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig 2010-12-02 19:50:37 UTC (rev 20320)
@@ -1,1523 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.component;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.ContextCallback;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.PartialStateHolder;
-import javax.faces.component.StateHelper;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIForm;
-import javax.faces.component.UINamingContainer;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.UniqueIdVendor;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitResult;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ComponentSystemEvent;
-import javax.faces.event.ComponentSystemEventListener;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.ListenerFor;
-import javax.faces.event.PhaseId;
-import javax.faces.event.PostValidateEvent;
-import javax.faces.event.PreRenderComponentEvent;
-import javax.faces.event.PreValidateEvent;
-import javax.faces.render.Renderer;
-
-import org.ajax4jsf.component.IterationStateHolder;
-import org.ajax4jsf.model.DataComponentState;
-import org.ajax4jsf.model.DataVisitResult;
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SerializableDataModel;
-import org.richfaces.context.ExtendedVisitContext;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-
-/**
- * Base class for iterable components, like dataTable, Tomahawk dataList, Facelets repeat, tree etc., with support for
- * partial rendering on AJAX responces for one or more selected iterations.
- *
- * @author shura
- */
-@ListenerFor(systemEventClass = PreRenderComponentEvent.class)
-public abstract class UIDataAdaptor extends UIComponentBase implements NamingContainer,
- UniqueIdVendor, IterationStateHolder, ComponentSystemEventListener {
-
- /**
- * <p>The standard component family for this component.</p>
- */
- public static final String COMPONENT_FAMILY = "org.richfaces.Data";
-
- /**
- * <p>The standard component type for this component.</p>
- */
- public static final String COMPONENT_TYPE = "org.richfaces.Data";
-
- private static final class IterationState implements Serializable {
-
- private static final long serialVersionUID = -3502645160277416066L;
-
- private DataComponentState componentState;
-
- private Object savedComponentState;
-
- private boolean componentStateIsStateHolder;
-
- private ExtendedDataModel<?> dataModel;
-
- public IterationState() {
- super();
- }
-
- public IterationState(DataComponentState componentState, ExtendedDataModel<?> dataModel) {
- super();
- this.componentState = componentState;
- this.dataModel = dataModel;
- }
-
- public ExtendedDataModel<?> getDataModel() {
- return dataModel;
- }
-
- public DataComponentState getComponentState() {
- return componentState;
- }
-
- /**
- * @param uiDataAdaptor
- */
- public void restoreComponentState(UIDataAdaptor uiDataAdaptor) {
- if (savedComponentState != null && componentStateIsStateHolder) {
- componentState = uiDataAdaptor.createComponentState();
- ((StateHolder) componentState).restoreState(FacesContext.getCurrentInstance(), savedComponentState);
- savedComponentState = null;
- }
- }
-
- final Object saveState() {
- boolean localComponentStateIsHolder = false;
- Object localSavedComponentState = null;
-
- if (componentState != null) {
- if (componentState instanceof StateHolder) {
- localComponentStateIsHolder = true;
-
- StateHolder stateHolder = (StateHolder) componentState;
- if (!stateHolder.isTransient()) {
- localSavedComponentState = stateHolder.saveState(FacesContext.getCurrentInstance());
- }
- } else {
- if (componentState instanceof Serializable) {
- localSavedComponentState = componentState;
- }
- }
- }
-
- Object savedSerializableModel = null;
-
- if (componentState != null && dataModel != null) {
- // TODO handle model serialization - "execute" model
- savedSerializableModel = dataModel.getSerializableModel(componentState.getRange());
- }
-
- if (localSavedComponentState != null || savedSerializableModel != null) {
- return new Object[] {
- localComponentStateIsHolder,
- localSavedComponentState,
- savedSerializableModel
- };
- } else {
- return null;
- }
- }
-
- final void restoreState(Object stateObject) {
- if (stateObject != null) {
- Object[] state = (Object[]) stateObject;
- componentStateIsStateHolder = Boolean.TRUE.equals(state[0]);
- Object localSavedComponentState = state[1];
-
- if (componentStateIsStateHolder) {
- savedComponentState = localSavedComponentState;
- } else {
- componentState = (DataComponentState) localSavedComponentState;
- }
-
- dataModel = (ExtendedDataModel<?>) state[2];
- }
- }
-
- private void writeObject(java.io.ObjectOutputStream out)
- throws IOException {
-
- out.writeObject(saveState());
- }
-
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException {
-
- restoreState(in.readObject());
- }
- }
-
- private static final VisitCallback STUB_CALLBACK = new VisitCallback() {
-
- public VisitResult visit(VisitContext context, UIComponent target) {
- return VisitResult.ACCEPT;
- }
- };
-
- private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
-
- /**
- * Visitor for process decode on children components.
- */
- protected ComponentVisitor decodeVisitor = new ComponentVisitor() {
- @Override
- public void processComponent(FacesContext context, UIComponent c, Object argument) {
- c.processDecodes(context);
- }
- };
-
- /**
- * Visitor for process validation phase
- */
- protected ComponentVisitor validateVisitor = new ComponentVisitor() {
- @Override
- public void processComponent(FacesContext context, UIComponent c, Object argument) {
- c.processValidators(context);
- }
- };
-
- /**
- * Visitor for process update model phase.
- */
- protected ComponentVisitor updateVisitor = new ComponentVisitor() {
- @Override
- public void processComponent(FacesContext context, UIComponent c, Object argument) {
- c.processUpdates(context);
- }
- };
-
- //TODO nick - PSH support?
- private DataComponentState componentState = null;
- private ExtendedDataModel<?> extendedDataModel = null;
-
- private Object rowKey = null;
-
- private boolean rowDataIsSet = false;
-
- private Object rowData;
-
- private String clientId;
-
- private Object originalVarValue;
-
- private Converter rowKeyConverter;
-
- /**
- * @author Nick Belaevski
- *
- */
- private final class DataVisitorForVisitTree implements DataVisitor {
- /**
- *
- */
- private final VisitCallback callback;
- /**
- *
- */
- private final VisitContext visitContext;
- /**
- *
- */
- private boolean visitResult;
-
- /**
- * @param callback
- * @param visitContext
- */
- private DataVisitorForVisitTree(VisitCallback callback, VisitContext visitContext) {
- this.callback = callback;
- this.visitContext = visitContext;
- }
-
- public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
- setRowKey(context, rowKey);
-
- if (isRowAvailable()) {
- VisitResult result = VisitResult.ACCEPT;
-
- if (visitContext instanceof ExtendedVisitContext) {
- result = visitContext.invokeVisitCallback(UIDataAdaptor.this, callback);
- if (VisitResult.COMPLETE.equals(result)) {
- visitResult = true;
-
- return DataVisitResult.STOP;
- }
-
- if (result == VisitResult.ACCEPT) {
- result = visitDataChildrenMetaComponents((ExtendedVisitContext) visitContext, callback);
- if (VisitResult.COMPLETE.equals(result)) {
- visitResult = true;
-
- return DataVisitResult.STOP;
- }
- }
- }
-
- if (VisitResult.ACCEPT.equals(result)) {
- Iterator<UIComponent> dataChildrenItr = dataChildren();
-
- while (dataChildrenItr.hasNext()) {
- UIComponent dataChild = dataChildrenItr.next();
-
- if (dataChild.visitTree(visitContext, callback)) {
- visitResult = true;
-
- return DataVisitResult.STOP;
- }
- }
- }
- }
-
- return DataVisitResult.CONTINUE;
- }
-
- public boolean getVisitResult() {
- return visitResult;
- }
- }
-
- private enum PropertyKeys {
- lastId, var, rowKeyVar, stateVar, childState, rowKeyConverter, rowKeyConverterSet, keepSaved
- }
-
- public UIDataAdaptor() {
- super();
- }
-
- protected Map<String, Object> getVariablesMap(FacesContext facesContext) {
- return facesContext.getExternalContext().getRequestMap();
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UniqueIdVendor#createUniqueId(javax.faces.context.FacesContext, java.lang.String)
- */
- public String createUniqueId(FacesContext context, String seed) {
- Integer i = (Integer) getStateHelper().get(PropertyKeys.lastId);
- int lastId = (i != null) ? i : 0;
-
- getStateHelper().put(PropertyKeys.lastId, ++lastId);
-
- return UIViewRoot.UNIQUE_ID_PREFIX + ((seed == null) ? lastId : seed);
- }
-
- /**
- * @return the rowKey
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- private void setRowKeyAndData(FacesContext facesContext, Object rowKey, boolean localRowDataAvailable, Object localRowData) {
- this.saveChildState(facesContext);
-
- this.rowKey = rowKey;
-
- if (localRowDataAvailable) {
- this.rowData = localRowData;
- this.rowDataIsSet = (rowKey != null);
- } else {
- this.rowData = null;
- this.rowDataIsSet = false;
-
- getExtendedDataModel().setRowKey(rowKey);
- }
-
- this.clientId = null;
-
- boolean rowSelected = (rowKey != null) && isRowAvailable();
-
- setupVariable(facesContext, rowSelected);
-
- this.restoreChildState(facesContext);
- }
-
- protected void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
- setRowKeyAndData(facesContext, rowKey, true, localRowData);
- }
-
- /**
- * Setup current row by key. Perform same functionality as
- * {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
- * row number in sequence data, but, for example - path to current node in
- * tree.
- *
- * @param faces -
- * current FacesContext
- * @param key new key value.
- */
- public void setRowKey(FacesContext facesContext, Object rowKey) {
-<<<<<<< HEAD
- this.saveChildState(facesContext);
-
- this.rowKey = rowKey;
-
- getExtendedDataModel().setRowKey(rowKey);
-
- this.clientId = null;
-
- boolean rowSelected = (rowKey != null) && isRowAvailable();
-
- setupVariable(facesContext, rowSelected);
-
- this.restoreChildState(facesContext);
-=======
- setRowKeyAndData(facesContext, rowKey, false, null);
->>>>>>> RF-9680:
- }
-
- /**
- * Save values of {@link EditableValueHolder} fields before change current
- * row.
- *
- * @param faces
- */
- protected void saveChildState(FacesContext facesContext) {
- Iterator<UIComponent> itr = dataChildren();
-
- while (itr.hasNext()) {
- this.saveChildState(facesContext, (UIComponent) itr.next());
- }
- }
-
- /**
- * @param facesContext
- * @param next
- * @param childState
- */
- protected void saveChildState(FacesContext facesContext, UIComponent component) {
-
- // TODO - is it right?
- if (component.isTransient()) {
- return;
- }
-
- SavedState state = null;
-
- if (component instanceof IterationStateHolder) {
- IterationStateHolder ish = (IterationStateHolder) component;
-
- state = new SavedState(ish);
- } else if (component instanceof EditableValueHolder) {
- EditableValueHolder evh = (EditableValueHolder) component;
-
- state = new SavedState(evh);
- } else if (component instanceof UIForm) {
- UIForm form = (UIForm) component;
-
- state = new SavedState(form);
- }
-
- if (state != null) {
-
- // TODO - use local map - children save their state themselves using visitors
- getStateHelper().put(PropertyKeys.childState, component.getClientId(facesContext), state);
- }
-
- if (component.getChildCount() > 0) {
- for (UIComponent child : component.getChildren()) {
- saveChildState(facesContext, child);
- }
- }
-
- if (component.getFacetCount() > 0) {
- for (UIComponent facet : component.getFacets().values()) {
- saveChildState(facesContext, facet);
- }
- }
- }
-
- protected Iterator<UIComponent> dataChildren() {
- if (getChildCount() > 0) {
- return getChildren().iterator();
- } else {
- return Collections.<UIComponent>emptyList().iterator();
- }
- }
-
- protected Iterator<UIComponent> fixedChildren() {
- if (getFacetCount() > 0) {
- return getFacets().values().iterator();
- } else {
- return Collections.<UIComponent>emptyList().iterator();
- }
- }
-
- /**
- * @param facesContext
- */
- protected void restoreChildState(FacesContext facesContext) {
- Iterator<UIComponent> itr = dataChildren();
-
- while (itr.hasNext()) {
- this.restoreChildState(facesContext, (UIComponent) itr.next());
- }
- }
-
- /**
- * Restore values of {@link EditableValueHolder} fields after change current
- * row.
- *
- * @param facesContext
- * @param next
- * @param childState
- */
- protected void restoreChildState(FacesContext facesContext, UIComponent component) {
- String id = component.getId();
-
- component.setId(id); // Forces client id to be reset
-
- SavedState savedState = null;
- @SuppressWarnings("unchecked")
- Map<String, SavedState> savedStatesMap = (Map<String, SavedState>) getStateHelper()
- .get(PropertyKeys.childState);
-
- if (savedStatesMap != null) {
- savedState = savedStatesMap.get(component.getClientId(facesContext));
- }
-
- if (savedState == null) {
- savedState = SavedState.EMPTY;
- }
-
- if (component instanceof IterationStateHolder) {
- IterationStateHolder ish = (IterationStateHolder) component;
-
- savedState.apply(ish);
- } else if (component instanceof EditableValueHolder) {
- EditableValueHolder evh = (EditableValueHolder) component;
-
- savedState.apply(evh);
- } else if (component instanceof UIForm) {
- UIForm form = (UIForm) component;
-
- savedState.apply(form);
- }
-
- if (component.getChildCount() > 0) {
- for (UIComponent child : component.getChildren()) {
- restoreChildState(facesContext, child);
- }
- }
-
- if (component.getFacetCount() > 0) {
- for (UIComponent facet : component.getFacets().values()) {
- restoreChildState(facesContext, facet);
- }
- }
- }
-
- public void setRowKey(Object rowKey) {
- setRowKey(getFacesContext(), rowKey);
- }
-
- protected FacesEvent wrapEvent(FacesEvent event) {
- return new RowKeyContextEventWrapper(this, event, getRowKey());
- }
-
- @Override
- public void queueEvent(FacesEvent event) {
- super.queueEvent(wrapEvent(event));
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
- */
- @Override
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- if (event instanceof RowKeyContextEventWrapper) {
- RowKeyContextEventWrapper eventWrapper = (RowKeyContextEventWrapper) event;
-
- eventWrapper.broadcast(getFacesContext());
- } else {
- super.broadcast(event);
- }
- }
-
- /**
- * @return the extendedDataModel
- */
- protected ExtendedDataModel<?> getExtendedDataModel() {
- if (extendedDataModel == null) {
- extendedDataModel = createExtendedDataModel();
- }
-
- return extendedDataModel;
- }
-
- /**
- * @return
- */
- protected abstract ExtendedDataModel<?> createExtendedDataModel();
-
- /**
- * @param extendedDataModel the extendedDataModel to set
- */
- protected void setExtendedDataModel(ExtendedDataModel<?> extendedDataModel) {
- this.extendedDataModel = extendedDataModel;
- }
-
- public String getVar() {
- return (String) getStateHelper().get(PropertyKeys.var);
- }
-
- public void setVar(String var) {
- getStateHelper().put(PropertyKeys.var, var);
- }
-
- public String getRowKeyVar() {
- return (String) getStateHelper().get(PropertyKeys.rowKeyVar);
- }
-
- public void setRowKeyVar(String rowKeyVar) {
- getStateHelper().put(PropertyKeys.rowKeyVar, rowKeyVar);
- }
-
- public String getStateVar() {
- return (String) getStateHelper().get(PropertyKeys.stateVar);
- }
-
- public void setStateVar(String stateVar) {
- getStateHelper().put(PropertyKeys.stateVar, stateVar);
- }
-
- //XXX - review and probably remove - useful method, should be left
- public int getRowCount() {
- return getExtendedDataModel().getRowCount();
- }
-
- public Object getRowData() {
- if (rowDataIsSet) {
- return rowData;
- }
-
- return getExtendedDataModel().getRowData();
- }
-
- public boolean isRowAvailable() {
- return rowDataIsSet || getExtendedDataModel().isRowAvailable();
- }
-
- /**
- * Boolean attribute that defines whether this iteration component will reset saved children's state
- * before rendering. By default state is reset if there are no faces messages with severity error or higher.
- * @return
- */
- public boolean isKeepSaved() {
- Object value = getStateHelper().eval(PropertyKeys.keepSaved);
-
- if (value == null) {
- return keepSaved(getFacesContext());
- } else {
- return Boolean.valueOf(value.toString());
- }
- }
-
- public void setKeepSaved(boolean keepSaved) {
- getStateHelper().put(PropertyKeys.keepSaved, keepSaved);
- }
-
- /**
- * Setup EL variable for different iteration. Value of row data and
- * component state will be put into request scope attributes with names
- * given by "var" and "varState" bean properties.
- * <p/>
- * Changed: does not check for row availability now
- *
- * @param faces current faces context
- * @param localModel
- * @param rowSelected
- */
- protected void setupVariable(FacesContext faces, boolean rowSelected) {
- Map<String, Object> attrs = getVariablesMap(faces);
-
- if (rowSelected) {
-
- // Current row data.
- setupVariable(getVar(), attrs, getRowData());
-
- // Component state variable.
- setupVariable(getStateVar(), attrs, getComponentState());
-
- // Row key Data variable.
- setupVariable(getRowKeyVar(), attrs, getRowKey());
- } else {
- removeVariable(getVar(), attrs);
- removeVariable(getStateVar(), attrs);
- removeVariable(getRowKeyVar(), attrs);
- }
- }
-
- /**
- * @return
- */
- public DataComponentState getComponentState() {
- if (componentState != null) {
- return componentState;
- }
-
- ValueExpression componentStateExpression = getValueExpression("componentState");
-
- if (componentStateExpression != null) {
- componentState = (DataComponentState) componentStateExpression.getValue(getFacesContext().getELContext());
- }
-
- if (componentState == null) {
- componentState = createComponentState();
-
- if ((componentStateExpression != null)
- && !componentStateExpression.isReadOnly(getFacesContext().getELContext())) {
- componentStateExpression.setValue(getFacesContext().getELContext(), componentState);
- }
- }
-
- return componentState;
- }
-
- protected abstract DataComponentState createComponentState();
-
- /**
- * @param var
- * @param attrs
- * @param rowData
- */
- private void setupVariable(String var, Map<String, Object> attrs, Object rowData) {
- if (var != null) {
- attrs.put(var, rowData);
- }
- }
-
- /**
- * @param var
- * @param attrs
- * @param rowData
- */
- private void removeVariable(String var, Map<String, Object> attrs) {
- if (var != null) {
- attrs.remove(var);
- }
- }
-
- public Converter getRowKeyConverter() {
- if (this.rowKeyConverter != null) {
- return this.rowKeyConverter;
- }
-
- return (Converter) getStateHelper().eval(PropertyKeys.rowKeyConverter);
- }
-
- public void setRowKeyConverter(Converter converter) {
- StateHelper stateHelper = getStateHelper();
- if (initialStateMarked()) {
- stateHelper.put(PropertyKeys.rowKeyConverterSet, Boolean.TRUE);
- }
-
- this.rowKeyConverter = converter;
- }
-
- private boolean isSetRowKeyConverter() {
- Boolean value = (Boolean) getStateHelper().get(PropertyKeys.rowKeyConverterSet);
- return Boolean.TRUE.equals(value);
- }
-
- @Override
- public String getClientId(FacesContext facesContext) {
- if (facesContext == null) {
- throw new NullPointerException("context");
- }
-
- if (null == clientId) {
- StringBuilder id = new StringBuilder(super.getClientId(facesContext));
- Object rowKey = getRowKey();
-
- if (rowKey != null) {
-
- // Use converter to get String representation ot the row key.
- Converter rowKeyConverter = getRowKeyConverter();
-
- if (null == rowKeyConverter) {
-
- // Create default converter for a row key.
- rowKeyConverter = facesContext.getApplication().createConverter(rowKey.getClass());
-
- // Store converter for a invokeOnComponents call.
- if (null != rowKeyConverter) {
- // TODO - review
- setRowKeyConverter(rowKeyConverter);
- }
- }
-
- String rowKeyString;
-
- if (null != rowKeyConverter) {
-
- // Temporary set clientId, to avoid infinite calls from converter.
- clientId = id.toString();
- rowKeyString = rowKeyConverter.getAsString(facesContext, this, rowKey);
- } else {
- rowKeyString = rowKey.toString();
- }
-
- id.append(UINamingContainer.getSeparatorChar(facesContext)).append(rowKeyString);
- }
-
- Renderer renderer = getRenderer(facesContext);
-
- if (null != renderer) {
- clientId = renderer.convertClientId(facesContext, id.toString());
- } else {
- clientId = id.toString();
- }
- }
-
- return clientId;
- }
-
- public String getBaseClientId(FacesContext context) {
- return super.getClientId(context);
- }
-
- /**
- * Save current state of data variable.
- *
- * @param faces current faces context
- */
-
- // TODO move into walk() method body
- public void captureOrigValue(FacesContext faces) {
- String var = getVar();
-
- if (var != null) {
- Map<String, Object> attrs = getVariablesMap(faces);
-
- this.originalVarValue = attrs.get(var);
- }
-
- // TODO add support for another variables
- }
-
- /**
- * Restore value of data variable after processing phase.
- *
- * @param faces current faces context
- */
- public void restoreOrigValue(FacesContext faces) {
- String var = getVar();
-
- if (var != null) {
- Map<String, Object> attrs = getVariablesMap(faces);
-
- if (this.originalVarValue != null) {
- attrs.put(var, this.originalVarValue);
- } else {
- attrs.remove(var);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponent#setValueExpression(java.lang.String, javax.el.ValueExpression)
- */
- @Override
- public void setValueExpression(String name, ValueExpression binding) {
- if ("var".equals(name) || "rowKeyVar".equals(name) || "stateVar".equals(name)) {
- throw new IllegalArgumentException(MessageFormat.format("{0} cannot be EL-expression", name));
- }
-
- super.setValueExpression(name, binding);
- }
-
- /**
- * Check for validation errors on children components. If true, saved values
- * must be keep on render phase
- *
- * @param context
- * @return
- */
- protected boolean keepSaved(FacesContext context) {
-
- // For an any validation errors, children components state should be preserved
- FacesMessage.Severity sev = context.getMaximumSeverity();
-
- return (sev != null) && (FacesMessage.SEVERITY_ERROR.compareTo(sev) >= 0);
- }
-
- /**
- * Perform iteration on all children components and all data rows with given
- * visitor.
- *
- * @param faces
- * @param visitor
- */
- protected void iterate(FacesContext faces, ComponentVisitor visitor) {
-
- // stop if not rendered
- if (!this.isRendered()) {
- return;
- }
-
- // reset rowIndex
- this.captureOrigValue(faces);
- this.setRowKey(faces, null);
-
- try {
- Iterator<UIComponent> fixedChildren = fixedChildren();
-
- while (fixedChildren.hasNext()) {
- UIComponent component = fixedChildren.next();
-
- visitor.processComponent(faces, component, null);
- }
-
- walk(faces, visitor, null);
- } catch (Exception e) {
- throw new FacesException(e);
- } finally {
- this.setRowKey(faces, null);
- this.restoreOrigValue(faces);
- }
- }
-
- /**
- * Walk ( visit ) this component on all data-aware children for each row.
- *
- * @param faces
- * @param visitor
- */
- public void walk(FacesContext faces, DataVisitor visitor, Object argument) {
- Object key = getRowKey();
- captureOrigValue(faces);
-
- Range range = null;
- DataComponentState componentState = getComponentState();
-
- if (componentState != null) {
- range = componentState.getRange();
- }
-
- getExtendedDataModel().walk(faces, visitor, range, argument);
-
- setRowKey(faces, key);
- restoreOrigValue(faces);
- }
-
- public void processDecodes(FacesContext faces) {
- if (!this.isRendered()) {
- return;
- }
-
- pushComponentToEL(faces, this);
- preDecode(faces);
- this.iterate(faces, decodeVisitor);
- this.decode(faces);
- popComponentFromEL(faces);
- }
-
- public void processValidators(FacesContext faces) {
- if (!this.isRendered()) {
- return;
- }
-
- pushComponentToEL(faces, this);
- Application app = faces.getApplication();
- app.publishEvent(faces, PreValidateEvent.class, this);
- preValidate(faces);
- this.iterate(faces, validateVisitor);
- app.publishEvent(faces, PostValidateEvent.class, this);
- popComponentFromEL(faces);
- }
-
- public void processUpdates(FacesContext faces) {
- if (!this.isRendered()) {
- return;
- }
-
- pushComponentToEL(faces, this);
- preUpdate(faces);
- this.iterate(faces, updateVisitor);
-
- ExtendedDataModel<?> dataModel = getExtendedDataModel();
-
- // If no validation errors, update values for serializable model,
- // restored from view.
- if ((dataModel instanceof SerializableDataModel) && (!isKeepSaved())) {
- SerializableDataModel serializableModel = (SerializableDataModel) dataModel;
-
- serializableModel.update();
- }
-
- doUpdate();
-
- popComponentFromEL(faces);
- }
-
- protected void doUpdate() {
-
- }
-
- @Override
- public void setId(String id) {
- super.setId(id);
- this.clientId = null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.ajax4jsf.component.IterationStateHolder#getIterationState()
- */
- public Object getIterationState() {
- assert rowKey == null;
-
- return new IterationState(this.componentState, this.extendedDataModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.component.IterationStateHolder#setIterationState(java.lang.Object)
- */
- public void setIterationState(Object stateObject) {
- assert rowKey == null;
-
- // TODO - ?
- // restoreChildState(getFacesContext());
- if (stateObject != null) {
- IterationState iterationState = (IterationState) stateObject;
- iterationState.restoreComponentState(this);
-
- this.componentState = iterationState.getComponentState();
- this.extendedDataModel = iterationState.getDataModel();
- } else {
- this.componentState = null;
- this.extendedDataModel = null;
- }
- }
-
- protected void resetDataModel() {
- this.extendedDataModel = null;
- }
-
- protected void resetChildState() {
- getStateHelper().remove(PropertyKeys.childState);
- }
-
- protected void preDecode(FacesContext context) {
- resetDataModel();
-
- Object savedChildState = getStateHelper().get(PropertyKeys.childState);
- // TODO - verify the check for null: savedChildState == null
- if (savedChildState == null || !isKeepSaved()) {
- resetChildState();
- }
- }
-
- // TODO - do we need this method?
- protected void preValidate(FacesContext context) {
- }
-
- // TODO - do we need this method?
- protected void preUpdate(FacesContext context) {
- }
-
- protected void preEncodeBegin(FacesContext context) {
- resetDataModel();
-
- if (!isKeepSaved()) {
- //TODO - this also resets state for the nested iteration components - is it correct?
- resetChildState();
- }
- }
-
- @Override
- public void markInitialState() {
- super.markInitialState();
-
- if (rowKeyConverter instanceof PartialStateHolder) {
- ((PartialStateHolder) rowKeyConverter).markInitialState();
- }
- }
-
- @Override
- public void clearInitialState() {
- super.clearInitialState();
-
- if (rowKeyConverter instanceof PartialStateHolder) {
- ((PartialStateHolder) rowKeyConverter).clearInitialState();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
- */
- @Override
- public Object saveState(FacesContext context) {
- Object parentState = super.saveState(context);
- Object savedComponentState = new IterationState(componentState, extendedDataModel).saveState();
-
- Object converterState = null;
- boolean nullDelta = true;
-
- boolean converterHasPartialState = false;
-
- if (initialStateMarked()) {
- if (!isSetRowKeyConverter() && rowKeyConverter != null && rowKeyConverter instanceof PartialStateHolder) {
- // Delta
- StateHolder holder = (StateHolder) rowKeyConverter;
- if (!holder.isTransient()) {
- Object attachedState = holder.saveState(context);
- if (attachedState != null) {
- nullDelta = false;
- converterState = attachedState;
- }
- converterHasPartialState = true;
- } else {
- converterState = null;
- }
- } else if (isSetRowKeyConverter() || rowKeyConverter != null) {
- // Full
- converterState = saveAttachedState(context, rowKeyConverter);
- nullDelta = false;
- }
-
- if (parentState == null && savedComponentState == null && nullDelta) {
- // No values
- return null;
- }
- } else {
- converterState = saveAttachedState(context, rowKeyConverter);
- }
-
- return new Object[] {
- parentState,
- savedComponentState,
- converterHasPartialState,
- converterState
- };
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext, java.lang.Object)
- */
- @Override
- public void restoreState(FacesContext context, Object stateObject) {
- if (stateObject == null) {
- return ;
- }
-
- Object[] state = (Object[]) stateObject;
-
- super.restoreState(context, state[0]);
-
- if (state[1] != null) {
- IterationState iterationState = new IterationState();
- iterationState.restoreState(state[1]);
- iterationState.restoreComponentState(this);
-
- // TODO update state model binding
- componentState = iterationState.getComponentState();
- extendedDataModel = iterationState.getDataModel();
- }
-
- boolean converterHasPartialState = Boolean.TRUE.equals(state[2]);
- Object savedConverterState = state[3];
- if (converterHasPartialState) {
- ((StateHolder) rowKeyConverter).restoreState(context, savedConverterState);
- } else {
- rowKeyConverter = (Converter) UIComponentBase.restoreAttachedState(context, savedConverterState);
- }
- }
-
- private boolean matchesBaseId(String clientId, String baseId, char separatorChar) {
- if (clientId.equals(baseId)) {
- return true;
- }
-
- // if clientId.startsWith(baseId + separatorChar)
- if (clientId.startsWith(baseId) && (clientId.length() > baseId.length())
- && (clientId.charAt(baseId.length()) == separatorChar)) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
- throws FacesException {
-
- if ((null == context) || (null == clientId) || (null == callback)) {
- throw new NullPointerException();
- }
-
- String baseId = super.getClientId(context);
-
- if (!matchesBaseId(clientId, baseId, UINamingContainer.getSeparatorChar(context))) {
- return false;
- }
-
- boolean found = false;
- Object oldRowKey = getRowKey();
-
- // TODO - this does not seem right
- captureOrigValue(context);
-
- try {
-
- // TODO - ?
- // if (null != oldRowKey) {
- setRowKey(context, null);
-
- // }
- if (clientId.equals(baseId)) {
- callback.invokeContextCallback(context, this);
- found = true;
- } else {
- Iterator<UIComponent> fixedChildrenItr = fixedChildren();
-
- while (fixedChildrenItr.hasNext() && !found) {
- UIComponent fixedChild = fixedChildrenItr.next();
-
- found = fixedChild.invokeOnComponent(context, clientId, callback);
- }
- }
-
- if (!found) {
- Object newRowKey = null;
-
- // Call for a child component - try to detect row key
- // baseId.length() + 1 expression skips SEPARATOR_CHAR
- //TODO - convertKeyString
- String rowKeyString = extractKeySegment(context, clientId.substring(baseId.length() + 1));
-
- if (rowKeyString != null) {
- Converter keyConverter = getRowKeyConverter();
-
- if (null != keyConverter) {
- try {
- //TODO: review
- newRowKey = keyConverter.getAsObject(context, this, rowKeyString);
- } catch (ConverterException e) {
-
- // TODO: LOG error
- }
- }
- }
-
- setRowKey(context, newRowKey);
-
- if (isRowAvailable()) {
- Iterator<UIComponent> dataChildrenItr = dataChildren();
-
- while (dataChildrenItr.hasNext() && !found) {
- UIComponent dataChild = dataChildrenItr.next();
-
- found = dataChild.invokeOnComponent(context, clientId, callback);
- }
- }
- }
- } catch (Exception e) {
- throw new FacesException(e);
- } finally {
-
- // if (null != oldRowKey) {
- try {
- setRowKey(context, oldRowKey);
- restoreOrigValue(context);
- } catch (Exception e) {
- LOG.error(e.getMessage(), e);
- }
-
- // }
- }
-
- return found;
- }
-
- // Tests whether we need to visit our children as part of
- // a tree visit
- private boolean doVisitChildren(VisitContext context, boolean visitRows) {
-
- // Just need to check whether there are any ids under this
- // subtree. Make sure row index is cleared out since
- // getSubtreeIdsToVisit() needs our row-less client id.
-
- // TODO check this
- if (visitRows) {
- setRowKey(context.getFacesContext(), null);
- }
-
- // TODO optimize for returned IDs
- Collection<String> idsToVisit = context.getSubtreeIdsToVisit(this);
-
- assert idsToVisit != null;
-
- if (idsToVisit == VisitContext.ALL_IDS) {
- // TODO
- }
-
- // All ids or non-empty collection means we need to visit our children.
- return !idsToVisit.isEmpty();
- }
-
- private boolean visitComponents(Iterator<UIComponent> components, VisitContext context, VisitCallback callback) {
-
- while (components.hasNext()) {
- UIComponent nextChild = components.next();
-
- if (nextChild.visitTree(context, callback)) {
- return true;
- }
- }
-
- return false;
- }
-
- protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
-
- return visitComponents(fixedChildren(), visitContext, callback);
- }
-
- protected VisitResult visitDataChildrenMetaComponents(ExtendedVisitContext extendedVisitContext, VisitCallback callback) {
- return VisitResult.ACCEPT;
- }
-
- protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback, boolean visitRows) {
-
- if (visitRows) {
- FacesContext facesContext = visitContext.getFacesContext();
-
- DataVisitorForVisitTree dataVisitor = new DataVisitorForVisitTree(callback, visitContext);
- this.walk(facesContext, dataVisitor, null);
-
- return dataVisitor.getVisitResult();
- } else {
- return visitComponents(dataChildren(), visitContext, callback);
- }
- }
-
- @Override
- public boolean visitTree(VisitContext visitContext, VisitCallback callback) {
-
- // First check to see whether we are visitable. If not
- // short-circuit out of this subtree, though allow the
- // visit to proceed through to other subtrees.
- if (!isVisitable(visitContext)) {
- return false;
- }
-
- // Clear out the row index is one is set so that
- // we start from a clean slate.
- FacesContext facesContext = visitContext.getFacesContext();
-
- // NOTE: that the visitRows local will be obsolete once the
- // appropriate visit hints have been added to the API
- boolean visitRows = requiresRowIteration(facesContext);
-
- Object oldRowKey = null;
- if (visitRows) {
- captureOrigValue(facesContext);
- oldRowKey = getRowKey();
- setRowKey(facesContext, null);
- }
-
- // Push ourselves to EL
- pushComponentToEL(facesContext, null);
-
- try {
-
- // Visit ourselves. Note that we delegate to the
- // VisitContext to actually perform the visit.
- VisitResult result = visitContext.invokeVisitCallback(this, callback);
-
- // If the visit is complete, short-circuit out and end the visit
- if (result == VisitResult.COMPLETE) {
- return true;
- }
-
- // Visit children, short-circuiting as necessary
- if ((result == VisitResult.ACCEPT) && doVisitChildren(visitContext, visitRows)) {
- if (visitRows) {
- setRowKey(facesContext, null);
- }
-
- if (visitFixedChildren(visitContext, callback)) {
- return true;
- }
-
- if (visitContext instanceof ExtendedVisitContext) {
- ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;
-
- Collection<String> directSubtreeIdsToVisit = extendedVisitContext.getDirectSubtreeIdsToVisit(this);
- if (directSubtreeIdsToVisit != VisitContext.ALL_IDS) {
- if (directSubtreeIdsToVisit.isEmpty()) {
- return false;
- } else {
- VisitContext directChildrenVisitContext =
- extendedVisitContext.createNamingContainerVisitContext(this, directSubtreeIdsToVisit);
-
- if (visitRows) {
- setRowKey(facesContext, null);
- }
- if (visitFixedChildren(directChildrenVisitContext, STUB_CALLBACK)) {
- return false;
- }
- }
- }
- }
-
- if (visitDataChildren(visitContext, callback, visitRows)) {
- return true;
- }
- }
- } finally {
-
- // Clean up - pop EL and restore old row index
- popComponentFromEL(facesContext);
-
- if (visitRows) {
- try {
- setRowKey(facesContext, oldRowKey);
- restoreOrigValue(facesContext);
- } catch (Exception e) {
-
- // TODO: handle exception
- LOG.error(e.getMessage(), e);
- }
- }
- }
-
- // Return false to allow the visit to continue
- return false;
- }
-
- /**
- * @param facesContext
- * @return
- */
- private boolean requiresRowIteration(FacesContext context) {
- return (!PhaseId.RESTORE_VIEW.equals(context.getCurrentPhaseId()));
- }
-
- /**
- * @param context
- * @param substring
- * @return
- */
- // TODO review!
- protected String extractKeySegment(FacesContext context, String substring) {
- char separatorChar = UINamingContainer.getSeparatorChar(context);
- int separatorIndex = substring.indexOf(separatorChar);
-
- if (separatorIndex < 0) {
- return null;
- } else {
- return substring.substring(0, separatorIndex);
- }
- }
-
- /**
- * Base class for visit data model at phases decode, validation and update model
- *
- * @author shura
- */
- protected abstract class ComponentVisitor implements DataVisitor {
- public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
- setRowKey(context, rowKey);
-
- if (isRowAvailable()) {
- Iterator<UIComponent> childIterator = dataChildren();
-
- while (childIterator.hasNext()) {
- UIComponent component = childIterator.next();
-
- processComponent(context, component, argument);
- }
- }
-
- return DataVisitResult.CONTINUE;
- }
-
- public abstract void processComponent(FacesContext context, UIComponent c, Object argument);
- }
-
- @Override
- public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
- super.processEvent(event);
-
- if (event instanceof PreRenderComponentEvent) {
- preEncodeBegin(getFacesContext());
- }
- }
-
- protected DataComponentState getLocalComponentState() {
- return componentState;
- }
-}
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig 2010-12-02 19:07:45 UTC (rev 20319)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig 2010-12-02 19:50:37 UTC (rev 20320)
@@ -1,575 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.component;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.MethodExpression;
-import javax.el.ValueExpression;
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UpdateModelException;
-import javax.faces.component.html.HtmlOutputText;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitResult;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ExceptionQueuedEvent;
-import javax.faces.event.ExceptionQueuedEventContext;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
-
-import org.ajax4jsf.model.DataComponentState;
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.richfaces.application.MessageFactory;
-import org.richfaces.application.ServiceTracker;
-import org.richfaces.appplication.FacesMessages;
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Signature;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.component.util.MessageUtil;
-import org.richfaces.context.ExtendedVisitContext;
-import org.richfaces.context.ExtendedVisitContextMode;
-import org.richfaces.convert.SequenceRowKeyConverter;
-import org.richfaces.event.TreeSelectionChangeEvent;
-import org.richfaces.event.TreeSelectionChangeListener;
-import org.richfaces.event.TreeSelectionChangeSource;
-import org.richfaces.event.TreeToggleEvent;
-import org.richfaces.event.TreeToggleListener;
-import org.richfaces.event.TreeToggleSource;
-import org.richfaces.model.DeclarativeTreeDataModelImpl;
-<<<<<<< HEAD
-import org.richfaces.model.DeclarativeTreeModel;
-=======
->>>>>>> RF-9680
-import org.richfaces.model.SwingTreeNodeDataModelImpl;
-import org.richfaces.model.TreeDataModel;
-import org.richfaces.model.TreeDataModelTuple;
-import org.richfaces.model.TreeDataVisitor;
-import org.richfaces.renderkit.MetaComponentRenderer;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-
-/**
- * @author Nick Belaevski
- *
- */
-@JsfComponent(
- type = AbstractTree.COMPONENT_TYPE,
- family = AbstractTree.COMPONENT_FAMILY,
- tag = @Tag(name = "tree", handler = "org.richfaces.view.facelets.TreeHandler"),
- renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer"),
- attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
-)
-//TODO add rowData caching for wrapper events
-public abstract class AbstractTree extends UIDataAdaptor implements MetaComponentResolver, MetaComponentEncoder, TreeSelectionChangeSource, TreeToggleSource {
-
- public static final String COMPONENT_TYPE = "org.richfaces.Tree";
-
- public static final String COMPONENT_FAMILY = "org.richfaces.Tree";
-
- public static final String SELECTION_META_COMPONENT_ID = "selection";
-
- private static final String DEFAULT_TREE_NODE_CREATED = AbstractTree.class.getName() + ":DEFAULT_TREE_NODE_CREATED";
-
- private static final class MatchingTreeNodePredicate implements Predicate<UIComponent> {
-
- private String type;
-
- public MatchingTreeNodePredicate(String type) {
- super();
- this.type = type;
- }
-
- public boolean apply(UIComponent input) {
- if (!(input instanceof AbstractTreeNode)) {
- return false;
- }
-
- String nodeType = ((AbstractTreeNode) input).getType();
- if (type == null && nodeType == null) {
- return true;
- }
-
- return type != null && type.equals(nodeType);
- }
- };
-
- private static final Converter ROW_KEY_CONVERTER = new SequenceRowKeyConverter();
-
- private enum PropertyKeys {
- selection
- }
-
- @SuppressWarnings("unused")
- @Attribute(generate = false, signature = @Signature(returnType = Void.class, parameters = TreeSelectionChangeEvent.class))
- private MethodExpression selectionChangeListener;
-
- @SuppressWarnings("unused")
- @Attribute(generate = false, signature = @Signature(returnType = Void.class, parameters = TreeToggleListener.class))
- private MethodExpression toggleListener;
-
- private transient TreeRange treeRange;
-
- public AbstractTree() {
- setKeepSaved(true);
- setRendererType("org.richfaces.TreeRenderer");
- }
-
- protected TreeRange getTreeRange() {
- if (treeRange == null) {
- treeRange = new TreeRange(this);
- }
-
- return treeRange;
- }
-
- public abstract Object getValue();
-
- public abstract boolean isImmediate();
-
- public abstract String getIconLeaf();
-
- public abstract String getIconExpanded();
-
- public abstract String getIconCollapsed();
-
- public abstract String getNodeClass();
-
- public abstract String getHandleClass();
-
- public abstract String getIconClass();
-
- public abstract String getLabelClass();
-
- @Attribute(events = @EventName("nodetoggle"))
- public abstract String getOnnodetoggle();
-
- @Attribute(events = @EventName("beforenodetoggle"))
- public abstract String getOnbeforenodetoggle();
-
- @Attribute(events = @EventName("selectionchange"))
- public abstract String getOnselectionchange();
-
- @Attribute(events = @EventName("beforeselectionchange"))
- public abstract String getOnbeforeselectionchange();
-
- @Attribute(defaultValue = "SwitchType.DEFAULT")
- public abstract SwitchType getToggleType();
-
- @Attribute(defaultValue = "SwitchType.client")
- public abstract SwitchType getSelectionType();
-
- public abstract String getNodeType();
-
- public abstract String getToggleNodeEvent();
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
- public Collection<Object> getSelection() {
- @SuppressWarnings("unchecked")
- Collection<Object> selection = (Collection<Object>) getStateHelper().eval(PropertyKeys.selection);
- if (selection == null) {
- selection = new HashSet<Object>();
-
- ValueExpression ve = getValueExpression(PropertyKeys.selection.toString());
- if (ve != null) {
- ve.setValue(getFacesContext().getELContext(), selection);
- } else {
- getStateHelper().put(PropertyKeys.selection, selection);
- }
- }
-
- return selection;
- }
-
- public void setSelection(Collection<Object> selection) {
- getStateHelper().put(PropertyKeys.selection, selection);
- }
-
- @Override
- protected DataComponentState createComponentState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Converter getRowKeyConverter() {
- Converter converter = super.getRowKeyConverter();
- if (converter == null) {
- converter = ROW_KEY_CONVERTER;
- }
- return converter;
- }
-
- protected Iterator<UIComponent> findMatchingTreeNodeComponent(String nodeType, UIComponent parentComponent) {
- Iterator<UIComponent> children = parentComponent.getChildren().iterator();
- if (parentComponent != this) {
- children = Iterators.concat(children, this.getChildren().iterator());
- }
-
- return Iterators.filter(children, new MatchingTreeNodePredicate(nodeType));
- }
-
- protected UIComponent getCurrentComponent() {
- ExtendedDataModel<?> dataModel = getExtendedDataModel();
- if (dataModel instanceof DeclarativeTreeModel) {
- return ((DeclarativeTreeModel) dataModel).getCurrentComponent();
- }
-
- return this;
- }
-
- public AbstractTreeNode findTreeNodeComponent() {
- FacesContext facesContext = getFacesContext();
-
- String nodeType = getNodeType();
-
- Iterator<UIComponent> nodesItr = findMatchingTreeNodeComponent(nodeType, getCurrentComponent());
-
- if (nodesItr.hasNext()) {
- Iterator<UIComponent> renderedNodesItr = Iterators.filter(nodesItr, ComponentPredicates.isRendered());
- if (renderedNodesItr.hasNext()) {
- return (AbstractTreeNode) renderedNodesItr.next();
- }
-
- return null;
- }
-
- if (Strings.isNullOrEmpty(nodeType)) {
- if (getAttributes().put(DEFAULT_TREE_NODE_CREATED, Boolean.TRUE) != null) {
- return null;
- }
-
- Application application = facesContext.getApplication();
- AbstractTreeNode treeNode = (AbstractTreeNode) application.createComponent(AbstractTreeNode.COMPONENT_TYPE);
- treeNode.setId("__defaultTreeNode");
-
- getChildren().add(treeNode);
-
- UIComponent text = application.createComponent(HtmlOutputText.COMPONENT_TYPE);
- text.setValueExpression("value", application.getExpressionFactory().createValueExpression(facesContext.getELContext(),
- "#{" + getVar() + "}", String.class));
- treeNode.getChildren().add(text);
-
- return treeNode;
- }
-
- return null;
- }
-
- @Override
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- super.broadcast(event);
-
- if (event instanceof TreeSelectionChangeEvent) {
- TreeSelectionChangeEvent selectionEvent = (TreeSelectionChangeEvent) event;
-
- final Collection<Object> newSelection = selectionEvent.getNewSelection();
-
- Collection<Object> selectionCollection = getSelection();
-
- Iterables.removeIf(selectionCollection, new Predicate<Object>() {
- public boolean apply(Object input) {
- return !newSelection.contains(input);
- };
- });
-
- if (!newSelection.isEmpty()) {
- Iterables.addAll(selectionCollection, newSelection);
- }
- } else if (event instanceof TreeToggleEvent) {
- TreeToggleEvent toggleEvent = (TreeToggleEvent) event;
- AbstractTreeNode treeNodeComponent = findTreeNodeComponent();
-
- boolean newExpandedValue = toggleEvent.isExpanded();
-
- FacesContext context = getFacesContext();
- ValueExpression expression = getValueExpression(AbstractTreeNode.PropertyKeys.expanded.toString());
- if (expression != null) {
- ELContext elContext = context.getELContext();
- Exception caught = null;
- FacesMessage message = null;
- try {
- expression.setValue(elContext, newExpandedValue);
- } catch (ELException e) {
- caught = e;
- String messageStr = e.getMessage();
- Throwable result = e.getCause();
- while (null != result &&
- result.getClass().isAssignableFrom(ELException.class)) {
- messageStr = result.getMessage();
- result = result.getCause();
- }
- if (null == messageStr) {
- MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
- message =
- messageFactory.createMessage(context, FacesMessages.UIINPUT_UPDATE,
- MessageUtil.getLabel(context, this));
- } else {
- message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
- messageStr,
- messageStr);
- }
- } catch (Exception e) {
- caught = e;
- MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
- message =
- messageFactory.createMessage(context, FacesMessages.UIINPUT_UPDATE,
- MessageUtil.getLabel(context, this));
- }
- if (caught != null) {
- assert(message != null);
- UpdateModelException toQueue = new UpdateModelException(message, caught);
- ExceptionQueuedEventContext eventContext =
- new ExceptionQueuedEventContext(context,
- toQueue,
- this,
- PhaseId.UPDATE_MODEL_VALUES);
- context.getApplication().publishEvent(context,
- ExceptionQueuedEvent.class,
- eventContext);
- }
- } else {
- treeNodeComponent.setExpanded(newExpandedValue);
- }
- }
- }
-
- @Override
- protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
- if (visitContext instanceof ExtendedVisitContext) {
- ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;
-
- if (ExtendedVisitContextMode.RENDER == extendedVisitContext.getVisitMode()) {
- VisitResult result = extendedVisitContext.invokeMetaComponentVisitCallback(this, callback, SELECTION_META_COMPONENT_ID);
- if (result != VisitResult.ACCEPT) {
- return result == VisitResult.COMPLETE;
- }
- }
- }
-
- return super.visitFixedChildren(visitContext, callback);
- }
-
- void decodeMetaComponent(FacesContext context, String metaComponentId) {
- ((MetaComponentRenderer) getRenderer(context)).decodeMetaComponent(context, this, metaComponentId);
- }
-
- public void encodeMetaComponent(FacesContext context, String metaComponentId) throws IOException {
- ((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(context, this, metaComponentId);
- }
-
- public String resolveClientId(FacesContext facesContext, UIComponent contextComponent, String metaComponentId) {
- if (SELECTION_META_COMPONENT_ID.equals(metaComponentId)) {
- return getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
- }
-
- return null;
- }
-
- public String substituteUnresolvedClientId(FacesContext facesContext, UIComponent contextComponent,
- String metaComponentId) {
-
- return null;
- }
-
- @Override
- protected Iterator<UIComponent> dataChildren() {
- AbstractTreeNode treeNodeComponent = findTreeNodeComponent();
- if (treeNodeComponent != null) {
- return Iterators.<UIComponent>singletonIterator(treeNodeComponent);
- } else {
- return Iterators.<UIComponent>emptyIterator();
- }
- }
-
- public void addTreeSelectionChangeListener(TreeSelectionChangeListener listener) {
- addFacesListener(listener);
- }
-
- @Attribute(hidden = true)
- public TreeSelectionChangeListener[] getTreeSelectionChangeListeners() {
- return (TreeSelectionChangeListener[]) getFacesListeners(TreeSelectionChangeListener.class);
- }
-
- public void removeTreeSelectionChangeListener(TreeSelectionChangeListener listener) {
- removeFacesListener(listener);
- }
-
- public void addTreeToggleListener(TreeToggleListener listener) {
- addFacesListener(listener);
- }
-
- @Attribute(hidden = true)
- public TreeToggleListener[] getTreeToggleListeners() {
- return (TreeToggleListener[]) getFacesListeners(TreeToggleListener.class);
- }
-
- public void removeTreeToggleListener(TreeToggleListener listener) {
- removeFacesListener(listener);
- }
-
- @Attribute(hidden = true)
- public boolean isExpanded() {
- if (getRowKey() == null) {
- return true;
- }
-
- AbstractTreeNode treeNode = findTreeNodeComponent();
- if (treeNode == null) {
- return false;
- }
-
- return treeNode.isExpanded();
- }
-
- //TODO review
- protected TreeDataModel<?> getTreeDataModel() {
- return (TreeDataModel<?>) getExtendedDataModel();
- }
-
- @Attribute(hidden = true)
- public boolean isLeaf() {
- if (getRowKey() == null) {
- return false;
- }
-
- return getTreeDataModel().isLeaf();
- }
-
- @Override
- public void walk(final FacesContext faces, final DataVisitor visitor, final Object argument) {
- walkModel(faces, new TreeDataVisitor() {
-
- public void enterNode() {
- visitor.process(faces, getRowKey(), argument);
- }
-
- public void exitNode() {
- }
-
- public void beforeChildrenVisit() {
- }
-
- public void afterChildrenVisit() {
- }
-
- });
- }
-
- @Override
- protected ExtendedDataModel<?> createExtendedDataModel() {
- ExtendedDataModel<?> dataModel;
-
- Object value = getValue();
- if (value == null) {
- dataModel = new DeclarativeTreeDataModelImpl(this, getVar(), getVariablesMap(getFacesContext()));
- } else {
- dataModel = new SwingTreeNodeDataModelImpl();
- dataModel.setWrappedData(getValue());
- }
-
- return dataModel;
- }
-
- public void walkModel(FacesContext context, TreeDataVisitor dataVisitor) {
- TreeDataModel<?> model = getTreeDataModel();
-
- if (!getTreeRange().shouldProcessNode()) {
- return;
- }
-
- boolean isRootNode = (getRowKey() == null);
-
- if (!isRootNode) {
- dataVisitor.enterNode();
- }
-
- walkModelChildren(context, dataVisitor, model);
-
- if (!isRootNode) {
- dataVisitor.exitNode();
- }
- }
-
- private void walkModelChildren(FacesContext context, TreeDataVisitor dataVisitor, TreeDataModel<?> model) {
- if (!getTreeRange().shouldIterateChildren()) {
- return;
- }
-
- dataVisitor.beforeChildrenVisit();
-
- Iterator<TreeDataModelTuple> childrenTuples = model.children();
- while (childrenTuples.hasNext()) {
- TreeDataModelTuple tuple = childrenTuples.next();
-
- restoreFromSnapshot(context, tuple);
-
- if (!getTreeRange().shouldProcessNode()) {
- continue;
- }
-
- dataVisitor.enterNode();
-
- walkModelChildren(context, dataVisitor, model);
-
- dataVisitor.exitNode();
- }
-
- dataVisitor.afterChildrenVisit();
- }
-
- @Override
- protected void resetDataModel() {
- super.resetDataModel();
- treeRange = null;
- }
-
- public TreeDataModelTuple createSnapshot() {
- return getTreeDataModel().createSnapshot();
- }
-
- public void restoreFromSnapshot(FacesContext context, TreeDataModelTuple tuple) {
- getTreeDataModel().restoreFromSnapshot(tuple);
- setRowKey(context, tuple.getRowKey());
- }
-
-}
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig 2010-12-02 19:07:45 UTC (rev 20319)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig 2010-12-02 19:50:37 UTC (rev 20320)
@@ -1,196 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.model;
-
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import javax.swing.tree.TreeNode;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class SwingTreeNodeDataModelImpl extends TreeSequenceKeyModel<Integer, TreeNode> {
-
- private final class SwingTreeNodeRowKeyIterator implements Iterator<TreeDataModelTuple> {
-
- private SequenceRowKey<Integer> baseKey;
-
- private Iterator<TreeNode> children;
-
- private int counter = 0;
-
- private SwingTreeNodeRowKeyIterator(SequenceRowKey<Integer> baseKey, Iterator<TreeNode> children) {
- this.baseKey = baseKey;
- this.children = children;
- }
-
- private int getNextCounterValue() {
- return counter++;
- }
-
- public boolean hasNext() {
- return children.hasNext();
- }
-
- public TreeDataModelTuple next() {
- TreeNode node = children.next();
-
- SequenceRowKey<Integer> key;
-
- if (baseKey != null) {
- key = baseKey.append(getNextCounterValue());
- } else {
- key = new SequenceRowKey<Integer>(getNextCounterValue());
- }
-
- return new TreeDataModelTuple(key, node);
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- }
-
- private final class FakeRootNode implements TreeNode {
-
- private Collection<TreeNode> wrappedData;
-
- public FakeRootNode(Collection<TreeNode> wrappedData) {
- super();
- this.wrappedData = wrappedData;
- }
-
- public boolean isLeaf() {
- return !wrappedData.isEmpty();
- }
-
- public TreeNode getParent() {
- return null;
- }
-
- public int getIndex(TreeNode node) {
- if (wrappedData == null) {
- return -1;
- }
-
- return Iterables.indexOf(wrappedData, Predicates.equalTo(node));
- }
-
- public int getChildCount() {
- if (wrappedData == null) {
- return 0;
- }
-
- return wrappedData.size();
- }
-
- public TreeNode getChildAt(int childIndex) {
- if (wrappedData == null) {
- throw new NoSuchElementException(String.valueOf(childIndex));
- }
-
- return Iterables.get(wrappedData, childIndex);
- }
-
- public boolean getAllowsChildren() {
- return true;
- }
-
- public Enumeration<?> children() {
- if (wrappedData == null) {
- return Iterators.asEnumeration(Iterators.emptyIterator());
- }
-
- return Iterators.asEnumeration(wrappedData.iterator());
- }
-
- public Collection<TreeNode> getWrappedData() {
- return wrappedData;
- }
- }
-
- private boolean asksAllowsChildren = false;
-
- private Iterator<TreeNode> safeGetChildren(TreeNode treeNode) {
- if (treeNode == null) {
- return Iterators.emptyIterator();
- }
-
- return Iterators.forEnumeration((Enumeration<TreeNode>) treeNode.children());
- }
-
-
- public Object getParentRowKey(Object rowKey) {
- throw new UnsupportedOperationException();
- }
-
- public void setWrappedData(Object data) {
- setRootNode(new FakeRootNode((Collection<TreeNode>) data));
- }
-
- public Collection<TreeNode> getWrappedData() {
- FakeRootNode rootNode = (FakeRootNode) getRootNode();
- if (rootNode == null) {
- return null;
- }
- return rootNode.getWrappedData();
- }
-
- protected TreeNode findChild(TreeNode parent, Integer simpleKey) {
- return parent.getChildAt(simpleKey.intValue());
- }
-
- public Iterator<TreeDataModelTuple> children() {
- return new SwingTreeNodeRowKeyIterator(getRowKey(), safeGetChildren(getData()));
- }
-
-
- public boolean isLeaf() {
- if (!asksAllowsChildren) {
- return getData().isLeaf();
- } else {
- return !getData().getAllowsChildren();
- }
- }
-
- @Override
- protected void walkNext(Integer segment) {
- TreeNode child = findChild(getData(), segment);
- //TODO what if node is missing?
- //TODO - optimize - remove partial keys creation
- setRowKeyAndData(safeGetRowKey().append(segment), child);
- }
-<<<<<<< HEAD
-
-=======
-
->>>>>>> RF-9680
-}
\ No newline at end of file
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig 2010-12-02 19:07:45 UTC (rev 20319)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig 2010-12-02 19:50:37 UTC (rev 20320)
@@ -1,180 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.model;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-
-
-/**
- * @author Nick Belaevski
- *
- */
-public abstract class TreeSequenceKeyModel<K, V> extends ExtendedDataModel<V> implements TreeDataModel<V> {
-
- private final SequenceRowKey<K> emptyKey = new SequenceRowKey<K>();
-
-<<<<<<< HEAD
- private V rootNode;
-
-=======
->>>>>>> RF-9680:
- private V data;
-
- private SequenceRowKey<K> rowKey;
-
- public SequenceRowKey<K> getRowKey() {
- return rowKey;
- }
-
- protected SequenceRowKey<K> safeGetRowKey() {
- SequenceRowKey<K> key = getRowKey();
-
- if (key == null) {
- key = emptyKey;
- }
-
- return key;
- }
-
- public void setRowKey(Object rowKey) {
- if (this.rowKey == null || !this.rowKey.equals(rowKey)) {
-<<<<<<< HEAD
- walkKey((SequenceRowKey<K>) rowKey);
- }
- }
-
- protected void resetRowKeyAndData() {
- setRowKeyAndData(null, rootNode);
- }
-
-=======
- this.rowKey = (SequenceRowKey<K>) rowKey;
- this.data = findData(this.rowKey);
- }
- }
-
->>>>>>> RF-9680:
- protected void setRowKeyAndData(SequenceRowKey<K> key, V data) {
- this.rowKey = key;
- this.data = data;
- }
-
- public boolean isDataAvailable() {
-<<<<<<< HEAD
- return getRowKey() == null || data != null;
-=======
- return data != null;
->>>>>>> RF-9680:
- }
-
- public V getData() {
- if (!isDataAvailable()) {
- throw new IllegalArgumentException();
- }
-
- return data;
- }
-<<<<<<< HEAD
-
- protected void walkKey(SequenceRowKey<K> key) {
- resetRowKeyAndData();
-=======
-
- protected V findData(SequenceRowKey<K> key) {
- if (key == null) {
- return rootNode;
- }
-
- V result = rootNode;
-
- for (K simpleKey : key.getSimpleKeys()) {
- result = findChild(result, simpleKey);
->>>>>>> RF-9680:
-
- if (key != null) {
- for (K simpleKey: key.getSimpleKeys()) {
- walkNext(simpleKey);
- }
- }
- }
-
- protected abstract void walkNext(K segment);
-
- protected V getRootNode() {
- return rootNode;
- }
-
- protected void setRootNode(V rootNode) {
- this.rootNode = rootNode;
- }
-
- //TODO ExtendedDataModel legacy
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
- throw new UnsupportedOperationException();
- }
-
-
- @Override
- public boolean isRowAvailable() {
- return isDataAvailable();
- }
-
-
- @Override
- public int getRowCount() {
- throw new UnsupportedOperationException();
- }
-
-
- @Override
- public V getRowData() {
- return getData();
- }
-
-
- @Override
- public int getRowIndex() {
- throw new UnsupportedOperationException();
- }
-
-
- @Override
- public void setRowIndex(int rowIndex) {
- throw new UnsupportedOperationException();
-<<<<<<< HEAD
- }
-
- public TreeDataModelTuple createSnapshot() {
- return new TreeDataModelTuple(getRowKey(), getData());
- }
-
- public void restoreFromSnapshot(TreeDataModelTuple tuple) {
- setRowKeyAndData((SequenceRowKey<K>) tuple.getRowKey(), (V) tuple.getData());
-=======
->>>>>>> RF-9680:
- }
-}
Deleted: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig 2010-12-02 19:07:45 UTC (rev 20319)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig 2010-12-02 19:50:37 UTC (rev 20320)
@@ -1,227 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.component.AbstractTree;
-import org.richfaces.component.AbstractTreeNode;
-import org.richfaces.component.util.HtmlUtil;
-import org.richfaces.model.TreeDataModelTuple;
-import org.richfaces.model.TreeDataVisitor;
-
-abstract class TreeEncoderBase implements TreeDataVisitor {
-
- private static final class QueuedData {
-
- private enum State {
- initial, visited, encoded
- }
-
- private State state = State.initial;
-
- private TreeDataModelTuple tuple;
-
- public QueuedData(TreeDataModelTuple tuple) {
- super();
- this.tuple = tuple;
- }
-
- public boolean isEncoded() {
- return state == State.encoded;
- }
-
- public void makeEncoded() {
- this.state = State.encoded;
- }
-
- public void makeVisited() {
- this.state = State.visited;
- }
-
- public boolean isVisited() {
- return state == State.visited;
- }
-
- public TreeDataModelTuple getTuple() {
- return tuple;
- }
-
- }
-
- static final String TREE_NODE_STATE_ATTRIBUTE = "__treeNodeState";
-
- protected final FacesContext context;
-
- protected final ResponseWriter responseWriter;
-
- protected final AbstractTree tree;
-
-<<<<<<< HEAD
- private LinkedList<QueuedData> queuedDataList = new LinkedList<QueuedData>();
-
-=======
->>>>>>> RF-9680:
- public TreeEncoderBase(FacesContext context, AbstractTree tree) {
- super();
- this.context = context;
- this.responseWriter = context.getResponseWriter();
- this.tree = tree;
- }
-
- protected void encodeTree() throws IOException {
- tree.walkModel(context, this);
- }
-
-<<<<<<< HEAD
- protected void flushParentNode() throws IOException {
- if (queuedDataList.isEmpty()) {
- return;
- }
-
- QueuedData data = queuedDataList.getLast();
- if (!data.isEncoded()) {
- data.makeEncoded();
- tree.restoreFromSnapshot(context, data.getTuple());
-
- TreeNodeState nodeState = getNodeState(tree.isLeaf(), false);
-
- writeTreeNodeStartElement(nodeState);
- tree.findTreeNodeComponent().encodeAll(context);
- }
- }
-
- private TreeNodeState getNodeState(boolean leaf, boolean visited) {
- TreeNodeState nodeState;
- if (leaf) {
- nodeState = TreeNodeState.leaf;
- } else if (visited) {
- nodeState = TreeNodeState.expandedNoChildren;
- } else if (tree.isExpanded()) {
- nodeState = TreeNodeState.expanded;
- } else {
- nodeState = TreeNodeState.collapsed;
- }
- return nodeState;
- }
-
- public void beforeChildrenVisit() {
- if (!queuedDataList.isEmpty()) {
- queuedDataList.getLast().makeVisited();
- }
- }
-
- public void afterChildrenVisit() {
- }
-
- public void enterNode() {
- TreeDataModelTuple tuple = tree.createSnapshot();
- QueuedData queuedData = new QueuedData(tuple);
-
- try {
- flushParentNode();
- } catch (IOException e) {
- throw new FacesException(e.getMessage(), e);
- }
-
- tree.restoreFromSnapshot(context, tuple);
- queuedDataList.add(queuedData);
- }
-
- public void exitNode() {
- QueuedData data = queuedDataList.removeLast();
-
- tree.restoreFromSnapshot(context, data.getTuple());
- try {
- if (!data.isEncoded()) {
- writeTreeNodeStartElement(getNodeState(tree.isLeaf(), data.isVisited()));
- tree.findTreeNodeComponent().encodeAll(context);
- }
-
-=======
- public void enterNode() {
- TreeNodeState state;
- if (tree.isLeaf()) {
- state = TreeNodeState.leaf;
- } else {
- if (tree.isExpanded()) {
- state = TreeNodeState.expanded;
- } else {
- state = TreeNodeState.collapsed;
- }
- }
-
- try {
- writeTreeNodeStartElement(state);
- tree.findTreeNodeComponent().encodeAll(context);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public void exitNode() {
- try {
->>>>>>> RF-9680:
- writeTreeNodeEndElement();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- protected void writeTreeNodeStartElement(TreeNodeState nodeState) throws IOException {
- AbstractTreeNode treeNodeComponent = tree.findTreeNodeComponent();
-
- context.getAttributes().put(TREE_NODE_STATE_ATTRIBUTE, nodeState);
-
- responseWriter.startElement(HtmlConstants.DIV_ELEM, tree);
- responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
- HtmlUtil.concatClasses("rf-tr-nd", nodeState.getNodeClass()),
- null);
- responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, treeNodeComponent.getClientId(context), null);
-
- emitClientToggleEvent(treeNodeComponent, nodeState);
- }
-
- protected void writeTreeNodeEndElement() throws IOException {
- responseWriter.endElement(HtmlConstants.DIV_ELEM);
- }
-
- public abstract void encode() throws IOException;
-
- private void emitClientToggleEvent(AbstractTreeNode treeNode, TreeNodeState nodeState) {
- if (treeNode.getClientId(context).equals(context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_ATTRIBUTE))) {
- TreeNodeState initialState = (TreeNodeState) context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_STATE_ATTRIBUTE);
-
- if (initialState.isDifferentThan(nodeState)) {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- ajaxContext.appendOncomplete(new JSFunction("RichFaces.ui.TreeNode.emitToggleEvent", treeNode.getClientId(context)));
- }
- }
- }
-}
\ No newline at end of file
13 years, 6 months
JBoss Rich Faces SVN: r20319 - in trunk: examples/output-demo/src/main/webapp/qunit and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-12-02 14:07:45 -0500 (Thu, 02 Dec 2010)
New Revision: 20319
Added:
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/PanelMenuTagHandler.java
Modified:
trunk/examples/output-demo/src/main/java/org/richfaces/ModalPanel.java
trunk/examples/output-demo/src/main/webapp/qunit/panelMenu.xhtml
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenu.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
Log:
RF-9317 panelMenu components
fix itemChangeListener and add action)
Modified: trunk/examples/output-demo/src/main/java/org/richfaces/ModalPanel.java
===================================================================
--- trunk/examples/output-demo/src/main/java/org/richfaces/ModalPanel.java 2010-12-02 18:53:41 UTC (rev 20318)
+++ trunk/examples/output-demo/src/main/java/org/richfaces/ModalPanel.java 2010-12-02 19:07:45 UTC (rev 20319)
@@ -1,196 +1,203 @@
package org.richfaces;
-import javax.faces.context.FacesContext;
-import javax.faces.event.ActionEvent;
+import org.richfaces.event.ItemChangeEvent;
+
import javax.faces.bean.ManagedBean;
-import javax.faces.bean.RequestScoped;
+import javax.faces.bean.SessionScoped;
+
@ManagedBean
-@RequestScoped
+@SessionScoped
public class ModalPanel {
- private boolean autosized;
- private boolean keepVisualState;
- private String left;
- private String top;
- private boolean rendered;
- private String shadowDepth;
- private String shadowOpacity;
- private boolean show;
- private int zindex;
- private int minHeight;
- private int minWidth;
- private int maxHeight;
- private int maxWidth;
- private int height;
- private int width;
- private boolean moveable;
- private boolean resizeable;
- private String inputTextTest;
- private String domElementAttachment;
-
+ private boolean autosized;
+ private boolean keepVisualState;
+ private String left;
+ private String top;
+ private boolean rendered;
+ private String shadowDepth;
+ private String shadowOpacity;
+ private boolean show;
+ private int zindex;
+ private int minHeight;
+ private int minWidth;
+ private int maxHeight;
+ private int maxWidth;
+ private int height;
+ private int width;
+ private boolean moveable;
+ private boolean resizeable;
+ private String inputTextTest;
+ private String domElementAttachment;
- public String getInputTextTest() {
- return inputTextTest;
- }
+ public String getInputTextTest() {
+ return inputTextTest;
+ }
- public void setInputTextTest(String inputTextTest) {
- this.inputTextTest = inputTextTest;
- }
+ public void setInputTextTest(String inputTextTest) {
+ this.inputTextTest = inputTextTest;
+ }
- public ModalPanel() {
- this.inputTextTest = "text";
- this.minHeight = 100;
- this.minWidth = 100;
- this.height = 300;
- this.width = 300;
- this.maxWidth = -1;
- this.maxHeight = -1;
- this.moveable=true;
- this.resizeable=true;
- this.autosized = false;
- this.keepVisualState = false;
- this.left = "auto";
- this.top = "auto";
- this.rendered = true;
- this.shadowDepth = "3";
- this.shadowOpacity = "3";
- this.show = false;
- this.domElementAttachment = "body";
- }
-
- public int getHeight() {
- return height;
- }
+ public ModalPanel() {
+ this.inputTextTest = "text";
+ this.minHeight = 100;
+ this.minWidth = 100;
+ this.height = 300;
+ this.width = 300;
+ this.maxWidth = -1;
+ this.maxHeight = -1;
+ this.moveable = true;
+ this.resizeable = true;
+ this.autosized = false;
+ this.keepVisualState = false;
+ this.left = "auto";
+ this.top = "auto";
+ this.rendered = true;
+ this.shadowDepth = "3";
+ this.shadowOpacity = "3";
+ this.show = false;
+ this.domElementAttachment = "body";
+ }
- public void setHeight(int height) {
- this.height = height;
- }
+ public int getHeight() {
+ return height;
+ }
- public int getMinHeight() {
- return minHeight;
- }
+ public void setHeight(int height) {
+ this.height = height;
+ }
- public void setMinHeight(int minHeight) {
- this.minHeight = minHeight;
- }
+ public int getMinHeight() {
+ return minHeight;
+ }
- public int getMaxWidth() {
- return maxWidth;
- }
+ public void setMinHeight(int minHeight) {
+ this.minHeight = minHeight;
+ }
- public void setMaxWidth(int maxWidth) {
- this.maxWidth = minWidth;
- }
-
- public int getMaxHeight() {
- return maxHeight;
- }
+ public int getMaxWidth() {
+ return maxWidth;
+ }
- public void setMaxHeight(int maxHeight) {
- this.maxHeight = maxHeight;
- }
+ public void setMaxWidth(int maxWidth) {
+ this.maxWidth = minWidth;
+ }
- public int getMinWidth() {
- return minWidth;
- }
+ public int getMaxHeight() {
+ return maxHeight;
+ }
- public void setMinWidth(int minWidth) {
- this.minWidth = minWidth;
- }
+ public void setMaxHeight(int maxHeight) {
+ this.maxHeight = maxHeight;
+ }
- public boolean isMoveable() {
- return moveable;
- }
+ public int getMinWidth() {
+ return minWidth;
+ }
- public void setMoveable(boolean moveable) {
- this.moveable = moveable;
- }
+ public void setMinWidth(int minWidth) {
+ this.minWidth = minWidth;
+ }
- public boolean isResizeable() {
- return resizeable;
- }
+ public boolean isMoveable() {
+ return moveable;
+ }
- public void setResizeable(boolean resizeable) {
- this.resizeable = resizeable;
- }
-
- public void setAutosized(boolean autosized) {
- this.autosized = autosized;
- }
+ public void setMoveable(boolean moveable) {
+ this.moveable = moveable;
+ }
+ public boolean isResizeable() {
+ return resizeable;
+ }
- public int getWidth() {
- return width;
- }
+ public void setResizeable(boolean resizeable) {
+ this.resizeable = resizeable;
+ }
- public void setWidth(int width) {
- this.width = width;
- }
+ public void setAutosized(boolean autosized) {
+ this.autosized = autosized;
+ }
- public boolean isAutosized() {
- return autosized;
- }
+ public int getWidth() {
+ return width;
+ }
- public boolean isKeepVisualState() {
- return keepVisualState;
- }
+ public void setWidth(int width) {
+ this.width = width;
+ }
- public void setKeepVisualState(boolean keepVisualState) {
- this.keepVisualState = keepVisualState;
- }
+ public boolean isAutosized() {
+ return autosized;
+ }
- public String getLeft() {
- return left;
- }
+ public boolean isKeepVisualState() {
+ return keepVisualState;
+ }
- public void setLeft(String left) {
- this.left = left;
- }
+ public void setKeepVisualState(boolean keepVisualState) {
+ this.keepVisualState = keepVisualState;
+ }
- public String getTop() {
- return top;
- }
+ public String getLeft() {
+ return left;
+ }
- public void setTop(String top) {
- this.top = top;
- }
+ public void setLeft(String left) {
+ this.left = left;
+ }
- public boolean getRendered() {
- return rendered;
- }
+ public String getTop() {
+ return top;
+ }
- public void setRendered(boolean rendered) {
- this.rendered = rendered;
- }
+ public void setTop(String top) {
+ this.top = top;
+ }
- public String getShadowDepth() {
- return shadowDepth;
- }
+ public boolean getRendered() {
+ return rendered;
+ }
- public void setShadowDepth(String shadowDepth) {
- this.shadowDepth = shadowDepth;
- }
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
- public String getShadowOpacity() {
- return shadowOpacity;
- }
+ public String getShadowDepth() {
+ return shadowDepth;
+ }
- public void setShadowOpacity(String shadowOpacity) {
- this.shadowOpacity = shadowOpacity;
- }
+ public void setShadowDepth(String shadowDepth) {
+ this.shadowDepth = shadowDepth;
+ }
- public boolean isShow() {
- return show;
- }
+ public String getShadowOpacity() {
+ return shadowOpacity;
+ }
- public void setShow(boolean show) {
- this.show = show;
- }
+ public void setShadowOpacity(String shadowOpacity) {
+ this.shadowOpacity = shadowOpacity;
+ }
- public String getDomElementAttachment() {
- return domElementAttachment;
- }
+ public boolean isShow() {
+ return show;
+ }
- public void setDomElementAttachment(String domElementAttachment) {
- this.domElementAttachment = domElementAttachment;
- }
+ public void setShow(boolean show) {
+ this.show = show;
+ }
+
+ public String getDomElementAttachment() {
+ return domElementAttachment;
+ }
+
+ public void setDomElementAttachment(String domElementAttachment) {
+ this.domElementAttachment = domElementAttachment;
+ }
+
+ public void itemChangeEventListener(ItemChangeEvent event) {
+ System.out.println("item was changed from '" + event.getOldItem() + "' to '" + event.getNewItem() + "'");
+ }
+
+ public void action() {
+ System.out.println("ModalPanel.action");
+ }
}
\ No newline at end of file
Modified: trunk/examples/output-demo/src/main/webapp/qunit/panelMenu.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/qunit/panelMenu.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
+++ trunk/examples/output-demo/src/main/webapp/qunit/panelMenu.xhtml 2010-12-02 19:07:45 UTC (rev 20319)
@@ -60,7 +60,10 @@
groupDisableIconLeft="disc"
topItemDisableIconLeft="disc"
topGroupDisableIconLeft="disc"
+ itemChangeListener="#{modalPanel.itemChangeEventListener}"
+ action="#{modalPanel.action}"
>
+
<pn:panelMenuGroup label="Group 1">
<pn:panelMenuItem label="Item 1.1" />
<pn:panelMenuItem label="Item 1.2" />
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java 2010-12-02 18:53:41 UTC (rev 20318)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractPanelMenu.java 2010-12-02 19:07:45 UTC (rev 20319)
@@ -25,11 +25,13 @@
import org.richfaces.PanelMenuMode;
import org.richfaces.event.ItemChangeEvent;
+import org.richfaces.event.ItemChangeListener;
+import org.richfaces.event.ItemChangeSource;
import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
@@ -37,7 +39,7 @@
* @author akolonitsky
* @since 2010-10-25
*/
-public abstract class AbstractPanelMenu extends UIOutput {
+public abstract class AbstractPanelMenu extends AbstractActionComponent implements ItemChangeSource {
public static final String COMPONENT_TYPE = "org.richfaces.PanelMenu";
@@ -113,8 +115,18 @@
}
}
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ if (event instanceof ItemChangeEvent
+ && (isBypassUpdates() || isImmediate())) {
+ FacesContext.getCurrentInstance().renderResponse();
+ }
+ }
+
+
public String getSubmittedActiveItem() {
return this.submittedActiveItem;
}
@@ -212,4 +224,18 @@
return null;
}
+
+ // ------------------------------------------------ Event Processing Methods
+
+ public void addItemChangeListener(ItemChangeListener listener) {
+ addFacesListener(listener);
+ }
+
+ public ItemChangeListener[] getItemChangeListeners() {
+ return (ItemChangeListener[]) getFacesListeners(ItemChangeListener.class);
+ }
+
+ public void removeItemChangeListener(ItemChangeListener listener) {
+ removeFacesListener(listener);
+ }
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenu.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenu.java 2010-12-02 18:53:41 UTC (rev 20318)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UIPanelMenu.java 2010-12-02 19:07:45 UTC (rev 20319)
@@ -105,14 +105,6 @@
getStateHelper().put(PropertyKeys.bubbleSelection, bubbleSelection);
}
- public String getActiveItem() {
- return (String) getStateHelper().eval(PropertyKeys.activeItem);
- }
-
- public void setActiveItem(String activeItem) {
- getStateHelper().put(PropertyKeys.activeItem, activeItem);
- }
-
public String getItemChangeListener() {
return (String) getStateHelper().eval(PropertyKeys.itemChangeListener);
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2010-12-02 18:53:41 UTC (rev 20318)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelMenuRenderer.java 2010-12-02 19:07:45 UTC (rev 20319)
@@ -35,6 +35,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -75,6 +76,8 @@
String compClientId = component.getClientId(context);
String clientId = requestMap.get(compClientId);
if (clientId != null && clientId.equals(compClientId)) {
+ new ActionEvent(component).queue();
+
AbstractPanelMenuItem panelItem = panelMenu.getItem(newValue);
if (panelItem != null) {
context.getPartialViewContext().getRenderIds().add(panelItem.getClientId(context));
Added: trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/PanelMenuTagHandler.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/PanelMenuTagHandler.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/PanelMenuTagHandler.java 2010-12-02 19:07:45 UTC (rev 20319)
@@ -0,0 +1,87 @@
+/**
+ * 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.view.facelets.html;
+
+import org.richfaces.event.ItemChangeEvent;
+import org.richfaces.event.ItemChangeSource;
+import org.richfaces.event.MethodExpressionItemChangeListener;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+/**
+ * @author akolonitsky
+ * @since Dec 2, 2010
+ */
+public class PanelMenuTagHandler extends ComponentHandler {
+
+ private static final MetaRule META_RULE = new PanelMenuMetaRule();
+
+
+ public PanelMenuTagHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRuleset = super.createMetaRuleset(type);
+ metaRuleset.addRule(META_RULE);
+ return metaRuleset;
+ }
+
+ private static class PanelMenuMetaRule extends MetaRule{
+
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(ItemChangeSource.class)) {
+ if ("itemChangeListener".equals(name)) {
+ return new ItemChangeExpressionMetadata(attribute);
+ }
+
+ }
+
+ return null;
+ }
+ }
+
+ private static final class ItemChangeExpressionMetadata extends Metadata {
+ private static final Class<?>[] ITEM_CHANGE_SIG = new Class[] {ItemChangeEvent.class };
+
+ private final TagAttribute attr;
+
+ ItemChangeExpressionMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((ItemChangeSource) instance).addItemChangeListener(new MethodExpressionItemChangeListener(
+ this.attr.getMethodExpression(ctx, null, ITEM_CHANGE_SIG)));
+ }
+ }
+}
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-02 18:53:41 UTC (rev 20318)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-12-02 19:07:45 UTC (rev 20319)
@@ -1638,7 +1638,20 @@
<component>
<component-type>org.richfaces.PanelMenu</component-type>
<component-class>org.richfaces.component.html.HtmlPanelMenu</component-class>
+
<property>
+ <property-name>action</property-name>
+ <property-class>javax.faces.el.MethodBinding</property-class>
+ </property>
+ <property>
+ <property-name>actionExpression</property-name>
+ <property-class>javax.el.MethodExpression</property-class>
+ </property>
+ <property>
+ <property-name>actionListener</property-name>
+ <property-class>javax.faces.el.MethodBinding</property-class>
+ </property>
+ <property>
<description></description>
<property-name>disabled</property-name>
<property-class>boolean</property-class>
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-02 18:53:41 UTC (rev 20318)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-12-02 19:07:45 UTC (rev 20319)
@@ -211,7 +211,6 @@
<component>
<component-type>org.richfaces.PanelMenuItem</component-type>
<renderer-type>org.richfaces.PanelMenuItem</renderer-type>
-
</component>
<attribute>
<description></description>
@@ -549,9 +548,30 @@
<component>
<component-type>org.richfaces.PanelMenu</component-type>
<renderer-type>org.richfaces.PanelMenu</renderer-type>
-
+ <handler-class>org.richfaces.view.facelets.html.PanelMenuTagHandler</handler-class>
</component>
<attribute>
+ <description>MethodExpression representing the application action to invoke when this component is activated by the user. The expression must evaluate to a public method that takes no parameters, and returns an Object (the toString() of which is called to derive the logical outcome) which is passed to the NavigationHandler for this application.</description>
+ <display-name>Application Action</display-name>
+ <icon/>
+ <name>action</name>
+ <type>javax.faces.el.MethodBinding</type>
+ </attribute>
+ <attribute>
+ <description>MethodExpression representing the application action to invoke when this component is activated by the user. The expression must evaluate to a public method that takes no parameters, and returns an Object (the toString() of which is called to derive the logical outcome) which is passed to the NavigationHandler for this application.</description>
+ <display-name>Application Action</display-name>
+ <icon/>
+ <name>actionExpression</name>
+ <type>javax.el.MethodExpression</type>
+ </attribute>
+ <attribute>
+ <description><p> MethodExpression representing an action listener method that will be notified when this component is activated by the user. The expression must evaluate to a public method that takes an ActionEvent parameter, with a return type of void, <span class="changed_added_2_0">or to a public method that takes no arguments with a return type of void. In the latter case, the method has no way of easily knowing where the event came from, but this can be useful in cases where a notification is needed that "some action happened".</span> </p></description>
+ <display-name>Action Listener</display-name>
+ <icon/>
+ <name>actionListener</name>
+ <type>javax.faces.el.MethodBinding</type>
+ </attribute>
+ <attribute>
<description></description>
<name>disabled</name>
<type>boolean</type>
13 years, 6 months
JBoss Rich Faces SVN: r20318 - in branches/RF-8742-1: examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar and 28 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-02 13:53:41 -0500 (Thu, 02 Dec 2010)
New Revision: 20318
Added:
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeNode.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeNodeImpl.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeyConverter.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/TreeConverterUtil.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeDataModelImpl.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeTuplesIterator.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig
branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert/
branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java
Removed:
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml
branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java
Modified:
branches/RF-8742-1/
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
branches/RF-8742-1/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
branches/RF-8742-1/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.ecss
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
branches/RF-8742-1/ui/input/ui/src/main/templates/select.template.xml
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/TreeRange.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/SequenceRowKeyConverter.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeModelKey.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelCompositeTuplesIterator.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelTuplesIterator.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeTuplesIterator.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
branches/RF-8742-1/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss
Log:
Merged revisions 20285,20289,20300,20303,20305,20309-20310,20315 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r20285 | abelevich | 2010-12-02 01:27:06 -0800 (Thu, 02 Dec 2010) | 1 line
remove def height
.......
r20289 | ilya_shaikovsky | 2010-12-02 02:15:11 -0800 (Thu, 02 Dec 2010) | 1 line
https://jira.jboss.org/browse/RF-9834
.......
r20300 | abelevich | 2010-12-02 03:59:05 -0800 (Thu, 02 Dec 2010) | 1 line
RF-9854, RF-9843
.......
r20303 | ilya_shaikovsky | 2010-12-02 05:20:26 -0800 (Thu, 02 Dec 2010) | 1 line
tree Adaptors, checkstyle fixes, PanelBar fixes after component refactoring.
.......
r20305 | abelevich | 2010-12-02 06:07:40 -0800 (Thu, 02 Dec 2010) | 1 line
RF-9576
.......
r20309 | nbelaevski | 2010-12-02 06:32:03 -0800 (Thu, 02 Dec 2010) | 1 line
RF-9680
.......
r20310 | nbelaevski | 2010-12-02 06:47:41 -0800 (Thu, 02 Dec 2010) | 3 lines
https://jira.jboss.org/browse/RF-9718
https://jira.jboss.org/browse/RF-9729
https://jira.jboss.org/browse/RF-9902
.......
r20315 | amarkhel | 2010-12-02 09:52:54 -0800 (Thu, 02 Dec 2010) | 1 line
@ResourceDependencies was added to wrap @ResourceDependency
.......
Property changes on: branches/RF-8742-1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-20272
+ /trunk:1-20317
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model (from rev 20315, trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model)
Deleted: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java 2010-12-02 17:52:54 UTC (rev 20315)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,54 +0,0 @@
-package org.richfaces.demo.calendar.model;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import javax.faces.bean.ApplicationScoped;
-import javax.faces.bean.ManagedBean;
-
-import org.richfaces.model.CalendarDataModel;
-import org.richfaces.model.CalendarDataModelItem;
-
-@ManagedBean
-@ApplicationScoped
-public class CalendarModel implements CalendarDataModel {
- private static final String WEEKEND_DAY_CLASS = "wdc";
- private static final String BUSY_DAY_CLASS = "bdc";
- private static final String BOUNDARY_DAY_CLASS = "rf-ca-boundary-dates";
-
- private boolean checkBusyDay(Calendar calendar) {
- return (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY);
- }
-
- private boolean checkWeekend(Calendar calendar) {
- return (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY);
- }
-
- public CalendarDataModelItem[] getData(Date[] dateArray) {
- CalendarDataModelItem[] modelItems = new CalendarModelItem[dateArray.length];
- Calendar current = GregorianCalendar.getInstance();
- Calendar today = GregorianCalendar.getInstance();
- today.setTime(new Date());
- for (int i = 0; i < dateArray.length; i++) {
- current.setTime(dateArray[i]);
- CalendarModelItem modelItem = new CalendarModelItem();
- if (current.before(today)) {
- modelItem.setEnabled(false);
- modelItem.setStyleClass(BOUNDARY_DAY_CLASS);
- } else if (checkBusyDay(current)){
- modelItem.setEnabled(false);
- modelItem.setStyleClass(BUSY_DAY_CLASS);
- }else if (checkWeekend(current)){
- modelItem.setEnabled(false);
- modelItem.setStyleClass(WEEKEND_DAY_CLASS);
- }else{
- modelItem.setEnabled(true);
- modelItem.setStyleClass("");
- }
- modelItems[i] = modelItem;
- }
-
- return modelItems;
- }
-}
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java (from rev 20315, trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java)
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java (rev 0)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,54 @@
+package org.richfaces.demo.calendar.model;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+
+import org.richfaces.model.CalendarDataModel;
+import org.richfaces.model.CalendarDataModelItem;
+
+@ManagedBean
+@ApplicationScoped
+public class CalendarModel implements CalendarDataModel {
+ private static final String WEEKEND_DAY_CLASS = "wdc";
+ private static final String BUSY_DAY_CLASS = "bdc";
+ private static final String BOUNDARY_DAY_CLASS = "rf-ca-boundary-dates";
+
+ private boolean checkBusyDay(Calendar calendar) {
+ return (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY);
+ }
+
+ private boolean checkWeekend(Calendar calendar) {
+ return (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY);
+ }
+
+ public CalendarDataModelItem[] getData(Date[] dateArray) {
+ CalendarDataModelItem[] modelItems = new CalendarModelItem[dateArray.length];
+ Calendar current = GregorianCalendar.getInstance();
+ Calendar today = GregorianCalendar.getInstance();
+ today.setTime(new Date());
+ for (int i = 0; i < dateArray.length; i++) {
+ current.setTime(dateArray[i]);
+ CalendarModelItem modelItem = new CalendarModelItem();
+ if (current.before(today)) {
+ modelItem.setEnabled(false);
+ modelItem.setStyleClass(BOUNDARY_DAY_CLASS);
+ } else if (checkBusyDay(current)){
+ modelItem.setEnabled(false);
+ modelItem.setStyleClass(BUSY_DAY_CLASS);
+ }else if (checkWeekend(current)){
+ modelItem.setEnabled(false);
+ modelItem.setStyleClass(WEEKEND_DAY_CLASS);
+ }else{
+ modelItem.setEnabled(true);
+ modelItem.setStyleClass("");
+ }
+ modelItems[i] = modelItem;
+ }
+
+ return modelItems;
+ }
+}
Deleted: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java 2010-12-02 17:52:54 UTC (rev 20315)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,25 +0,0 @@
-package org.richfaces.demo.calendar.model;
-
-import org.richfaces.model.CalendarDataModelItem;
-
-public class CalendarModelItem implements CalendarDataModelItem{
- private boolean enabled;
- private String styleClass;
-
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- public void setStyleClass(String styleClass) {
- this.styleClass = styleClass;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public String getStyleClass() {
- return styleClass;
- }
-}
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java (from rev 20315, trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java)
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java (rev 0)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,25 @@
+package org.richfaces.demo.calendar.model;
+
+import org.richfaces.model.CalendarDataModelItem;
+
+public class CalendarModelItem implements CalendarDataModelItem{
+ private boolean enabled;
+ private String styleClass;
+
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public void setStyleClass(String styleClass) {
+ this.styleClass = styleClass;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public String getStyleClass() {
+ return styleClass;
+ }
+}
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -4,30 +4,31 @@
import javax.faces.bean.RequestScoped;
import org.richfaces.event.ItemChangeEvent;
+
@ManagedBean
@RequestScoped
public class PanelMenuBean {
- private String current;
- private boolean singleMode;
- public boolean isSingleMode() {
- return singleMode;
- }
+ private String current;
+ private boolean singleMode;
- public void setSingleMode(boolean singleMode) {
- this.singleMode = singleMode;
- }
+ public boolean isSingleMode() {
+ return singleMode;
+ }
- public PanelMenuBean() {
- }
-
- public String getCurrent() {
- return this.current;
- }
-
- public void setCurrent(String current) {
- this.current = current;
- }
- public void updateCurrent(ItemChangeEvent event) {
- setCurrent(event.getNewItem());
- }
+ public void setSingleMode(boolean singleMode) {
+ this.singleMode = singleMode;
+ }
+
+ public String getCurrent() {
+ return this.current;
+ }
+
+ public void setCurrent(String current) {
+ this.current = current;
+ }
+
+ public void updateCurrent(ItemChangeEvent event) {
+ setCurrent(event.getNewItem());
+ System.out.println(event.getNewItem());
+ }
}
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/progressBar/ProgressBarBean.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -11,18 +11,18 @@
/**
* @author Ilya Shaikovsky
- *
+ *
*/
@ManagedBean
@ViewScoped
public class ProgressBarBean implements Serializable {
-
+
private static final long serialVersionUID = -314414475508376585L;
private boolean buttonRendered = true;
- private boolean enabled=false;
+ private boolean enabled = false;
private Long startTime;
-
+
public String startProcess() {
setEnabled(true);
setButtonRendered(false);
@@ -30,24 +30,23 @@
return null;
}
- public Long getCurrentValue(){
+ public Long getCurrentValue() {
if (isEnabled()) {
- Long current = (new Date().getTime() - startTime)/1000;
- if (current>100){
+ Long current = (new Date().getTime() - startTime) / 1000;
+ if (current >= 100) {
setButtonRendered(true);
} else if (current.equals(0)) {
return new Long(1);
}
- return (new Date().getTime() - startTime)/1000;
- }
+ return (new Date().getTime() - startTime) / 1000;
+ }
if (startTime == null) {
return Long.valueOf(-1);
} else {
- return Long.valueOf(101);
+ return Long.valueOf(100);
}
-
}
-
+
public boolean isEnabled() {
return enabled;
}
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/TreeBean.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -50,7 +50,7 @@
private List<TreeNode> rootNodes = new ArrayList<TreeNode>();
private Map<String, Country> countriesCache = new HashMap<String, Country>();
private Map<String, Company> companiesCache = new HashMap<String, Company>();
-
+ private Object currentSelection;
@PostConstruct
public void init() {
for (CDXmlDescriptor current : cdXmlDescriptors) {
@@ -62,6 +62,13 @@
company.getCds().add(cd);
}
}
+
+ public void selectionChanged(TreeSelectionChangeEvent selectionChangeEvent){
+ //considering only single selection
+ List<Object> selection = new ArrayList<Object>(selectionChangeEvent.getNewSelection());
+ currentSelection = selection.get(0);
+
+ }
private Country getCountryByName(CDXmlDescriptor descriptor) {
String countryName = descriptor.getCountry();
@@ -88,10 +95,6 @@
return company;
}
- private void selectionListener(TreeSelectionChangeEvent event) {
- //TODO: implement when ready
- }
-
public List<CDXmlDescriptor> getCdXmlDescriptors() {
return cdXmlDescriptors;
}
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors (from rev 20315, trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors)
Deleted: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java 2010-12-02 17:52:54 UTC (rev 20315)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,22 +0,0 @@
-package org.richfaces.demo.tree.adaptors;
-
-import java.util.List;
-
-import javax.faces.bean.ManagedBean;
-import javax.faces.bean.RequestScoped;
-
-@ManagedBean
-@RequestScoped
-public class FileSystemBean {
- private static final String SRC_PATH = "/WEB-INF";
-
- private List<FileSystemNode> srcRoots;
-
- public synchronized List<FileSystemNode> getSourceRoots() {
- if (srcRoots == null) {
- srcRoots = new FileSystemNode(SRC_PATH).getNodes();
- }
-
- return srcRoots;
- }
-}
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java (from rev 20315, trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java)
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java (rev 0)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemBean.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,22 @@
+package org.richfaces.demo.tree.adaptors;
+
+import java.util.List;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+@ManagedBean
+@RequestScoped
+public class FileSystemBean {
+ private static final String SRC_PATH = "/WEB-INF";
+
+ private List<FileSystemNode> srcRoots;
+
+ public synchronized List<FileSystemNode> getSourceRoots() {
+ if (srcRoots == null) {
+ srcRoots = new FileSystemNode(SRC_PATH).getNodes();
+ }
+
+ return srcRoots;
+ }
+}
Deleted: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java 2010-12-02 17:52:54 UTC (rev 20315)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,51 +0,0 @@
-package org.richfaces.demo.tree.adaptors;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-public class FileSystemNode {
- private String path;
-
- private List<FileSystemNode> children;
-
- private String shortPath;
-
- public FileSystemNode(String path) {
- this.path = path;
- int idx = path.lastIndexOf('/');
- if (idx != -1) {
- shortPath = path.substring(idx + 1);
- } else {
- shortPath = path;
- }
- }
-
- public synchronized List<FileSystemNode> getNodes() {
- if (children == null) {
- children = new ArrayList<FileSystemNode>();
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ExternalContext externalContext = facesContext.getExternalContext();
- Set resourcePaths = externalContext.getResourcePaths(this.path);
- if (resourcePaths != null) {
- Object[] nodes = (Object[]) resourcePaths.toArray();
- for (Object node : nodes) {
- String nodePath = node.toString();
- if (nodePath.endsWith("/")) {
- nodePath = nodePath.substring(0, nodePath.length() - 1);
- }
- children.add(new FileSystemNode(nodePath));
- }
- }
- }
- return children;
- }
-
- public String getShortPath() {
- return shortPath;
- }
-
-}
\ No newline at end of file
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java (from rev 20315, trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java)
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java (rev 0)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/adaptors/FileSystemNode.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,51 @@
+package org.richfaces.demo.tree.adaptors;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+public class FileSystemNode {
+ private String path;
+
+ private List<FileSystemNode> children;
+
+ private String shortPath;
+
+ public FileSystemNode(String path) {
+ this.path = path;
+ int idx = path.lastIndexOf('/');
+ if (idx != -1) {
+ shortPath = path.substring(idx + 1);
+ } else {
+ shortPath = path;
+ }
+ }
+
+ public synchronized List<FileSystemNode> getNodes() {
+ if (children == null) {
+ children = new ArrayList<FileSystemNode>();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Set resourcePaths = externalContext.getResourcePaths(this.path);
+ if (resourcePaths != null) {
+ Object[] nodes = (Object[]) resourcePaths.toArray();
+ for (Object node : nodes) {
+ String nodePath = node.toString();
+ if (nodePath.endsWith("/")) {
+ nodePath = nodePath.substring(0, nodePath.length() - 1);
+ }
+ children.add(new FileSystemNode(nodePath));
+ }
+ }
+ }
+ return children;
+ }
+
+ public String getShortPath() {
+ return shortPath;
+ }
+
+}
\ No newline at end of file
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
- NOTES(TODO: move to some readme in future): id for sample should
- equals to xhtml page name with the sample the same for demo id - it
- should be equals to name of the folder where samples placed
- -->
+<!-- NOTES(TODO: move to some readme in future): id for sample should equals
+ to xhtml page name with the sample the same for demo id - it should be equals
+ to name of the folder where samples placed -->
<root>
<group>
<name>Ajax Action</name>
<demos>
<demo>
- <id>ajax</id>
+ <id>ajax</id>
<name>a4j:ajax</name>
<samples>
<sample>
@@ -174,21 +172,10 @@
</demo>
</demos>
</group>
- <!-- group>
- <name>Validation</name>
- <demos>
- <demo>
- <id>clientValidation</id>
- <name>Ajax/Client Validation</name>
- <samples>
- <sample>
- <id>ajaxValidation</id>
- <name>Simple Ajax Validation</name>
- </sample>
- </samples>
- </demo>
- </demos>
- </group-->
+ <!-- group> <name>Validation</name> <demos> <demo> <id>clientValidation</id>
+ <name>Ajax/Client Validation</name> <samples> <sample> <id>ajaxValidation</id>
+ <name>Simple Ajax Validation</name> </sample> </samples> </demo> </demos>
+ </group -->
<group>
<name>Data Iteration</name>
<demos>
@@ -215,14 +202,10 @@
<name>Data Table Styling</name>
<description>
<!-- TODO: rowClass should appears at this sample after completion -->
- <!--
- TODO: rowClasses should be used instead of jQuerry selectors
- after will works
- -->
- <!--
- TODO: onrowmouseover, onrowmouseout - should be used instead of
- jQuery selector
- -->
+ <!-- TODO: rowClasses should be used instead of jQuerry selectors
+ after will works -->
+ <!-- TODO: onrowmouseover, onrowmouseout - should be used instead
+ of jQuery selector -->
</description>
</sample>
<sample>
@@ -246,7 +229,7 @@
<sample>
<id>exTableSelection</id>
<name>ExtendedData Table Selection usage</name>
- </sample>
+ </sample>
</samples>
</demo>
<demo>
@@ -308,6 +291,16 @@
</sample>
</samples>
</demo>
+ <demo new="true">
+ <id>treeAdaptors</id>
+ <name>Tree Adaptors</name>
+ <samples>
+ <sample>
+ <id>treeModelRecursiveAdaptor</id>
+ <name>Simple treeModelRecursiveAdaptor usage</name>
+ </sample>
+ </samples>
+ </demo>
</demos>
</group>
<group>
@@ -334,7 +327,7 @@
<sample>
<id>simple</id>
<name>Simple Toggle Panel</name>
- </sample>
+ </sample>
</samples>
</demo>
<demo>
@@ -346,18 +339,15 @@
<description>Simple Tab Panels</description>
<name>Simple Tab Panels</name>
</sample>
- <!-- sample>
- <id>headerCustomization</id>
- <description>Headers Customization</description>
- <name>Headers Customization</name>
- </sample-->
- <sample>
+ <!-- sample> <id>headerCustomization</id> <description>Headers Customization</description>
+ <name>Headers Customization</name> </sample -->
+ <sample>
<id>valueManagement</id>
<description>Selected Tab Management</description>
<name>Selected Tab Management</name>
- </sample>
+ </sample>
</samples>
- </demo>
+ </demo>
<demo>
<id>collapsiblePanel</id>
<name>rich:collapsiblePanel</name>
@@ -371,13 +361,13 @@
<demo>
<id>accordion</id>
<name>rich:accordion</name>
- <samples>
+ <samples>
<sample>
<id>simple</id>
<name>Simple Accordion</name>
</sample>
- </samples>
- </demo>
+ </samples>
+ </demo>
<demo>
<id>popup</id>
<name>rich:popupPanel</name>
@@ -415,13 +405,13 @@
<name>Simple tooltips</name>
</sample>
</samples>
- </demo>
+ </demo>
</demos>
</group>
<group>
<name>Menus</name>
<demos>
- <demo new="true">
+ <demo new="true">
<id>panelMenu</id>
<name>rich:panelMenu</name>
<samples>
@@ -431,7 +421,7 @@
</sample>
</samples>
</demo>
- <demo new="true">
+ <demo new="true">
<id>toolBar</id>
<name>rich:toolBar</name>
<samples>
@@ -449,7 +439,7 @@
</group>
<group>
<name>Inputs and Selects</name>
- <demos>
+ <demos>
<demo>
<id>autocomplete</id>
<name>rich:autocomplete</name>
@@ -457,14 +447,14 @@
<sample>
<id>cachedAjax</id>
<name>Autocomplete in Cached Ajax mode</name>
- </sample>
+ </sample>
<sample>
<id>clientFilter</id>
<name>Custom client filter</name>
- </sample>
+ </sample>
</samples>
</demo>
- <demo>
+ <demo new="true">
<id>calendar</id>
<name>rich:calendar</name>
<samples>
@@ -475,7 +465,11 @@
<sample new="true">
<id>clientStylingDisablement</id>
<name>Client Side Styling/Disablement</name>
- </sample>
+ </sample>
+ <sample new="true">
+ <id>dataModel</id>
+ <name>Data Model Support</name>
+ </sample>
</samples>
</demo>
<demo>
@@ -507,7 +501,7 @@
<name>Inplace Inputs samples</name>
</sample>
</samples>
- </demo>
+ </demo>
<demo>
<id>inplaceSelect</id>
<name>rich:inplaceSelect</name>
@@ -517,7 +511,7 @@
<name>Inplace Selects samples</name>
</sample>
</samples>
- </demo>
+ </demo>
<demo>
<id>select</id>
<name>rich:select</name>
@@ -527,8 +521,8 @@
<name>Selects samples</name>
</sample>
</samples>
- </demo>
- </demos>
+ </demo>
+ </demos>
</group>
<group>
<name>Misc Components/Features</name>
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml (from rev 20315, trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml)
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml (rev 0)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>Calendar may use a special Data Model to provide data for
+ element rendering. You can re-define the default Calendar Model using
+ the dataModel attribute pointed to the object that implements
+ CalendarDataModel interface.</p>
+ <p>In next simple example next rules applied using model:</p>
+ <ul>
+ <li>Weekend days are disabled (sunday and saturday) and uses bold
+ and italic text style.</li>
+ <li>Thuesday and Thursday are disabled also. (just RichFaces team
+ meeting days) So grayed out as busy days.</li>
+ <li>All the values in the past disabed and styled as boundary
+ dates.</li>
+ </ul>
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
+ value="/WEB-INF/src/org/richfaces/demo/calendar/model/CalendarModel.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View CalendarModel Source" />
+ <ui:param name="hideLabel" value="Hide CalendarModel Source" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
+ value="/WEB-INF/src/org/richfaces/demo/calendar/model/CalendarModelItem.java" />
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View CalendarModelItem Source" />
+ <ui:param name="hideLabel" value="Hide CalendarModelItem Source" />
+ </ui:include>
+ <p>Calendar may use a special Data Model to provide data for
+ element rendering. You can re-define the default Calendar Model using
+ the dataModel attribute pointed to the object that implements
+ <b>CalendarDataModel</b> interface.</p>
+ <p>CalendarDataModel has the following methods:</p>
+ <ul>
+ <li><b>CalendarDataModelItem[] getData(Date[])</b> is called every time
+ when components need the next block of CalendarDataItems. That may
+ happens when the calendar is rendered, or when you navigate to the
+ next/previous month or in any other case when the calendar is
+ rendered. This method is called in an Ajax mode when the calendar
+ renders a new page.</li>
+ </ul>
+ <p>CalendarDataModelItem provides the following methods:</p>
+ <ul>
+ <li><b>Boolean isEnabled()</b> returns "true" if date is "selectable" on
+ the calendar, the default implementation returns "true"</li>
+ <li><b>String getStyleClass()</b> returns "String" that is appended to a
+ style class for the date span. For example it may be "relevant
+ holiday" that means a class looks like "rich-cal-day relevant
+ holiday". The default implementation returns an empty string.</li>
+ </ul>
+</ui:composition>
+
+</html>
\ No newline at end of file
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -34,5 +34,4 @@
</script>
<rich:calendar dayDisableFunction="disablementFunction"
dayClassFunction="disabledClassesProv" boundaryDatesMode="scroll" />
-
</ui:composition>
\ No newline at end of file
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml (from rev 20315, trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml)
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml (rev 0)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,22 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <style>
+.bdc {
+ background-color: gray;
+}
+
+.wdc {
+ font-weight: bold;
+ font-style: italic;
+}
+</style>
+ <h:form>
+ <rich:calendar mode="ajax" boundaryDatesMode="scroll"
+ dataModel="#{calendarModel}" />
+ </h:form>
+</ui:composition>
\ No newline at end of file
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -16,7 +16,7 @@
iconExpandedGroup="disc" iconCollapsedGroup="disc"
iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
iconCollapsedTopGroup="chevronDown"
- itemChangeListener="#{panelMenuBean.updateCurrent}">
+ activeItem="#{panelMenuBean.current}">
<rich:panelMenuGroup label="Group 1">
<rich:panelMenuItem label="Item 1.1">
<f:param name="current" value="Item 1.1" />
@@ -71,8 +71,5 @@
</a4j:outputPanel>
</rich:panel>
</h:panelGrid>
- <rich:tabPanel>
- <rich:tab label="12 ">asdasd</rich:tab>
- </rich:tabPanel>
</h:form>
</ui:composition>
\ No newline at end of file
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/progressBar/samples/ajaxProgressBar-sample.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -5,28 +5,29 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <h:form id="form">
- <rich:progressBar mode="ajax" value="#{progressBarBean.currentValue}"
- interval="2000"
- enabled="#{progressBarBean.enabled}" minValue="-1" maxValue="100"
- reRenderAfterComplete="progressPanel">
- <f:facet name="initial">
- <br />
- <h:outputText value="Process doesn't started yet" />
- <a4j:commandButton action="#{progressBarBean.startProcess}"
- value="Start Process" execute="@form"
- rendered="#{progressBarBean.buttonRendered}"
- style="margin: 9px 0px 5px;" />
- </f:facet>
- <f:facet name="complete">
- <br />
- <h:outputText value="Process Done" />
- <a4j:commandButton action="#{progressBarBean.startProcess}"
- value="Restart Process" execute="@form"
- rendered="#{progressBarBean.buttonRendered}"
- style="margin: 9px 0px 5px;" />
- </f:facet>
- <h:outputText value="#{progressBarBean.currentValue} %"/>
- </rich:progressBar>
- </h:form>
+ <h:form id="form">
+ <rich:progressBar mode="ajax" value="#{progressBarBean.currentValue}"
+ interval="2000" id="pb" enabled="#{progressBarBean.enabled}"
+ minValue="0" maxValue="100" reRenderAfterComplete="progressPanel">
+ <f:facet name="initial">
+ <h:panelGroup>
+ <h:outputText value="Process doesn't started yet" />
+ <a4j:commandButton action="#{progressBarBean.startProcess}"
+ value="Start Process" execute="@form" render="pb"
+ rendered="#{progressBarBean.buttonRendered}"
+ style="margin: 9px 0px 5px;" />
+ </h:panelGroup>
+ </f:facet>
+ <f:facet name="finish">
+ <h:panelGroup>
+ <h:outputText value="Process Done" />
+ <a4j:commandButton action="#{progressBarBean.startProcess}"
+ value="Restart Process" execute="@form"
+ rendered="#{progressBarBean.buttonRendered}"
+ style="margin: 9px 0px 5px;" />
+ </h:panelGroup>
+ </f:facet>
+ <h:outputText value="#{progressBarBean.currentValue} %" />
+ </rich:progressBar>
+ </h:form>
</ui:composition>
\ No newline at end of file
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -7,7 +7,8 @@
xmlns:rich="http://richfaces.org/rich">
<rich:tree id="tree" nodeType="#{node.type}" var="node"
- value="#{treeBean.rootNodes}" toggleType="client">
+ value="#{treeBean.rootNodes}" toggleType="client"
+ >
<rich:treeNode type="country">
#{node.name}
</rich:treeNode>
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors (from rev 20315, trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors)
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples (from rev 20315, trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples)
Deleted: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml 2010-12-02 17:52:54 UTC (rev 20315)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,18 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich">
-
- <h:form>
- <rich:tree style="width:300px" toggleType="ajax" var="item">
- <rich:treeModelRecursiveAdaptor roots="#{fileSystemBean.sourceRoots}" nodes="#{item.nodes}" >
- <rich:treeNode>
- #{item.shortPath}
- </rich:treeNode>
- </rich:treeModelRecursiveAdaptor>
- </rich:tree>
- </h:form>
-</ui:composition>
\ No newline at end of file
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml (from rev 20315, trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml)
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml (rev 0)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+
+ <h:form>
+ <rich:tree style="width:300px" toggleType="ajax" var="item">
+ <rich:treeModelRecursiveAdaptor roots="#{fileSystemBean.sourceRoots}" nodes="#{item.nodes}" >
+ <rich:treeNode>
+ #{item.shortPath}
+ </rich:treeNode>
+ </rich:treeModelRecursiveAdaptor>
+ </rich:tree>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Deleted: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml 2010-12-02 17:52:54 UTC (rev 20315)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,18 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:ui="http://java.sun.com/jsf/facelets">
-
-<ui:composition>
- <p>DESC</p>
- <ui:include src="#{demoNavigator.sampleIncludeURI}" />
- <ui:include src="/templates/includes/source-view.xhtml">
- <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
- <ui:param name="sourceType" value="xhtml" />
- <ui:param name="openLabel" value="View Source" />
- <ui:param name="hideLabel" value="Hide Source" />
- </ui:include>
-</ui:composition>
-
-</html>
\ No newline at end of file
Copied: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml (from rev 20315, trunk/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml)
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml (rev 0)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/treeModelRecursiveAdaptor.xhtml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,18 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>DESC</p>
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+</ui:composition>
+
+</html>
\ No newline at end of file
Copied: branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig (from rev 20315, trunk/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig)
===================================================================
--- branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig (rev 0)
+++ branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java.orig 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,1523 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHelper;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.UniqueIdVendor;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ComponentSystemEventListener;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PostValidateEvent;
+import javax.faces.event.PreRenderComponentEvent;
+import javax.faces.event.PreValidateEvent;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.component.IterationStateHolder;
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SerializableDataModel;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+
+/**
+ * Base class for iterable components, like dataTable, Tomahawk dataList, Facelets repeat, tree etc., with support for
+ * partial rendering on AJAX responces for one or more selected iterations.
+ *
+ * @author shura
+ */
+@ListenerFor(systemEventClass = PreRenderComponentEvent.class)
+public abstract class UIDataAdaptor extends UIComponentBase implements NamingContainer,
+ UniqueIdVendor, IterationStateHolder, ComponentSystemEventListener {
+
+ /**
+ * <p>The standard component family for this component.</p>
+ */
+ public static final String COMPONENT_FAMILY = "org.richfaces.Data";
+
+ /**
+ * <p>The standard component type for this component.</p>
+ */
+ public static final String COMPONENT_TYPE = "org.richfaces.Data";
+
+ private static final class IterationState implements Serializable {
+
+ private static final long serialVersionUID = -3502645160277416066L;
+
+ private DataComponentState componentState;
+
+ private Object savedComponentState;
+
+ private boolean componentStateIsStateHolder;
+
+ private ExtendedDataModel<?> dataModel;
+
+ public IterationState() {
+ super();
+ }
+
+ public IterationState(DataComponentState componentState, ExtendedDataModel<?> dataModel) {
+ super();
+ this.componentState = componentState;
+ this.dataModel = dataModel;
+ }
+
+ public ExtendedDataModel<?> getDataModel() {
+ return dataModel;
+ }
+
+ public DataComponentState getComponentState() {
+ return componentState;
+ }
+
+ /**
+ * @param uiDataAdaptor
+ */
+ public void restoreComponentState(UIDataAdaptor uiDataAdaptor) {
+ if (savedComponentState != null && componentStateIsStateHolder) {
+ componentState = uiDataAdaptor.createComponentState();
+ ((StateHolder) componentState).restoreState(FacesContext.getCurrentInstance(), savedComponentState);
+ savedComponentState = null;
+ }
+ }
+
+ final Object saveState() {
+ boolean localComponentStateIsHolder = false;
+ Object localSavedComponentState = null;
+
+ if (componentState != null) {
+ if (componentState instanceof StateHolder) {
+ localComponentStateIsHolder = true;
+
+ StateHolder stateHolder = (StateHolder) componentState;
+ if (!stateHolder.isTransient()) {
+ localSavedComponentState = stateHolder.saveState(FacesContext.getCurrentInstance());
+ }
+ } else {
+ if (componentState instanceof Serializable) {
+ localSavedComponentState = componentState;
+ }
+ }
+ }
+
+ Object savedSerializableModel = null;
+
+ if (componentState != null && dataModel != null) {
+ // TODO handle model serialization - "execute" model
+ savedSerializableModel = dataModel.getSerializableModel(componentState.getRange());
+ }
+
+ if (localSavedComponentState != null || savedSerializableModel != null) {
+ return new Object[] {
+ localComponentStateIsHolder,
+ localSavedComponentState,
+ savedSerializableModel
+ };
+ } else {
+ return null;
+ }
+ }
+
+ final void restoreState(Object stateObject) {
+ if (stateObject != null) {
+ Object[] state = (Object[]) stateObject;
+ componentStateIsStateHolder = Boolean.TRUE.equals(state[0]);
+ Object localSavedComponentState = state[1];
+
+ if (componentStateIsStateHolder) {
+ savedComponentState = localSavedComponentState;
+ } else {
+ componentState = (DataComponentState) localSavedComponentState;
+ }
+
+ dataModel = (ExtendedDataModel<?>) state[2];
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException {
+
+ out.writeObject(saveState());
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+
+ restoreState(in.readObject());
+ }
+ }
+
+ private static final VisitCallback STUB_CALLBACK = new VisitCallback() {
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ return VisitResult.ACCEPT;
+ }
+ };
+
+ private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
+
+ /**
+ * Visitor for process decode on children components.
+ */
+ protected ComponentVisitor decodeVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processDecodes(context);
+ }
+ };
+
+ /**
+ * Visitor for process validation phase
+ */
+ protected ComponentVisitor validateVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processValidators(context);
+ }
+ };
+
+ /**
+ * Visitor for process update model phase.
+ */
+ protected ComponentVisitor updateVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processUpdates(context);
+ }
+ };
+
+ //TODO nick - PSH support?
+ private DataComponentState componentState = null;
+ private ExtendedDataModel<?> extendedDataModel = null;
+
+ private Object rowKey = null;
+
+ private boolean rowDataIsSet = false;
+
+ private Object rowData;
+
+ private String clientId;
+
+ private Object originalVarValue;
+
+ private Converter rowKeyConverter;
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class DataVisitorForVisitTree implements DataVisitor {
+ /**
+ *
+ */
+ private final VisitCallback callback;
+ /**
+ *
+ */
+ private final VisitContext visitContext;
+ /**
+ *
+ */
+ private boolean visitResult;
+
+ /**
+ * @param callback
+ * @param visitContext
+ */
+ private DataVisitorForVisitTree(VisitCallback callback, VisitContext visitContext) {
+ this.callback = callback;
+ this.visitContext = visitContext;
+ }
+
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ setRowKey(context, rowKey);
+
+ if (isRowAvailable()) {
+ VisitResult result = VisitResult.ACCEPT;
+
+ if (visitContext instanceof ExtendedVisitContext) {
+ result = visitContext.invokeVisitCallback(UIDataAdaptor.this, callback);
+ if (VisitResult.COMPLETE.equals(result)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+
+ if (result == VisitResult.ACCEPT) {
+ result = visitDataChildrenMetaComponents((ExtendedVisitContext) visitContext, callback);
+ if (VisitResult.COMPLETE.equals(result)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+ }
+ }
+
+ if (VisitResult.ACCEPT.equals(result)) {
+ Iterator<UIComponent> dataChildrenItr = dataChildren();
+
+ while (dataChildrenItr.hasNext()) {
+ UIComponent dataChild = dataChildrenItr.next();
+
+ if (dataChild.visitTree(visitContext, callback)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+ }
+ }
+ }
+
+ return DataVisitResult.CONTINUE;
+ }
+
+ public boolean getVisitResult() {
+ return visitResult;
+ }
+ }
+
+ private enum PropertyKeys {
+ lastId, var, rowKeyVar, stateVar, childState, rowKeyConverter, rowKeyConverterSet, keepSaved
+ }
+
+ public UIDataAdaptor() {
+ super();
+ }
+
+ protected Map<String, Object> getVariablesMap(FacesContext facesContext) {
+ return facesContext.getExternalContext().getRequestMap();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UniqueIdVendor#createUniqueId(javax.faces.context.FacesContext, java.lang.String)
+ */
+ public String createUniqueId(FacesContext context, String seed) {
+ Integer i = (Integer) getStateHelper().get(PropertyKeys.lastId);
+ int lastId = (i != null) ? i : 0;
+
+ getStateHelper().put(PropertyKeys.lastId, ++lastId);
+
+ return UIViewRoot.UNIQUE_ID_PREFIX + ((seed == null) ? lastId : seed);
+ }
+
+ /**
+ * @return the rowKey
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ private void setRowKeyAndData(FacesContext facesContext, Object rowKey, boolean localRowDataAvailable, Object localRowData) {
+ this.saveChildState(facesContext);
+
+ this.rowKey = rowKey;
+
+ if (localRowDataAvailable) {
+ this.rowData = localRowData;
+ this.rowDataIsSet = (rowKey != null);
+ } else {
+ this.rowData = null;
+ this.rowDataIsSet = false;
+
+ getExtendedDataModel().setRowKey(rowKey);
+ }
+
+ this.clientId = null;
+
+ boolean rowSelected = (rowKey != null) && isRowAvailable();
+
+ setupVariable(facesContext, rowSelected);
+
+ this.restoreChildState(facesContext);
+ }
+
+ protected void setRowKeyAndData(FacesContext facesContext, Object rowKey, Object localRowData) {
+ setRowKeyAndData(facesContext, rowKey, true, localRowData);
+ }
+
+ /**
+ * Setup current row by key. Perform same functionality as
+ * {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
+ * row number in sequence data, but, for example - path to current node in
+ * tree.
+ *
+ * @param faces -
+ * current FacesContext
+ * @param key new key value.
+ */
+ public void setRowKey(FacesContext facesContext, Object rowKey) {
+<<<<<<< HEAD
+ this.saveChildState(facesContext);
+
+ this.rowKey = rowKey;
+
+ getExtendedDataModel().setRowKey(rowKey);
+
+ this.clientId = null;
+
+ boolean rowSelected = (rowKey != null) && isRowAvailable();
+
+ setupVariable(facesContext, rowSelected);
+
+ this.restoreChildState(facesContext);
+=======
+ setRowKeyAndData(facesContext, rowKey, false, null);
+>>>>>>> RF-9680:
+ }
+
+ /**
+ * Save values of {@link EditableValueHolder} fields before change current
+ * row.
+ *
+ * @param faces
+ */
+ protected void saveChildState(FacesContext facesContext) {
+ Iterator<UIComponent> itr = dataChildren();
+
+ while (itr.hasNext()) {
+ this.saveChildState(facesContext, (UIComponent) itr.next());
+ }
+ }
+
+ /**
+ * @param facesContext
+ * @param next
+ * @param childState
+ */
+ protected void saveChildState(FacesContext facesContext, UIComponent component) {
+
+ // TODO - is it right?
+ if (component.isTransient()) {
+ return;
+ }
+
+ SavedState state = null;
+
+ if (component instanceof IterationStateHolder) {
+ IterationStateHolder ish = (IterationStateHolder) component;
+
+ state = new SavedState(ish);
+ } else if (component instanceof EditableValueHolder) {
+ EditableValueHolder evh = (EditableValueHolder) component;
+
+ state = new SavedState(evh);
+ } else if (component instanceof UIForm) {
+ UIForm form = (UIForm) component;
+
+ state = new SavedState(form);
+ }
+
+ if (state != null) {
+
+ // TODO - use local map - children save their state themselves using visitors
+ getStateHelper().put(PropertyKeys.childState, component.getClientId(facesContext), state);
+ }
+
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ saveChildState(facesContext, child);
+ }
+ }
+
+ if (component.getFacetCount() > 0) {
+ for (UIComponent facet : component.getFacets().values()) {
+ saveChildState(facesContext, facet);
+ }
+ }
+ }
+
+ protected Iterator<UIComponent> dataChildren() {
+ if (getChildCount() > 0) {
+ return getChildren().iterator();
+ } else {
+ return Collections.<UIComponent>emptyList().iterator();
+ }
+ }
+
+ protected Iterator<UIComponent> fixedChildren() {
+ if (getFacetCount() > 0) {
+ return getFacets().values().iterator();
+ } else {
+ return Collections.<UIComponent>emptyList().iterator();
+ }
+ }
+
+ /**
+ * @param facesContext
+ */
+ protected void restoreChildState(FacesContext facesContext) {
+ Iterator<UIComponent> itr = dataChildren();
+
+ while (itr.hasNext()) {
+ this.restoreChildState(facesContext, (UIComponent) itr.next());
+ }
+ }
+
+ /**
+ * Restore values of {@link EditableValueHolder} fields after change current
+ * row.
+ *
+ * @param facesContext
+ * @param next
+ * @param childState
+ */
+ protected void restoreChildState(FacesContext facesContext, UIComponent component) {
+ String id = component.getId();
+
+ component.setId(id); // Forces client id to be reset
+
+ SavedState savedState = null;
+ @SuppressWarnings("unchecked")
+ Map<String, SavedState> savedStatesMap = (Map<String, SavedState>) getStateHelper()
+ .get(PropertyKeys.childState);
+
+ if (savedStatesMap != null) {
+ savedState = savedStatesMap.get(component.getClientId(facesContext));
+ }
+
+ if (savedState == null) {
+ savedState = SavedState.EMPTY;
+ }
+
+ if (component instanceof IterationStateHolder) {
+ IterationStateHolder ish = (IterationStateHolder) component;
+
+ savedState.apply(ish);
+ } else if (component instanceof EditableValueHolder) {
+ EditableValueHolder evh = (EditableValueHolder) component;
+
+ savedState.apply(evh);
+ } else if (component instanceof UIForm) {
+ UIForm form = (UIForm) component;
+
+ savedState.apply(form);
+ }
+
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ restoreChildState(facesContext, child);
+ }
+ }
+
+ if (component.getFacetCount() > 0) {
+ for (UIComponent facet : component.getFacets().values()) {
+ restoreChildState(facesContext, facet);
+ }
+ }
+ }
+
+ public void setRowKey(Object rowKey) {
+ setRowKey(getFacesContext(), rowKey);
+ }
+
+ protected FacesEvent wrapEvent(FacesEvent event) {
+ return new RowKeyContextEventWrapper(this, event, getRowKey());
+ }
+
+ @Override
+ public void queueEvent(FacesEvent event) {
+ super.queueEvent(wrapEvent(event));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ if (event instanceof RowKeyContextEventWrapper) {
+ RowKeyContextEventWrapper eventWrapper = (RowKeyContextEventWrapper) event;
+
+ eventWrapper.broadcast(getFacesContext());
+ } else {
+ super.broadcast(event);
+ }
+ }
+
+ /**
+ * @return the extendedDataModel
+ */
+ protected ExtendedDataModel<?> getExtendedDataModel() {
+ if (extendedDataModel == null) {
+ extendedDataModel = createExtendedDataModel();
+ }
+
+ return extendedDataModel;
+ }
+
+ /**
+ * @return
+ */
+ protected abstract ExtendedDataModel<?> createExtendedDataModel();
+
+ /**
+ * @param extendedDataModel the extendedDataModel to set
+ */
+ protected void setExtendedDataModel(ExtendedDataModel<?> extendedDataModel) {
+ this.extendedDataModel = extendedDataModel;
+ }
+
+ public String getVar() {
+ return (String) getStateHelper().get(PropertyKeys.var);
+ }
+
+ public void setVar(String var) {
+ getStateHelper().put(PropertyKeys.var, var);
+ }
+
+ public String getRowKeyVar() {
+ return (String) getStateHelper().get(PropertyKeys.rowKeyVar);
+ }
+
+ public void setRowKeyVar(String rowKeyVar) {
+ getStateHelper().put(PropertyKeys.rowKeyVar, rowKeyVar);
+ }
+
+ public String getStateVar() {
+ return (String) getStateHelper().get(PropertyKeys.stateVar);
+ }
+
+ public void setStateVar(String stateVar) {
+ getStateHelper().put(PropertyKeys.stateVar, stateVar);
+ }
+
+ //XXX - review and probably remove - useful method, should be left
+ public int getRowCount() {
+ return getExtendedDataModel().getRowCount();
+ }
+
+ public Object getRowData() {
+ if (rowDataIsSet) {
+ return rowData;
+ }
+
+ return getExtendedDataModel().getRowData();
+ }
+
+ public boolean isRowAvailable() {
+ return rowDataIsSet || getExtendedDataModel().isRowAvailable();
+ }
+
+ /**
+ * Boolean attribute that defines whether this iteration component will reset saved children's state
+ * before rendering. By default state is reset if there are no faces messages with severity error or higher.
+ * @return
+ */
+ public boolean isKeepSaved() {
+ Object value = getStateHelper().eval(PropertyKeys.keepSaved);
+
+ if (value == null) {
+ return keepSaved(getFacesContext());
+ } else {
+ return Boolean.valueOf(value.toString());
+ }
+ }
+
+ public void setKeepSaved(boolean keepSaved) {
+ getStateHelper().put(PropertyKeys.keepSaved, keepSaved);
+ }
+
+ /**
+ * Setup EL variable for different iteration. Value of row data and
+ * component state will be put into request scope attributes with names
+ * given by "var" and "varState" bean properties.
+ * <p/>
+ * Changed: does not check for row availability now
+ *
+ * @param faces current faces context
+ * @param localModel
+ * @param rowSelected
+ */
+ protected void setupVariable(FacesContext faces, boolean rowSelected) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ if (rowSelected) {
+
+ // Current row data.
+ setupVariable(getVar(), attrs, getRowData());
+
+ // Component state variable.
+ setupVariable(getStateVar(), attrs, getComponentState());
+
+ // Row key Data variable.
+ setupVariable(getRowKeyVar(), attrs, getRowKey());
+ } else {
+ removeVariable(getVar(), attrs);
+ removeVariable(getStateVar(), attrs);
+ removeVariable(getRowKeyVar(), attrs);
+ }
+ }
+
+ /**
+ * @return
+ */
+ public DataComponentState getComponentState() {
+ if (componentState != null) {
+ return componentState;
+ }
+
+ ValueExpression componentStateExpression = getValueExpression("componentState");
+
+ if (componentStateExpression != null) {
+ componentState = (DataComponentState) componentStateExpression.getValue(getFacesContext().getELContext());
+ }
+
+ if (componentState == null) {
+ componentState = createComponentState();
+
+ if ((componentStateExpression != null)
+ && !componentStateExpression.isReadOnly(getFacesContext().getELContext())) {
+ componentStateExpression.setValue(getFacesContext().getELContext(), componentState);
+ }
+ }
+
+ return componentState;
+ }
+
+ protected abstract DataComponentState createComponentState();
+
+ /**
+ * @param var
+ * @param attrs
+ * @param rowData
+ */
+ private void setupVariable(String var, Map<String, Object> attrs, Object rowData) {
+ if (var != null) {
+ attrs.put(var, rowData);
+ }
+ }
+
+ /**
+ * @param var
+ * @param attrs
+ * @param rowData
+ */
+ private void removeVariable(String var, Map<String, Object> attrs) {
+ if (var != null) {
+ attrs.remove(var);
+ }
+ }
+
+ public Converter getRowKeyConverter() {
+ if (this.rowKeyConverter != null) {
+ return this.rowKeyConverter;
+ }
+
+ return (Converter) getStateHelper().eval(PropertyKeys.rowKeyConverter);
+ }
+
+ public void setRowKeyConverter(Converter converter) {
+ StateHelper stateHelper = getStateHelper();
+ if (initialStateMarked()) {
+ stateHelper.put(PropertyKeys.rowKeyConverterSet, Boolean.TRUE);
+ }
+
+ this.rowKeyConverter = converter;
+ }
+
+ private boolean isSetRowKeyConverter() {
+ Boolean value = (Boolean) getStateHelper().get(PropertyKeys.rowKeyConverterSet);
+ return Boolean.TRUE.equals(value);
+ }
+
+ @Override
+ public String getClientId(FacesContext facesContext) {
+ if (facesContext == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (null == clientId) {
+ StringBuilder id = new StringBuilder(super.getClientId(facesContext));
+ Object rowKey = getRowKey();
+
+ if (rowKey != null) {
+
+ // Use converter to get String representation ot the row key.
+ Converter rowKeyConverter = getRowKeyConverter();
+
+ if (null == rowKeyConverter) {
+
+ // Create default converter for a row key.
+ rowKeyConverter = facesContext.getApplication().createConverter(rowKey.getClass());
+
+ // Store converter for a invokeOnComponents call.
+ if (null != rowKeyConverter) {
+ // TODO - review
+ setRowKeyConverter(rowKeyConverter);
+ }
+ }
+
+ String rowKeyString;
+
+ if (null != rowKeyConverter) {
+
+ // Temporary set clientId, to avoid infinite calls from converter.
+ clientId = id.toString();
+ rowKeyString = rowKeyConverter.getAsString(facesContext, this, rowKey);
+ } else {
+ rowKeyString = rowKey.toString();
+ }
+
+ id.append(UINamingContainer.getSeparatorChar(facesContext)).append(rowKeyString);
+ }
+
+ Renderer renderer = getRenderer(facesContext);
+
+ if (null != renderer) {
+ clientId = renderer.convertClientId(facesContext, id.toString());
+ } else {
+ clientId = id.toString();
+ }
+ }
+
+ return clientId;
+ }
+
+ public String getBaseClientId(FacesContext context) {
+ return super.getClientId(context);
+ }
+
+ /**
+ * Save current state of data variable.
+ *
+ * @param faces current faces context
+ */
+
+ // TODO move into walk() method body
+ public void captureOrigValue(FacesContext faces) {
+ String var = getVar();
+
+ if (var != null) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ this.originalVarValue = attrs.get(var);
+ }
+
+ // TODO add support for another variables
+ }
+
+ /**
+ * Restore value of data variable after processing phase.
+ *
+ * @param faces current faces context
+ */
+ public void restoreOrigValue(FacesContext faces) {
+ String var = getVar();
+
+ if (var != null) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ if (this.originalVarValue != null) {
+ attrs.put(var, this.originalVarValue);
+ } else {
+ attrs.remove(var);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#setValueExpression(java.lang.String, javax.el.ValueExpression)
+ */
+ @Override
+ public void setValueExpression(String name, ValueExpression binding) {
+ if ("var".equals(name) || "rowKeyVar".equals(name) || "stateVar".equals(name)) {
+ throw new IllegalArgumentException(MessageFormat.format("{0} cannot be EL-expression", name));
+ }
+
+ super.setValueExpression(name, binding);
+ }
+
+ /**
+ * Check for validation errors on children components. If true, saved values
+ * must be keep on render phase
+ *
+ * @param context
+ * @return
+ */
+ protected boolean keepSaved(FacesContext context) {
+
+ // For an any validation errors, children components state should be preserved
+ FacesMessage.Severity sev = context.getMaximumSeverity();
+
+ return (sev != null) && (FacesMessage.SEVERITY_ERROR.compareTo(sev) >= 0);
+ }
+
+ /**
+ * Perform iteration on all children components and all data rows with given
+ * visitor.
+ *
+ * @param faces
+ * @param visitor
+ */
+ protected void iterate(FacesContext faces, ComponentVisitor visitor) {
+
+ // stop if not rendered
+ if (!this.isRendered()) {
+ return;
+ }
+
+ // reset rowIndex
+ this.captureOrigValue(faces);
+ this.setRowKey(faces, null);
+
+ try {
+ Iterator<UIComponent> fixedChildren = fixedChildren();
+
+ while (fixedChildren.hasNext()) {
+ UIComponent component = fixedChildren.next();
+
+ visitor.processComponent(faces, component, null);
+ }
+
+ walk(faces, visitor, null);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ } finally {
+ this.setRowKey(faces, null);
+ this.restoreOrigValue(faces);
+ }
+ }
+
+ /**
+ * Walk ( visit ) this component on all data-aware children for each row.
+ *
+ * @param faces
+ * @param visitor
+ */
+ public void walk(FacesContext faces, DataVisitor visitor, Object argument) {
+ Object key = getRowKey();
+ captureOrigValue(faces);
+
+ Range range = null;
+ DataComponentState componentState = getComponentState();
+
+ if (componentState != null) {
+ range = componentState.getRange();
+ }
+
+ getExtendedDataModel().walk(faces, visitor, range, argument);
+
+ setRowKey(faces, key);
+ restoreOrigValue(faces);
+ }
+
+ public void processDecodes(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ preDecode(faces);
+ this.iterate(faces, decodeVisitor);
+ this.decode(faces);
+ popComponentFromEL(faces);
+ }
+
+ public void processValidators(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ Application app = faces.getApplication();
+ app.publishEvent(faces, PreValidateEvent.class, this);
+ preValidate(faces);
+ this.iterate(faces, validateVisitor);
+ app.publishEvent(faces, PostValidateEvent.class, this);
+ popComponentFromEL(faces);
+ }
+
+ public void processUpdates(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ preUpdate(faces);
+ this.iterate(faces, updateVisitor);
+
+ ExtendedDataModel<?> dataModel = getExtendedDataModel();
+
+ // If no validation errors, update values for serializable model,
+ // restored from view.
+ if ((dataModel instanceof SerializableDataModel) && (!isKeepSaved())) {
+ SerializableDataModel serializableModel = (SerializableDataModel) dataModel;
+
+ serializableModel.update();
+ }
+
+ doUpdate();
+
+ popComponentFromEL(faces);
+ }
+
+ protected void doUpdate() {
+
+ }
+
+ @Override
+ public void setId(String id) {
+ super.setId(id);
+ this.clientId = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.ajax4jsf.component.IterationStateHolder#getIterationState()
+ */
+ public Object getIterationState() {
+ assert rowKey == null;
+
+ return new IterationState(this.componentState, this.extendedDataModel);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.component.IterationStateHolder#setIterationState(java.lang.Object)
+ */
+ public void setIterationState(Object stateObject) {
+ assert rowKey == null;
+
+ // TODO - ?
+ // restoreChildState(getFacesContext());
+ if (stateObject != null) {
+ IterationState iterationState = (IterationState) stateObject;
+ iterationState.restoreComponentState(this);
+
+ this.componentState = iterationState.getComponentState();
+ this.extendedDataModel = iterationState.getDataModel();
+ } else {
+ this.componentState = null;
+ this.extendedDataModel = null;
+ }
+ }
+
+ protected void resetDataModel() {
+ this.extendedDataModel = null;
+ }
+
+ protected void resetChildState() {
+ getStateHelper().remove(PropertyKeys.childState);
+ }
+
+ protected void preDecode(FacesContext context) {
+ resetDataModel();
+
+ Object savedChildState = getStateHelper().get(PropertyKeys.childState);
+ // TODO - verify the check for null: savedChildState == null
+ if (savedChildState == null || !isKeepSaved()) {
+ resetChildState();
+ }
+ }
+
+ // TODO - do we need this method?
+ protected void preValidate(FacesContext context) {
+ }
+
+ // TODO - do we need this method?
+ protected void preUpdate(FacesContext context) {
+ }
+
+ protected void preEncodeBegin(FacesContext context) {
+ resetDataModel();
+
+ if (!isKeepSaved()) {
+ //TODO - this also resets state for the nested iteration components - is it correct?
+ resetChildState();
+ }
+ }
+
+ @Override
+ public void markInitialState() {
+ super.markInitialState();
+
+ if (rowKeyConverter instanceof PartialStateHolder) {
+ ((PartialStateHolder) rowKeyConverter).markInitialState();
+ }
+ }
+
+ @Override
+ public void clearInitialState() {
+ super.clearInitialState();
+
+ if (rowKeyConverter instanceof PartialStateHolder) {
+ ((PartialStateHolder) rowKeyConverter).clearInitialState();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
+ */
+ @Override
+ public Object saveState(FacesContext context) {
+ Object parentState = super.saveState(context);
+ Object savedComponentState = new IterationState(componentState, extendedDataModel).saveState();
+
+ Object converterState = null;
+ boolean nullDelta = true;
+
+ boolean converterHasPartialState = false;
+
+ if (initialStateMarked()) {
+ if (!isSetRowKeyConverter() && rowKeyConverter != null && rowKeyConverter instanceof PartialStateHolder) {
+ // Delta
+ StateHolder holder = (StateHolder) rowKeyConverter;
+ if (!holder.isTransient()) {
+ Object attachedState = holder.saveState(context);
+ if (attachedState != null) {
+ nullDelta = false;
+ converterState = attachedState;
+ }
+ converterHasPartialState = true;
+ } else {
+ converterState = null;
+ }
+ } else if (isSetRowKeyConverter() || rowKeyConverter != null) {
+ // Full
+ converterState = saveAttachedState(context, rowKeyConverter);
+ nullDelta = false;
+ }
+
+ if (parentState == null && savedComponentState == null && nullDelta) {
+ // No values
+ return null;
+ }
+ } else {
+ converterState = saveAttachedState(context, rowKeyConverter);
+ }
+
+ return new Object[] {
+ parentState,
+ savedComponentState,
+ converterHasPartialState,
+ converterState
+ };
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ @Override
+ public void restoreState(FacesContext context, Object stateObject) {
+ if (stateObject == null) {
+ return ;
+ }
+
+ Object[] state = (Object[]) stateObject;
+
+ super.restoreState(context, state[0]);
+
+ if (state[1] != null) {
+ IterationState iterationState = new IterationState();
+ iterationState.restoreState(state[1]);
+ iterationState.restoreComponentState(this);
+
+ // TODO update state model binding
+ componentState = iterationState.getComponentState();
+ extendedDataModel = iterationState.getDataModel();
+ }
+
+ boolean converterHasPartialState = Boolean.TRUE.equals(state[2]);
+ Object savedConverterState = state[3];
+ if (converterHasPartialState) {
+ ((StateHolder) rowKeyConverter).restoreState(context, savedConverterState);
+ } else {
+ rowKeyConverter = (Converter) UIComponentBase.restoreAttachedState(context, savedConverterState);
+ }
+ }
+
+ private boolean matchesBaseId(String clientId, String baseId, char separatorChar) {
+ if (clientId.equals(baseId)) {
+ return true;
+ }
+
+ // if clientId.startsWith(baseId + separatorChar)
+ if (clientId.startsWith(baseId) && (clientId.length() > baseId.length())
+ && (clientId.charAt(baseId.length()) == separatorChar)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+
+ if ((null == context) || (null == clientId) || (null == callback)) {
+ throw new NullPointerException();
+ }
+
+ String baseId = super.getClientId(context);
+
+ if (!matchesBaseId(clientId, baseId, UINamingContainer.getSeparatorChar(context))) {
+ return false;
+ }
+
+ boolean found = false;
+ Object oldRowKey = getRowKey();
+
+ // TODO - this does not seem right
+ captureOrigValue(context);
+
+ try {
+
+ // TODO - ?
+ // if (null != oldRowKey) {
+ setRowKey(context, null);
+
+ // }
+ if (clientId.equals(baseId)) {
+ callback.invokeContextCallback(context, this);
+ found = true;
+ } else {
+ Iterator<UIComponent> fixedChildrenItr = fixedChildren();
+
+ while (fixedChildrenItr.hasNext() && !found) {
+ UIComponent fixedChild = fixedChildrenItr.next();
+
+ found = fixedChild.invokeOnComponent(context, clientId, callback);
+ }
+ }
+
+ if (!found) {
+ Object newRowKey = null;
+
+ // Call for a child component - try to detect row key
+ // baseId.length() + 1 expression skips SEPARATOR_CHAR
+ //TODO - convertKeyString
+ String rowKeyString = extractKeySegment(context, clientId.substring(baseId.length() + 1));
+
+ if (rowKeyString != null) {
+ Converter keyConverter = getRowKeyConverter();
+
+ if (null != keyConverter) {
+ try {
+ //TODO: review
+ newRowKey = keyConverter.getAsObject(context, this, rowKeyString);
+ } catch (ConverterException e) {
+
+ // TODO: LOG error
+ }
+ }
+ }
+
+ setRowKey(context, newRowKey);
+
+ if (isRowAvailable()) {
+ Iterator<UIComponent> dataChildrenItr = dataChildren();
+
+ while (dataChildrenItr.hasNext() && !found) {
+ UIComponent dataChild = dataChildrenItr.next();
+
+ found = dataChild.invokeOnComponent(context, clientId, callback);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new FacesException(e);
+ } finally {
+
+ // if (null != oldRowKey) {
+ try {
+ setRowKey(context, oldRowKey);
+ restoreOrigValue(context);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ // }
+ }
+
+ return found;
+ }
+
+ // Tests whether we need to visit our children as part of
+ // a tree visit
+ private boolean doVisitChildren(VisitContext context, boolean visitRows) {
+
+ // Just need to check whether there are any ids under this
+ // subtree. Make sure row index is cleared out since
+ // getSubtreeIdsToVisit() needs our row-less client id.
+
+ // TODO check this
+ if (visitRows) {
+ setRowKey(context.getFacesContext(), null);
+ }
+
+ // TODO optimize for returned IDs
+ Collection<String> idsToVisit = context.getSubtreeIdsToVisit(this);
+
+ assert idsToVisit != null;
+
+ if (idsToVisit == VisitContext.ALL_IDS) {
+ // TODO
+ }
+
+ // All ids or non-empty collection means we need to visit our children.
+ return !idsToVisit.isEmpty();
+ }
+
+ private boolean visitComponents(Iterator<UIComponent> components, VisitContext context, VisitCallback callback) {
+
+ while (components.hasNext()) {
+ UIComponent nextChild = components.next();
+
+ if (nextChild.visitTree(context, callback)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
+
+ return visitComponents(fixedChildren(), visitContext, callback);
+ }
+
+ protected VisitResult visitDataChildrenMetaComponents(ExtendedVisitContext extendedVisitContext, VisitCallback callback) {
+ return VisitResult.ACCEPT;
+ }
+
+ protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback, boolean visitRows) {
+
+ if (visitRows) {
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ DataVisitorForVisitTree dataVisitor = new DataVisitorForVisitTree(callback, visitContext);
+ this.walk(facesContext, dataVisitor, null);
+
+ return dataVisitor.getVisitResult();
+ } else {
+ return visitComponents(dataChildren(), visitContext, callback);
+ }
+ }
+
+ @Override
+ public boolean visitTree(VisitContext visitContext, VisitCallback callback) {
+
+ // First check to see whether we are visitable. If not
+ // short-circuit out of this subtree, though allow the
+ // visit to proceed through to other subtrees.
+ if (!isVisitable(visitContext)) {
+ return false;
+ }
+
+ // Clear out the row index is one is set so that
+ // we start from a clean slate.
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ // NOTE: that the visitRows local will be obsolete once the
+ // appropriate visit hints have been added to the API
+ boolean visitRows = requiresRowIteration(facesContext);
+
+ Object oldRowKey = null;
+ if (visitRows) {
+ captureOrigValue(facesContext);
+ oldRowKey = getRowKey();
+ setRowKey(facesContext, null);
+ }
+
+ // Push ourselves to EL
+ pushComponentToEL(facesContext, null);
+
+ try {
+
+ // Visit ourselves. Note that we delegate to the
+ // VisitContext to actually perform the visit.
+ VisitResult result = visitContext.invokeVisitCallback(this, callback);
+
+ // If the visit is complete, short-circuit out and end the visit
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ }
+
+ // Visit children, short-circuiting as necessary
+ if ((result == VisitResult.ACCEPT) && doVisitChildren(visitContext, visitRows)) {
+ if (visitRows) {
+ setRowKey(facesContext, null);
+ }
+
+ if (visitFixedChildren(visitContext, callback)) {
+ return true;
+ }
+
+ if (visitContext instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;
+
+ Collection<String> directSubtreeIdsToVisit = extendedVisitContext.getDirectSubtreeIdsToVisit(this);
+ if (directSubtreeIdsToVisit != VisitContext.ALL_IDS) {
+ if (directSubtreeIdsToVisit.isEmpty()) {
+ return false;
+ } else {
+ VisitContext directChildrenVisitContext =
+ extendedVisitContext.createNamingContainerVisitContext(this, directSubtreeIdsToVisit);
+
+ if (visitRows) {
+ setRowKey(facesContext, null);
+ }
+ if (visitFixedChildren(directChildrenVisitContext, STUB_CALLBACK)) {
+ return false;
+ }
+ }
+ }
+ }
+
+ if (visitDataChildren(visitContext, callback, visitRows)) {
+ return true;
+ }
+ }
+ } finally {
+
+ // Clean up - pop EL and restore old row index
+ popComponentFromEL(facesContext);
+
+ if (visitRows) {
+ try {
+ setRowKey(facesContext, oldRowKey);
+ restoreOrigValue(facesContext);
+ } catch (Exception e) {
+
+ // TODO: handle exception
+ LOG.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ // Return false to allow the visit to continue
+ return false;
+ }
+
+ /**
+ * @param facesContext
+ * @return
+ */
+ private boolean requiresRowIteration(FacesContext context) {
+ return (!PhaseId.RESTORE_VIEW.equals(context.getCurrentPhaseId()));
+ }
+
+ /**
+ * @param context
+ * @param substring
+ * @return
+ */
+ // TODO review!
+ protected String extractKeySegment(FacesContext context, String substring) {
+ char separatorChar = UINamingContainer.getSeparatorChar(context);
+ int separatorIndex = substring.indexOf(separatorChar);
+
+ if (separatorIndex < 0) {
+ return null;
+ } else {
+ return substring.substring(0, separatorIndex);
+ }
+ }
+
+ /**
+ * Base class for visit data model at phases decode, validation and update model
+ *
+ * @author shura
+ */
+ protected abstract class ComponentVisitor implements DataVisitor {
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ setRowKey(context, rowKey);
+
+ if (isRowAvailable()) {
+ Iterator<UIComponent> childIterator = dataChildren();
+
+ while (childIterator.hasNext()) {
+ UIComponent component = childIterator.next();
+
+ processComponent(context, component, argument);
+ }
+ }
+
+ return DataVisitResult.CONTINUE;
+ }
+
+ public abstract void processComponent(FacesContext context, UIComponent c, Object argument);
+ }
+
+ @Override
+ public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
+ super.processEvent(event);
+
+ if (event instanceof PreRenderComponentEvent) {
+ preEncodeBegin(getFacesContext());
+ }
+ }
+
+ protected DataComponentState getLocalComponentState() {
+ return componentState;
+ }
+}
Modified: branches/RF-8742-1/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
--- branches/RF-8742-1/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -25,6 +25,7 @@
import java.util.Map;
+import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -39,7 +40,9 @@
* @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:53 $
*
*/
-@ResourceDependency(library = "org.richfaces", name = "ajax.reslib")
+@ResourceDependencies({
+ @ResourceDependency(library = "org.richfaces", name = "ajax.reslib")
+})
public abstract class AjaxCommandRendererBase extends RendererBase {
private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -41,7 +41,7 @@
renderer = @JsfRenderer(type = "org.richfaces.InplaceSelectRenderer"),
tag = @Tag(name="inplaceSelect")
)
-public abstract class AbstractInplaceSelect extends AbstractSelect implements InplaceComponent {
+public abstract class AbstractInplaceSelect extends AbstractSelectComponent implements InplaceComponent {
public static final String COMPONENT_TYPE = "org.richfaces.InplaceSelect";
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,31 +1,6 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
package org.richfaces.component;
-import javax.faces.component.UISelectOne;
-
import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
@@ -35,115 +10,27 @@
*
*/
@JsfComponent(
- type = AbstractSelect.COMPONENT_TYPE,
- family = AbstractSelect.COMPONENT_FAMILY,
+ type = AbstractSelectComponent.COMPONENT_TYPE,
+ family = AbstractSelectComponent.COMPONENT_FAMILY,
generate = "org.richfaces.component.UISelect",
renderer = @JsfRenderer(type = "org.richfaces.SelectRenderer"),
tag = @Tag(name="select")
)
-public abstract class AbstractSelect extends UISelectOne {
-
+
+public abstract class AbstractSelect extends AbstractSelectComponent {
+
public static final String COMPONENT_TYPE = "org.richfaces.Select";
public static final String COMPONENT_FAMILY = "org.richfaces.Select";
+
- @Attribute(defaultValue="250px")
- public abstract String getListWidth();
-
- @Attribute(defaultValue="100px")
- public abstract String getListHeight();
-
- @Attribute(defaultValue="true")
- public abstract boolean isShowButton();
-
@Attribute(defaultValue="false")
public abstract boolean isEnableManualInput();
-
+
@Attribute(defaultValue="true")
public abstract boolean isSelectFirst();
- @Attribute
- public abstract String getDefaultLabel();
-
- @Attribute
- public abstract String getItemClass();
-
- @Attribute
- public abstract String getSelectItemClass();
-
- @Attribute
- public abstract String getListClass();
+ @Attribute(defaultValue="true")
+ public abstract boolean isShowButton();
- @Attribute(events=@EventName("blur"))
- public abstract String getOnblur();
-
- @Attribute(events=@EventName("click"))
- public abstract String getOnclick();
-
- @Attribute(events=@EventName("dblclick"))
- public abstract String getOndblclick();
-
- @Attribute(events=@EventName("focus"))
- public abstract String getOnfocus();
-
- @Attribute(events=@EventName("keydown"))
- public abstract String getOnkeydown();
-
- @Attribute(events=@EventName("keypress"))
- public abstract String getOnkeypress();
-
- @Attribute(events=@EventName("keyup"))
- public abstract String getOnkeyup();
-
- @Attribute(events=@EventName("mousedown"))
- public abstract String getOnmousedown();
-
- @Attribute(events=@EventName("mousemove"))
- public abstract String getOnmousemove();
-
- @Attribute(events=@EventName("mouseout"))
- public abstract String getOnmouseout();
-
- @Attribute(events=@EventName("mouseover"))
- public abstract String getOnmouseover();
-
- @Attribute(events=@EventName("mouseup"))
- public abstract String getOnmouseup();
-
- @Attribute(events=@EventName("listclick"))
- public abstract String getOnlistclick();
-
- @Attribute(events=@EventName("listdblclick"))
- public abstract String getOnlistdblclick();
-
- @Attribute(events=@EventName("listmousedown"))
- public abstract String getOnlistmousedown();
-
- @Attribute(events=@EventName("listmouseup"))
- public abstract String getOnlistmouseup();
-
- @Attribute(events=@EventName("listmouseover"))
- public abstract String getOnlistmouseover();
-
- @Attribute(events=@EventName("listmousemove"))
- public abstract String getOnlistmousemove();
-
- @Attribute(events=@EventName("listmouseout"))
- public abstract String getOnlistmouseout();
-
- @Attribute(events=@EventName("listkeypress"))
- public abstract String getOnlistkeypress();
-
- @Attribute(events=@EventName("listkeydown"))
- public abstract String getOnlistkeydown();
-
- @Attribute(events=@EventName("listkeyup"))
- public abstract String getOnlistkeyup();
-
- @Attribute(events=@EventName("select"))
- public abstract String getOnselect();
-
- @Attribute(events=@EventName("change"))
- public abstract String getOnchange();
-
}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java (from rev 20315, trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelectComponent.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UISelectOne;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+
+/**
+ * @author abelevich
+ *
+ */
+
+public abstract class AbstractSelectComponent extends UISelectOne {
+
+ @Attribute(defaultValue="250px")
+ public abstract String getListWidth();
+
+ @Attribute(defaultValue="100px")
+ public abstract String getListHeight();
+
+ @Attribute
+ public abstract String getDefaultLabel();
+
+ @Attribute
+ public abstract String getItemClass();
+
+ @Attribute
+ public abstract String getSelectItemClass();
+
+ @Attribute
+ public abstract String getListClass();
+
+ @Attribute(events=@EventName("blur"))
+ public abstract String getOnblur();
+
+ @Attribute(events=@EventName("click"))
+ public abstract String getOnclick();
+
+ @Attribute(events=@EventName("dblclick"))
+ public abstract String getOndblclick();
+
+ @Attribute(events=@EventName("focus"))
+ public abstract String getOnfocus();
+
+ @Attribute(events=@EventName("keydown"))
+ public abstract String getOnkeydown();
+
+ @Attribute(events=@EventName("keypress"))
+ public abstract String getOnkeypress();
+
+ @Attribute(events=@EventName("keyup"))
+ public abstract String getOnkeyup();
+
+ @Attribute(events=@EventName("mousedown"))
+ public abstract String getOnmousedown();
+
+ @Attribute(events=@EventName("mousemove"))
+ public abstract String getOnmousemove();
+
+ @Attribute(events=@EventName("mouseout"))
+ public abstract String getOnmouseout();
+
+ @Attribute(events=@EventName("mouseover"))
+ public abstract String getOnmouseover();
+
+ @Attribute(events=@EventName("mouseup"))
+ public abstract String getOnmouseup();
+
+ @Attribute(events=@EventName("listclick"))
+ public abstract String getOnlistclick();
+
+ @Attribute(events=@EventName("listdblclick"))
+ public abstract String getOnlistdblclick();
+
+ @Attribute(events=@EventName("listmousedown"))
+ public abstract String getOnlistmousedown();
+
+ @Attribute(events=@EventName("listmouseup"))
+ public abstract String getOnlistmouseup();
+
+ @Attribute(events=@EventName("listmouseover"))
+ public abstract String getOnlistmouseover();
+
+ @Attribute(events=@EventName("listmousemove"))
+ public abstract String getOnlistmousemove();
+
+ @Attribute(events=@EventName("listmouseout"))
+ public abstract String getOnlistmouseout();
+
+ @Attribute(events=@EventName("listkeypress"))
+ public abstract String getOnlistkeypress();
+
+ @Attribute(events=@EventName("listkeydown"))
+ public abstract String getOnlistkeydown();
+
+ @Attribute(events=@EventName("listkeyup"))
+ public abstract String getOnlistkeyup();
+
+ @Attribute(events=@EventName("select"))
+ public abstract String getOnselect();
+
+ @Attribute(events=@EventName("change"))
+ public abstract String getOnchange();
+
+}
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -33,7 +33,7 @@
import javax.faces.context.ResponseWriter;
import javax.faces.model.SelectItem;
-import org.richfaces.component.AbstractSelect;
+import org.richfaces.component.AbstractSelectComponent;
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.component.util.InputUtils;
import org.richfaces.component.util.SelectUtils;
@@ -92,7 +92,7 @@
}
public static List<ClientSelectItem> getConvertedSelectItems(FacesContext facesContext, UIComponent component) {
- AbstractSelect select = (AbstractSelect) component;
+ AbstractSelectComponent select = (AbstractSelectComponent) component;
List<SelectItem> selectItems = SelectUtils.getSelectItems(facesContext, select);
List<ClientSelectItem> clientSelectItems = new ArrayList<ClientSelectItem>();
@@ -106,7 +106,7 @@
public static void encodeItems(FacesContext facesContext, UIComponent component,
List<ClientSelectItem> clientSelectItems, String itemHtmlElement, String defaultItemCss) throws IOException {
- AbstractSelect select = (AbstractSelect) component;
+ AbstractSelectComponent select = (AbstractSelectComponent) component;
if (clientSelectItems != null && !clientSelectItems.isEmpty()) {
ResponseWriter writer = facesContext.getResponseWriter();
String clientId = component.getClientId(facesContext);
@@ -133,7 +133,7 @@
}
public static String getSelectInputLabel(FacesContext facesContext, UIComponent component) {
- AbstractSelect select = (AbstractSelect) component;
+ AbstractSelectComponent select = (AbstractSelectComponent) component;
Object value = select.getSubmittedValue();
String label = null;
if (value == null) {
@@ -152,7 +152,7 @@
return label;
}
- public static void addSelectCssToOptions(AbstractSelect abstractSelect, Map<String, Object> options, String [] defaultCss) {
+ public static void addSelectCssToOptions(AbstractSelectComponent abstractSelect, Map<String, Object> options, String [] defaultCss) {
String itemCss = abstractSelect.getItemClass();
if(itemCss != null && itemCss.trim().length() > 0) {
options.put(PopupConstants.OPTIONS_ITEM_CLASS, HtmlUtil.concatClasses(defaultCss[0], itemCss));
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -30,7 +30,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.richfaces.component.AbstractSelect;
+import org.richfaces.component.AbstractSelectComponent;
/**
* @author abelevich
@@ -63,7 +63,7 @@
}
public String getSelectLabel(FacesContext facesContext, UIComponent component) {
- AbstractSelect select = (AbstractSelect) component;
+ AbstractSelectComponent select = (AbstractSelectComponent) component;
String label = getSelectInputLabel(facesContext, select);
if (label == null || "".equals(label.trim())) {
label = select.getDefaultLabel();
Modified: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss 2010-12-02 18:53:41 UTC (rev 20318)
@@ -112,7 +112,7 @@
position : absolute;
bottom : 0px;
right : 0px;
- wigth : 1px;
+ width : 1px;
height : 1px;
}
Modified: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.ecss 2010-12-02 18:53:41 UTC (rev 20318)
@@ -158,7 +158,7 @@
position : absolute;
top : -4px;
right : 0px;
- wigth : 1px;
+ width : 1px;
height : 1px;
}
Modified: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.ecss
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.ecss 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.ecss 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,4 +1,3 @@
-
.rf-sel-inp, .rf-sel-opt {
color: '#{richSkin.generalTextColor}';
font-size: '#{richSkin.generalSizeFont}';
@@ -9,30 +8,42 @@
border-width: 0px;
background: none;
width: 100%;
+ color: '#{richSkin.generalTextColor}';
+ font-size: '#{richSkin.generalSizeFont}';
+ font-family: '#{richSkin.generalFamilyFont}';
}
+.rf-sel{
+ width:200px;
+ display:inline-block;
+}
+
.rf-sel-fld{
- width: 200px;
- position: inline-block;
border-width: 1px;
border-style: solid;
border-color: '#{richSkin.panelBorderColor}';
- display: inline-block;
background-image: "url(#{resource['org.richfaces.renderkit.html.images.AutocompleteFieldGradient']})";
background-repeat: repeat-x;
background-position: top left;
background-color: '#{richSkin.controlBackgroundColor}';
+ width: 100%;
}
+.rf-sel-fld-err input{
+ color: #FF0000;
+}
+
.rf-sel-btn{
background-image: "url(#{resource['org.richfaces.renderkit.html.images.AutocompleteButtonGradient']})";
background-repeat: repeat-x;
background-position: top left;
background-color: '#{richSkin.headerBackgroundColor}';
text-align: center;
- border-left-style: solid;
- border-left-width: 1px;
- border-left-color: '#{richSkin.panelBorderColor}';
+ border-style: solid;
+ border-width: 1px;
+ border-color: '#{richSkin.panelBorderColor}';
+ border-left-width: 0px;
+
width: 15px;
position: absolute;
top: 0px;
Modified: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-12-02 18:53:41 UTC (rev 20318)
@@ -109,7 +109,9 @@
var inputLabel = this.getValue() ;
this.initialValue = (inputLabel != this.defaultLabel) ? inputLabel : "";
this.selValueInput = $(document.getElementById(id+"selValue"));
+ this.field = $(document.getElementById(id+"Field"));
this.clientItems = mergedOptions.items;
+
if(mergedOptions.showControl) {
this.btn = $(document.getElementById(id+"Button"));
@@ -242,6 +244,14 @@
var newValue = this.getValue();
if(this.cache && this.cache.isCached(newValue)) {
this.__updateItems();
+
+ var items = this.popupList.__getItems();
+ if(items.length != 0) {
+ this.field.removeClass("rf-sel-fld-err");
+ } else {
+ this.field.addClass("rf-sel-fld-err");
+ }
+
if(!this.popupList.isVisible()) {
this.showPopup();
}
@@ -316,7 +326,9 @@
}
});
} else {
- var prevValue = this.selValueInput.val();
+ this.field.removeClass("rf-sel-fld-err");
+
+ var prevValue = this.selValueInput.val();
if(prevValue && prevValue != "") {
$.each(this.clientItems, function() {
if(this.value == prevValue) {
@@ -328,6 +340,7 @@
}
}
}
+
this.setValue(label);
this.selValueInput.val(value);
this.focused = false;
Modified: branches/RF-8742-1/ui/input/ui/src/main/templates/select.template.xml
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/templates/select.template.xml 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/input/ui/src/main/templates/select.template.xml 2010-12-02 18:53:41 UTC (rev 20318)
@@ -19,19 +19,20 @@
<cdk:object type="java.lang.Object" name="disabled" value="#{component.attributes['disabled']}" />
- <div id="#{clientId}" class="rf-sel-fld">
- <div style="position : relative; overflow : hidden; text-align : left; padding-right : 21px;">
+ <div id="#{clientId}" class="rf-sel">
+ <div style="position : relative; overflow : hidden; text-align : left; padding-right : 18px;">
<input id="#{clientId}selValue" name="#{clientId}" type="hidden" value="#{getInputValue(facesContext, component)}"/>
- <input cdk:passThroughWithExclusions="class autocomplete id value disabled name type readonly"
- id="#{clientId}Input"
- value="#{getSelectLabel(facesContext, component)}"
- disabled="#{disabled}"
- name="#{clientId}Input"
- type="text"
- class="rf-sel-fnt rf-sel-inp"
- autocomplete="off"
- readonly="#{component.attributes['enableManualInput'] ? '' : 'readonly'}"/>
-
+ <div id="#{clientId}Field" class="rf-sel-fld">
+ <input cdk:passThroughWithExclusions="class autocomplete id value disabled name type readonly"
+ id="#{clientId}Input"
+ value="#{getSelectLabel(facesContext, component)}"
+ disabled="#{disabled}"
+ name="#{clientId}Input"
+ type="text"
+ class="rf-sel-inp"
+ autocomplete="off"
+ readonly="#{component.attributes['enableManualInput'] ? '' : 'readonly'}"/>
+ </div>
<c:if test="#{component.attributes['showButton']}">
<c:if test="#{component.attributes['disabled']}">
<div id="#{clientId}Button" class="rf-sel-btn">
Modified: branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
===================================================================
--- branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -43,29 +43,29 @@
private static final long serialVersionUID = 8841984268370598781L;
private TreeNode parent;
-
+
private T data;
-
+
private Collection<TreeNode> children;
-
+
private boolean allowUpdateParents = true;
-
+
public SwingTreeNodeImpl() {
this(null);
}
-
- void setAllowUpdateParents(boolean allowUpdateParents) {
- this.allowUpdateParents = allowUpdateParents;
- }
-
+
public SwingTreeNodeImpl(Collection<TreeNode> children) {
this.children = wrapNull(children);
}
+ void setAllowUpdateParents(boolean allowUpdateParents) {
+ this.allowUpdateParents = allowUpdateParents;
+ }
+
private static Collection<TreeNode> wrapNull(Collection<TreeNode> src) {
return src != null ? src : Lists.<TreeNode>newArrayList();
}
-
+
public TreeNode getChildAt(int childIndex) {
return Iterables.get(children, childIndex);
}
@@ -81,7 +81,7 @@
public void setParent(TreeNode parent) {
this.parent = parent;
}
-
+
public int getIndex(TreeNode node) {
return Iterables.indexOf(children, Predicates.equalTo(node));
}
@@ -93,16 +93,16 @@
treeNodeImpl.setParent(this);
}
}
-
+
public void removeChild(TreeNode node) {
if (children.remove(node)) {
if (allowUpdateParents && node instanceof SwingTreeNodeImpl<?>) {
SwingTreeNodeImpl<?> treeNodeImpl = (SwingTreeNodeImpl<?>) node;
treeNodeImpl.setParent(null);
}
- }
+ }
}
-
+
public boolean getAllowsChildren() {
return true;
}
@@ -118,20 +118,20 @@
public T getData() {
return data;
}
-
+
public void setData(T data) {
this.data = data;
}
-
+
public Collection<TreeNode> getChildrenList() {
return children;
}
-
+
@Override
public String toString() {
ToStringHelper toStringHelper = Objects.toStringHelper(this);
toStringHelper.add("data", data);
-
+
return toStringHelper.toString();
}
}
Modified: branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
--- branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -23,7 +23,9 @@
import java.util.Iterator;
+import javax.faces.convert.Converter;
+
/**
* @author Nick Belaevski
*
@@ -31,6 +33,8 @@
//TODO - add necessary methods for tree adaptors support
public interface TreeDataModel<E> {
+ public static final char SEPARATOR_CHAR = '.';
+
public Object getRowKey();
public void setRowKey(Object rowKey);
@@ -53,4 +57,6 @@
public void restoreFromSnapshot(TreeDataModelTuple tuple);
+ public Converter getRowKeyConverter();
+
}
Copied: branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeNode.java (from rev 20315, trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeNode.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeNode.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeNode.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface TreeNode {
+
+ public TreeNode getChild(Object key);
+
+ public int indexOf(Object key);
+
+ public Iterator<Object> getChildrenKeysIterator();
+
+ public boolean isLeaf();
+
+ public void addChild(Object key, TreeNode child);
+
+ public void insertChild(int idx, Object key, TreeNode child);
+
+ public void removeChild(Object key);
+
+}
Copied: branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeNodeImpl.java (from rev 20315, trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeNodeImpl.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeNodeImpl.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/api/src/main/java/org/richfaces/model/TreeNodeImpl.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TreeNodeImpl implements TreeNode {
+
+ private List<Object> keysList = null;
+
+ private Map<Object, TreeNode> children = null;
+
+ private boolean leaf;
+
+ public TreeNodeImpl() {
+ this(false);
+ }
+
+ public TreeNodeImpl(boolean leaf) {
+ super();
+
+ this.leaf = leaf;
+
+ if (!leaf) {
+ keysList = Lists.newArrayList();
+ children = Maps.newHashMap();
+ }
+ }
+
+ public void addChild(Object key, TreeNode child) {
+ if (isLeaf()) {
+ throw new IllegalStateException("Cannot add children to leaf");
+ }
+
+ keysList.add(key);
+ children.put(key, child);
+ }
+
+ public void insertChild(int idx, Object key, TreeNode child) {
+ if (isLeaf()) {
+ throw new IllegalStateException("Cannot add children to leaf");
+ }
+
+ keysList.add(idx, key);
+ children.put(key, child);
+ }
+
+ public void removeChild(Object key) {
+ if (isLeaf()) {
+ return;
+ }
+
+ children.remove(key);
+ keysList.remove(key);
+ }
+
+ public TreeNode getChild(Object key) {
+ if (isLeaf()) {
+ return null;
+ }
+
+ return children.get(key);
+ }
+
+ public Iterator<Object> getChildrenKeysIterator() {
+ if (isLeaf()) {
+ return Iterators.emptyIterator();
+ }
+
+ return Iterators.unmodifiableIterator(keysList.iterator());
+ }
+
+ public int indexOf(Object key) {
+ if (isLeaf()) {
+ return -1;
+ }
+
+ return keysList.indexOf(key);
+ }
+
+ public boolean isLeaf() {
+ return leaf;
+ }
+
+}
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -61,7 +61,6 @@
import org.richfaces.component.util.MessageUtil;
import org.richfaces.context.ExtendedVisitContext;
import org.richfaces.context.ExtendedVisitContextMode;
-import org.richfaces.convert.SequenceRowKeyConverter;
import org.richfaces.event.TreeSelectionChangeEvent;
import org.richfaces.event.TreeSelectionChangeListener;
import org.richfaces.event.TreeSelectionChangeSource;
@@ -126,8 +125,6 @@
}
};
- private static final Converter ROW_KEY_CONVERTER = new SequenceRowKeyConverter();
-
private enum PropertyKeys {
selection
}
@@ -231,7 +228,7 @@
public Converter getRowKeyConverter() {
Converter converter = super.getRowKeyConverter();
if (converter == null) {
- converter = ROW_KEY_CONVERTER;
+ converter = getTreeDataModel().getRowKeyConverter();
}
return converter;
}
@@ -255,6 +252,10 @@
}
public AbstractTreeNode findTreeNodeComponent() {
+ if (getRowKey() == null) {
+ return null;
+ }
+
FacesContext facesContext = getFacesContext();
String nodeType = getNodeType();
@@ -319,7 +320,7 @@
boolean newExpandedValue = toggleEvent.isExpanded();
FacesContext context = getFacesContext();
- ValueExpression expression = getValueExpression(AbstractTreeNode.PropertyKeys.expanded.toString());
+ ValueExpression expression = treeNodeComponent.getValueExpression(AbstractTreeNode.PropertyKeys.expanded.toString());
if (expression != null) {
ELContext elContext = context.getELContext();
Exception caught = null;
@@ -465,10 +466,6 @@
@Attribute(hidden = true)
public boolean isLeaf() {
- if (getRowKey() == null) {
- return false;
- }
-
return getTreeDataModel().isLeaf();
}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java.orig 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,575 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.component;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UpdateModelException;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ExceptionQueuedEvent;
+import javax.faces.event.ExceptionQueuedEventContext;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.richfaces.application.MessageFactory;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.appplication.FacesMessages;
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Signature;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.component.util.MessageUtil;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.context.ExtendedVisitContextMode;
+import org.richfaces.convert.SequenceRowKeyConverter;
+import org.richfaces.event.TreeSelectionChangeEvent;
+import org.richfaces.event.TreeSelectionChangeListener;
+import org.richfaces.event.TreeSelectionChangeSource;
+import org.richfaces.event.TreeToggleEvent;
+import org.richfaces.event.TreeToggleListener;
+import org.richfaces.event.TreeToggleSource;
+import org.richfaces.model.DeclarativeTreeDataModelImpl;
+<<<<<<< HEAD
+import org.richfaces.model.DeclarativeTreeModel;
+=======
+>>>>>>> RF-9680
+import org.richfaces.model.SwingTreeNodeDataModelImpl;
+import org.richfaces.model.TreeDataModel;
+import org.richfaces.model.TreeDataModelTuple;
+import org.richfaces.model.TreeDataVisitor;
+import org.richfaces.renderkit.MetaComponentRenderer;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Strings;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@JsfComponent(
+ type = AbstractTree.COMPONENT_TYPE,
+ family = AbstractTree.COMPONENT_FAMILY,
+ tag = @Tag(name = "tree", handler = "org.richfaces.view.facelets.TreeHandler"),
+ renderer = @JsfRenderer(type = "org.richfaces.TreeRenderer"),
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"}
+)
+//TODO add rowData caching for wrapper events
+public abstract class AbstractTree extends UIDataAdaptor implements MetaComponentResolver, MetaComponentEncoder, TreeSelectionChangeSource, TreeToggleSource {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Tree";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Tree";
+
+ public static final String SELECTION_META_COMPONENT_ID = "selection";
+
+ private static final String DEFAULT_TREE_NODE_CREATED = AbstractTree.class.getName() + ":DEFAULT_TREE_NODE_CREATED";
+
+ private static final class MatchingTreeNodePredicate implements Predicate<UIComponent> {
+
+ private String type;
+
+ public MatchingTreeNodePredicate(String type) {
+ super();
+ this.type = type;
+ }
+
+ public boolean apply(UIComponent input) {
+ if (!(input instanceof AbstractTreeNode)) {
+ return false;
+ }
+
+ String nodeType = ((AbstractTreeNode) input).getType();
+ if (type == null && nodeType == null) {
+ return true;
+ }
+
+ return type != null && type.equals(nodeType);
+ }
+ };
+
+ private static final Converter ROW_KEY_CONVERTER = new SequenceRowKeyConverter();
+
+ private enum PropertyKeys {
+ selection
+ }
+
+ @SuppressWarnings("unused")
+ @Attribute(generate = false, signature = @Signature(returnType = Void.class, parameters = TreeSelectionChangeEvent.class))
+ private MethodExpression selectionChangeListener;
+
+ @SuppressWarnings("unused")
+ @Attribute(generate = false, signature = @Signature(returnType = Void.class, parameters = TreeToggleListener.class))
+ private MethodExpression toggleListener;
+
+ private transient TreeRange treeRange;
+
+ public AbstractTree() {
+ setKeepSaved(true);
+ setRendererType("org.richfaces.TreeRenderer");
+ }
+
+ protected TreeRange getTreeRange() {
+ if (treeRange == null) {
+ treeRange = new TreeRange(this);
+ }
+
+ return treeRange;
+ }
+
+ public abstract Object getValue();
+
+ public abstract boolean isImmediate();
+
+ public abstract String getIconLeaf();
+
+ public abstract String getIconExpanded();
+
+ public abstract String getIconCollapsed();
+
+ public abstract String getNodeClass();
+
+ public abstract String getHandleClass();
+
+ public abstract String getIconClass();
+
+ public abstract String getLabelClass();
+
+ @Attribute(events = @EventName("nodetoggle"))
+ public abstract String getOnnodetoggle();
+
+ @Attribute(events = @EventName("beforenodetoggle"))
+ public abstract String getOnbeforenodetoggle();
+
+ @Attribute(events = @EventName("selectionchange"))
+ public abstract String getOnselectionchange();
+
+ @Attribute(events = @EventName("beforeselectionchange"))
+ public abstract String getOnbeforeselectionchange();
+
+ @Attribute(defaultValue = "SwitchType.DEFAULT")
+ public abstract SwitchType getToggleType();
+
+ @Attribute(defaultValue = "SwitchType.client")
+ public abstract SwitchType getSelectionType();
+
+ public abstract String getNodeType();
+
+ public abstract String getToggleNodeEvent();
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public Collection<Object> getSelection() {
+ @SuppressWarnings("unchecked")
+ Collection<Object> selection = (Collection<Object>) getStateHelper().eval(PropertyKeys.selection);
+ if (selection == null) {
+ selection = new HashSet<Object>();
+
+ ValueExpression ve = getValueExpression(PropertyKeys.selection.toString());
+ if (ve != null) {
+ ve.setValue(getFacesContext().getELContext(), selection);
+ } else {
+ getStateHelper().put(PropertyKeys.selection, selection);
+ }
+ }
+
+ return selection;
+ }
+
+ public void setSelection(Collection<Object> selection) {
+ getStateHelper().put(PropertyKeys.selection, selection);
+ }
+
+ @Override
+ protected DataComponentState createComponentState() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Converter getRowKeyConverter() {
+ Converter converter = super.getRowKeyConverter();
+ if (converter == null) {
+ converter = ROW_KEY_CONVERTER;
+ }
+ return converter;
+ }
+
+ protected Iterator<UIComponent> findMatchingTreeNodeComponent(String nodeType, UIComponent parentComponent) {
+ Iterator<UIComponent> children = parentComponent.getChildren().iterator();
+ if (parentComponent != this) {
+ children = Iterators.concat(children, this.getChildren().iterator());
+ }
+
+ return Iterators.filter(children, new MatchingTreeNodePredicate(nodeType));
+ }
+
+ protected UIComponent getCurrentComponent() {
+ ExtendedDataModel<?> dataModel = getExtendedDataModel();
+ if (dataModel instanceof DeclarativeTreeModel) {
+ return ((DeclarativeTreeModel) dataModel).getCurrentComponent();
+ }
+
+ return this;
+ }
+
+ public AbstractTreeNode findTreeNodeComponent() {
+ FacesContext facesContext = getFacesContext();
+
+ String nodeType = getNodeType();
+
+ Iterator<UIComponent> nodesItr = findMatchingTreeNodeComponent(nodeType, getCurrentComponent());
+
+ if (nodesItr.hasNext()) {
+ Iterator<UIComponent> renderedNodesItr = Iterators.filter(nodesItr, ComponentPredicates.isRendered());
+ if (renderedNodesItr.hasNext()) {
+ return (AbstractTreeNode) renderedNodesItr.next();
+ }
+
+ return null;
+ }
+
+ if (Strings.isNullOrEmpty(nodeType)) {
+ if (getAttributes().put(DEFAULT_TREE_NODE_CREATED, Boolean.TRUE) != null) {
+ return null;
+ }
+
+ Application application = facesContext.getApplication();
+ AbstractTreeNode treeNode = (AbstractTreeNode) application.createComponent(AbstractTreeNode.COMPONENT_TYPE);
+ treeNode.setId("__defaultTreeNode");
+
+ getChildren().add(treeNode);
+
+ UIComponent text = application.createComponent(HtmlOutputText.COMPONENT_TYPE);
+ text.setValueExpression("value", application.getExpressionFactory().createValueExpression(facesContext.getELContext(),
+ "#{" + getVar() + "}", String.class));
+ treeNode.getChildren().add(text);
+
+ return treeNode;
+ }
+
+ return null;
+ }
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+
+ if (event instanceof TreeSelectionChangeEvent) {
+ TreeSelectionChangeEvent selectionEvent = (TreeSelectionChangeEvent) event;
+
+ final Collection<Object> newSelection = selectionEvent.getNewSelection();
+
+ Collection<Object> selectionCollection = getSelection();
+
+ Iterables.removeIf(selectionCollection, new Predicate<Object>() {
+ public boolean apply(Object input) {
+ return !newSelection.contains(input);
+ };
+ });
+
+ if (!newSelection.isEmpty()) {
+ Iterables.addAll(selectionCollection, newSelection);
+ }
+ } else if (event instanceof TreeToggleEvent) {
+ TreeToggleEvent toggleEvent = (TreeToggleEvent) event;
+ AbstractTreeNode treeNodeComponent = findTreeNodeComponent();
+
+ boolean newExpandedValue = toggleEvent.isExpanded();
+
+ FacesContext context = getFacesContext();
+ ValueExpression expression = getValueExpression(AbstractTreeNode.PropertyKeys.expanded.toString());
+ if (expression != null) {
+ ELContext elContext = context.getELContext();
+ Exception caught = null;
+ FacesMessage message = null;
+ try {
+ expression.setValue(elContext, newExpandedValue);
+ } catch (ELException e) {
+ caught = e;
+ String messageStr = e.getMessage();
+ Throwable result = e.getCause();
+ while (null != result &&
+ result.getClass().isAssignableFrom(ELException.class)) {
+ messageStr = result.getMessage();
+ result = result.getCause();
+ }
+ if (null == messageStr) {
+ MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
+ message =
+ messageFactory.createMessage(context, FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(context, this));
+ } else {
+ message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ messageStr,
+ messageStr);
+ }
+ } catch (Exception e) {
+ caught = e;
+ MessageFactory messageFactory = ServiceTracker.getService(MessageFactory.class);
+ message =
+ messageFactory.createMessage(context, FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(context, this));
+ }
+ if (caught != null) {
+ assert(message != null);
+ UpdateModelException toQueue = new UpdateModelException(message, caught);
+ ExceptionQueuedEventContext eventContext =
+ new ExceptionQueuedEventContext(context,
+ toQueue,
+ this,
+ PhaseId.UPDATE_MODEL_VALUES);
+ context.getApplication().publishEvent(context,
+ ExceptionQueuedEvent.class,
+ eventContext);
+ }
+ } else {
+ treeNodeComponent.setExpanded(newExpandedValue);
+ }
+ }
+ }
+
+ @Override
+ protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
+ if (visitContext instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;
+
+ if (ExtendedVisitContextMode.RENDER == extendedVisitContext.getVisitMode()) {
+ VisitResult result = extendedVisitContext.invokeMetaComponentVisitCallback(this, callback, SELECTION_META_COMPONENT_ID);
+ if (result != VisitResult.ACCEPT) {
+ return result == VisitResult.COMPLETE;
+ }
+ }
+ }
+
+ return super.visitFixedChildren(visitContext, callback);
+ }
+
+ void decodeMetaComponent(FacesContext context, String metaComponentId) {
+ ((MetaComponentRenderer) getRenderer(context)).decodeMetaComponent(context, this, metaComponentId);
+ }
+
+ public void encodeMetaComponent(FacesContext context, String metaComponentId) throws IOException {
+ ((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(context, this, metaComponentId);
+ }
+
+ public String resolveClientId(FacesContext facesContext, UIComponent contextComponent, String metaComponentId) {
+ if (SELECTION_META_COMPONENT_ID.equals(metaComponentId)) {
+ return getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
+ }
+
+ return null;
+ }
+
+ public String substituteUnresolvedClientId(FacesContext facesContext, UIComponent contextComponent,
+ String metaComponentId) {
+
+ return null;
+ }
+
+ @Override
+ protected Iterator<UIComponent> dataChildren() {
+ AbstractTreeNode treeNodeComponent = findTreeNodeComponent();
+ if (treeNodeComponent != null) {
+ return Iterators.<UIComponent>singletonIterator(treeNodeComponent);
+ } else {
+ return Iterators.<UIComponent>emptyIterator();
+ }
+ }
+
+ public void addTreeSelectionChangeListener(TreeSelectionChangeListener listener) {
+ addFacesListener(listener);
+ }
+
+ @Attribute(hidden = true)
+ public TreeSelectionChangeListener[] getTreeSelectionChangeListeners() {
+ return (TreeSelectionChangeListener[]) getFacesListeners(TreeSelectionChangeListener.class);
+ }
+
+ public void removeTreeSelectionChangeListener(TreeSelectionChangeListener listener) {
+ removeFacesListener(listener);
+ }
+
+ public void addTreeToggleListener(TreeToggleListener listener) {
+ addFacesListener(listener);
+ }
+
+ @Attribute(hidden = true)
+ public TreeToggleListener[] getTreeToggleListeners() {
+ return (TreeToggleListener[]) getFacesListeners(TreeToggleListener.class);
+ }
+
+ public void removeTreeToggleListener(TreeToggleListener listener) {
+ removeFacesListener(listener);
+ }
+
+ @Attribute(hidden = true)
+ public boolean isExpanded() {
+ if (getRowKey() == null) {
+ return true;
+ }
+
+ AbstractTreeNode treeNode = findTreeNodeComponent();
+ if (treeNode == null) {
+ return false;
+ }
+
+ return treeNode.isExpanded();
+ }
+
+ //TODO review
+ protected TreeDataModel<?> getTreeDataModel() {
+ return (TreeDataModel<?>) getExtendedDataModel();
+ }
+
+ @Attribute(hidden = true)
+ public boolean isLeaf() {
+ if (getRowKey() == null) {
+ return false;
+ }
+
+ return getTreeDataModel().isLeaf();
+ }
+
+ @Override
+ public void walk(final FacesContext faces, final DataVisitor visitor, final Object argument) {
+ walkModel(faces, new TreeDataVisitor() {
+
+ public void enterNode() {
+ visitor.process(faces, getRowKey(), argument);
+ }
+
+ public void exitNode() {
+ }
+
+ public void beforeChildrenVisit() {
+ }
+
+ public void afterChildrenVisit() {
+ }
+
+ });
+ }
+
+ @Override
+ protected ExtendedDataModel<?> createExtendedDataModel() {
+ ExtendedDataModel<?> dataModel;
+
+ Object value = getValue();
+ if (value == null) {
+ dataModel = new DeclarativeTreeDataModelImpl(this, getVar(), getVariablesMap(getFacesContext()));
+ } else {
+ dataModel = new SwingTreeNodeDataModelImpl();
+ dataModel.setWrappedData(getValue());
+ }
+
+ return dataModel;
+ }
+
+ public void walkModel(FacesContext context, TreeDataVisitor dataVisitor) {
+ TreeDataModel<?> model = getTreeDataModel();
+
+ if (!getTreeRange().shouldProcessNode()) {
+ return;
+ }
+
+ boolean isRootNode = (getRowKey() == null);
+
+ if (!isRootNode) {
+ dataVisitor.enterNode();
+ }
+
+ walkModelChildren(context, dataVisitor, model);
+
+ if (!isRootNode) {
+ dataVisitor.exitNode();
+ }
+ }
+
+ private void walkModelChildren(FacesContext context, TreeDataVisitor dataVisitor, TreeDataModel<?> model) {
+ if (!getTreeRange().shouldIterateChildren()) {
+ return;
+ }
+
+ dataVisitor.beforeChildrenVisit();
+
+ Iterator<TreeDataModelTuple> childrenTuples = model.children();
+ while (childrenTuples.hasNext()) {
+ TreeDataModelTuple tuple = childrenTuples.next();
+
+ restoreFromSnapshot(context, tuple);
+
+ if (!getTreeRange().shouldProcessNode()) {
+ continue;
+ }
+
+ dataVisitor.enterNode();
+
+ walkModelChildren(context, dataVisitor, model);
+
+ dataVisitor.exitNode();
+ }
+
+ dataVisitor.afterChildrenVisit();
+ }
+
+ @Override
+ protected void resetDataModel() {
+ super.resetDataModel();
+ treeRange = null;
+ }
+
+ public TreeDataModelTuple createSnapshot() {
+ return getTreeDataModel().createSnapshot();
+ }
+
+ public void restoreFromSnapshot(FacesContext context, TreeDataModelTuple tuple) {
+ getTreeDataModel().restoreFromSnapshot(tuple);
+ setRowKey(context, tuple.getRowKey());
+ }
+
+}
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/TreeRange.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/TreeRange.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/TreeRange.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -41,10 +41,18 @@
}
public boolean shouldProcessNode() {
+ if (tree.getRowKey() == null) {
+ return true;
+ }
+
return tree.findTreeNodeComponent() != null;
}
public boolean shouldIterateChildren() {
+ if (tree.getRowKey() == null) {
+ return true;
+ }
+
if (tree.isLeaf()) {
return false;
}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeyConverter.java (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeyConverter.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeyConverter.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeyConverter.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import static org.richfaces.convert.TreeConverterUtil.escape;
+import static org.richfaces.convert.TreeConverterUtil.unescape;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UINamingContainer;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+import org.richfaces.model.DeclarativeModelKey;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class DeclarativeModelKeyConverter implements Converter {
+
+ private static final class StaticHolder {
+
+ static final Joiner JOINER;
+
+ static final Splitter SPLITTER;
+
+ static {
+ char separatorChar = UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance());
+ JOINER = Joiner.on(separatorChar);
+ SPLITTER = Splitter.on(separatorChar);
+ }
+
+ private StaticHolder() {}
+
+ }
+
+ private Converter delegateConverter;
+
+ public DeclarativeModelKeyConverter(Converter delegateConverter) {
+ super();
+ this.delegateConverter = delegateConverter;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component, String value) {
+ if (Strings.isNullOrEmpty(value)) {
+ return null;
+ }
+
+ String s = unescape(value);
+
+ Iterator<String> split = StaticHolder.SPLITTER.split(s).iterator();
+
+ String modelId = (String) split.next();
+ Object modelKey = delegateConverter.getAsObject(context, component, split.next());
+
+ if (split.hasNext()) {
+ throw new ConverterException(value);
+ }
+
+ return new DeclarativeModelKey(modelId, modelKey);
+ }
+
+ public String getAsString(FacesContext context, UIComponent component, Object value) {
+ if (value == null) {
+ return "";
+ }
+
+ DeclarativeModelKey declarativeModelKey = (DeclarativeModelKey) value;
+
+ String convertedModelKey = delegateConverter.getAsString(context, component, declarativeModelKey.getModelKey());
+ String keyString = StaticHolder.JOINER.join(declarativeModelKey.getModelId(), convertedModelKey);
+
+ return escape(keyString);
+ }
+
+}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/DeclarativeModelKeySequenceRowKeyConverter.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import javax.faces.convert.IntegerConverter;
+
+import org.richfaces.model.DeclarativeModelKey;
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class DeclarativeModelKeySequenceRowKeyConverter extends SequenceRowKeyConverter<DeclarativeModelKey> {
+
+ public DeclarativeModelKeySequenceRowKeyConverter() {
+ super(DeclarativeModelKey.class, new DeclarativeModelKeyConverter(new IntegerConverter()));
+ }
+
+
+}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/IntegerSequenceRowKeyConverter.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import javax.faces.convert.IntegerConverter;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class IntegerSequenceRowKeyConverter extends SequenceRowKeyConverter<Integer> {
+
+ public IntegerSequenceRowKeyConverter() {
+ super(Integer.class, new IntegerConverter());
+ }
+
+}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/ObjectSequenceRowKeyConverter.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ObjectSequenceRowKeyConverter extends SequenceRowKeyConverter<Object> {
+
+ private static final Converter NO_OP_CONVERTER = new Converter() {
+
+ public String getAsString(FacesContext context, UIComponent component, Object value) {
+ return (String) value;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component, String value) {
+ return value;
+ }
+ };
+
+ public ObjectSequenceRowKeyConverter() {
+ super(Object.class, NO_OP_CONVERTER);
+ }
+
+}
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/SequenceRowKeyConverter.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/SequenceRowKeyConverter.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/SequenceRowKeyConverter.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,63 +1,52 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
package org.richfaces.convert;
+import java.util.List;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
-
+import javax.faces.convert.ConverterException;
+import static org.richfaces.model.TreeDataModel.*;
import org.richfaces.model.SequenceRowKey;
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.ObjectArrays;
/**
* @author Nick Belaevski
- *
+ * @since 3.3.1
*/
-public class SequenceRowKeyConverter implements Converter {
- private static final Joiner DOT_JOINER = Joiner.on('.');
+public class SequenceRowKeyConverter<T> implements Converter {
- private static final Splitter DOT_SPLITTER = Splitter.on('.');
+ private static final Splitter DOT_SPLITTER = Splitter.on(SEPARATOR_CHAR);
- private static final Function<String, Integer> INTEGER_PARSER = new Function<String, Integer>() {
- public Integer apply(String from) {
- return Integer.parseInt(from);
- };
- };
+ private Class<T> clazz;
- public Object getAsObject(FacesContext context, UIComponent component, String value) {
+ private Converter delegateConverter;
+
+ public SequenceRowKeyConverter(Class<T> clazz, Converter delegateConverter) {
+ super();
+ this.clazz = clazz;
+ this.delegateConverter = delegateConverter;
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
if (Strings.isNullOrEmpty(value)) {
return null;
}
Iterable<String> split = DOT_SPLITTER.split(value);
-
- //TODO - handle another types
- return new SequenceRowKey<Integer>(Iterables.toArray(Iterables.transform(split, INTEGER_PARSER), Integer.class));
+ List<T> keysList = Lists.<T>newArrayList();
+
+ for (String s: split) {
+ T convertedKey = clazz.cast(delegateConverter.getAsObject(context, component, s));
+ keysList.add(convertedKey);
+ }
+
+ return new SequenceRowKey(keysList.toArray(ObjectArrays.newArray(clazz, keysList.size())));
}
public String getAsString(FacesContext context, UIComponent component, Object value) {
@@ -65,10 +54,20 @@
return "";
}
- SequenceRowKey<?> sequenceRowKey = (SequenceRowKey<?>) value;
- Object[] simpleKeys=sequenceRowKey.getSimpleKeys();
-
- return DOT_JOINER.join(simpleKeys);
+ SequenceRowKey sequenceRowKey = (SequenceRowKey) value;
+
+ StringBuilder result = new StringBuilder();
+
+ for (Object simpleKey: sequenceRowKey.getSimpleKeys()) {
+ String convertedKey = delegateConverter.getAsString(context, component, simpleKey);
+
+ if (result.length() > 0) {
+ result.append(SEPARATOR_CHAR);
+ }
+
+ result.append(convertedKey);
+ }
+
+ return result.toString();
}
-
}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/TreeConverterUtil.java (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/convert/TreeConverterUtil.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/TreeConverterUtil.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/convert/TreeConverterUtil.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,264 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import java.text.MessageFormat;
+
+import javax.faces.component.UINamingContainer;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class TreeConverterUtil {
+
+ private static final class SeparatorCharHolder {
+
+ static final char SEPARATOR_CHAR = UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance());
+
+ private SeparatorCharHolder() {}
+
+ }
+
+ private static final char ESCAPE_CHAR = '_';
+
+ private TreeConverterUtil() {}
+
+ private static boolean shouldEscape(char c) {
+ if ('a' <= c && c <= 'z') {
+ return false;
+ }
+
+ if ('A' <= c && c <= 'Z') {
+ return false;
+ }
+
+ if ('0' <= c && c <= '9') {
+ return false;
+ }
+
+ if (c == ESCAPE_CHAR || c == SeparatorCharHolder.SEPARATOR_CHAR) {
+ return true;
+ }
+
+ if ('-' == c || '\u00B7' == c) {
+ return false;
+ }
+
+ if ('\u00C0' <= c && c <= '\u00D6') {
+ return false;
+ }
+
+ if ('\u00D8' <= c && c <= '\u00F6') {
+ return false;
+ }
+
+ if ('\u00F8' <= c && c <= '\u02FF') {
+ return false;
+ }
+
+ if ('\u0370' <= c && c <= '\u037D') {
+ return false;
+ }
+
+ if ('\u037F' <= c && c <= '\u1FFF') {
+ return false;
+ }
+
+ if ('\u200C' <= c && c <= '\u200D') {
+ return false;
+ }
+
+ if ('\u2070' <= c && c <= '\u218F') {
+ return false;
+ }
+
+ if ('\u2C00' <= c && c <= '\u2FEF') {
+ return false;
+ }
+
+ if ('\u3001' <= c && c <= '\uD7FF') {
+ return false;
+ }
+
+ if ('\uF900' <= c && c <= '\uFDCF') {
+ return false;
+ }
+
+ if ('\uFDF0' <= c && c <= '\uFFFD') {
+ return false;
+ }
+
+ if ('\u0300' <= c && c <= '\u036F') {
+ return false;
+ }
+
+ if ('\u203F' <= c && c <= '\u2040') {
+ return false;
+ }
+
+ return true;
+ }
+
+ private static int parseHexString(String s) {
+ int result = 0;
+
+ for (int i = 0; i < s.length(); i++) {
+ result <<= 4;
+
+ char c = s.charAt(i);
+
+ int digitValue = Character.digit(c, 16);
+ if (digitValue < 0) {
+ throw new NumberFormatException();
+ }
+
+ result += digitValue;
+ }
+
+ return result;
+ }
+
+ private static void checkAvailable(String s, int idx, int len) {
+ if (s.length() < idx + len) {
+ throw new IllegalArgumentException(MessageFormat.format("Expected {0} available chars in ''{1}'' string starting from {2} index", len, s, idx));
+ }
+ }
+
+ private static char getNextChar(String s, int idx) {
+ checkAvailable(s, idx, 1);
+
+ return s.charAt(idx);
+ }
+
+ private static char readNextCharFromHexCode(String s, int idx, int len) {
+ checkAvailable(s, idx, len);
+
+ String numString = s.substring(idx, idx + len);
+ try {
+ int charValue = parseHexString(numString);
+ return (char) charValue;
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(MessageFormat.format("Substring ''{0}'' of ''{1}'' string is not a valid hex number ", numString, s));
+ }
+ }
+
+ public static String unescape(String s) {
+ StringBuilder sb = new StringBuilder(s.length());
+
+ int startIdx = 0;
+
+ while (startIdx >= 0) {
+ int idx = s.indexOf(ESCAPE_CHAR, startIdx);
+
+ if (idx >= 0) {
+ sb.append(s.subSequence(startIdx, idx));
+
+ idx++; //skip escape char
+
+ char c = getNextChar(s, idx);
+
+ switch (c) {
+ case ESCAPE_CHAR:
+ idx++;
+ sb.append(c);
+ break;
+
+ case 'x':
+ idx++;
+ sb.append(readNextCharFromHexCode(s, idx, 2));
+ idx += 2;
+ break;
+
+ case 'u':
+ idx++;
+ sb.append(readNextCharFromHexCode(s, idx, 4));
+ idx += 4;
+ break;
+
+ default:
+ throw new IllegalArgumentException(MessageFormat.format("Unexpected char ''{0}'' in ''{1}'' string located at index {2}", c, s, idx));
+ }
+
+
+ } else {
+ sb.append(s.subSequence(startIdx, s.length()));
+ }
+
+ startIdx = idx;
+ }
+
+ return sb.toString();
+ }
+
+
+ public static String escape(String s) {
+ StringBuilder sb = new StringBuilder(s.length());
+
+ int start = 0;
+
+ char[] cs = s.toCharArray();
+ for (int idx = 0; idx < cs.length; idx++) {
+ char c = cs[idx];
+
+ if (shouldEscape(c)) {
+ sb.append(cs, start, idx - start);
+ sb.append(ESCAPE_CHAR);
+
+ if (c == ESCAPE_CHAR) {
+ sb.append(c); // ${escapeChar}
+ } else {
+ String asHex = Integer.toHexString(c);
+ switch (asHex.length()) {
+
+ case 1:
+ sb.append("x0"); // _x05
+ break;
+ case 2:
+ sb.append("x"); // _xef
+ break;
+ case 3:
+ sb.append("u0"); // _u0fed
+ break;
+ case 4:
+ sb.append("u"); // _ufcda
+ break;
+
+ default:
+ throw new IllegalArgumentException();
+ }
+
+ sb.append(asHex);
+ }
+
+ start = idx + 1;
+ }
+ }
+
+ if (start < s.length()) {
+ sb.append(cs, start, s.length() - start);
+ }
+
+ return sb.toString();
+ }
+}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeDataModelImpl.java (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeDataModelImpl.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeDataModelImpl.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeDataModelImpl.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+import javax.faces.convert.Converter;
+
+import org.richfaces.convert.ObjectSequenceRowKeyConverter;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ClassicTreeNodeDataModelImpl extends TreeSequenceKeyModel<TreeNode> {
+
+ private static final Converter DEFAULT_CONVERTER = new ObjectSequenceRowKeyConverter();
+
+ private TreeNode rootNode;
+
+ public boolean isLeaf() {
+ return getData().isLeaf();
+ }
+
+ public Iterator<TreeDataModelTuple> children() {
+ return new ClassicTreeNodeTuplesIterator(getData(), getRowKey());
+ }
+
+ @Override
+ protected TreeNode setupChildContext(Object segment) {
+ return getData().getChild(segment);
+ }
+
+ @Override
+ public Object getWrappedData() {
+ return rootNode;
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ this.rootNode = (TreeNode) data;
+ }
+
+ public Converter getRowKeyConverter() {
+ return DEFAULT_CONVERTER;
+ }
+}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeTuplesIterator.java (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeTuplesIterator.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeTuplesIterator.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/ClassicTreeNodeTuplesIterator.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+import com.google.common.collect.UnmodifiableIterator;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+final class ClassicTreeNodeTuplesIterator extends UnmodifiableIterator<TreeDataModelTuple> {
+
+ private TreeNode treeNode;
+
+ private SequenceRowKey baseKey;
+
+ private Iterator<Object> childrenKeysIterator = null;
+
+ public ClassicTreeNodeTuplesIterator(TreeNode treeNode, SequenceRowKey baseKey) {
+ super();
+ this.treeNode = treeNode;
+ this.baseKey = baseKey;
+ this.childrenKeysIterator = treeNode.getChildrenKeysIterator();
+ }
+
+ public boolean hasNext() {
+ return childrenKeysIterator.hasNext();
+ }
+
+ public TreeDataModelTuple next() {
+ Object nextChildKey = childrenKeysIterator.next();
+ Object rowKey = (baseKey != null ? baseKey.append(nextChildKey) : new SequenceRowKey(nextChildKey));
+
+ return new TreeDataModelTuple(rowKey, treeNode.getChild(nextChildKey));
+ }
+
+}
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeModelKey.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeModelKey.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeModelKey.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -23,6 +23,8 @@
import java.io.Serializable;
+import com.google.common.base.Objects;
+
/**
* @author Nick Belaevski
*
@@ -89,6 +91,6 @@
@Override
public String toString() {
- return getModelId() + "." + getModelKey();
+ return Objects.toStringHelper(this).add("modelId", getModelId()).add("modelKey", getModelKey()).toString();
}
}
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelCompositeTuplesIterator.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelCompositeTuplesIterator.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelCompositeTuplesIterator.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -40,11 +40,11 @@
private UIComponent component;
- private SequenceRowKey<DeclarativeModelKey> key;
+ private SequenceRowKey key;
private Iterator<TreeDataModelTuple> iterator;
- public DeclarativeTreeDataModelCompositeTuplesIterator(UIComponent component, SequenceRowKey<DeclarativeModelKey> key) {
+ public DeclarativeTreeDataModelCompositeTuplesIterator(UIComponent component, SequenceRowKey key) {
super();
this.component = component;
this.key = key;
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelImpl.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -21,17 +21,17 @@
*/
package org.richfaces.model;
-import static com.google.common.base.Objects.firstNonNull;
-
import java.util.Iterator;
import java.util.Map;
import javax.faces.component.UIComponent;
+import javax.faces.convert.Converter;
import org.richfaces.component.AbstractTree;
import org.richfaces.component.ComponentPredicates;
import org.richfaces.component.TreeModelAdaptor;
import org.richfaces.component.TreeModelRecursiveAdaptor;
+import org.richfaces.convert.DeclarativeModelKeySequenceRowKeyConverter;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -42,11 +42,11 @@
* @author Nick Belaevski
*
*/
-public class DeclarativeTreeDataModelImpl extends TreeSequenceKeyModel<DeclarativeModelKey, Object> implements DeclarativeTreeModel<Object> {
+public class DeclarativeTreeDataModelImpl extends TreeSequenceKeyModel<Object> implements DeclarativeTreeModel<Object> {
private static final Logger LOGGER = RichfacesLogger.MODEL.getLogger();
- private static final SequenceRowKey<DeclarativeModelKey> EMPTY_KEY = new SequenceRowKey<DeclarativeModelKey>();
+ private static final Converter DEFAULT_CONVERTER = new DeclarativeModelKeySequenceRowKeyConverter();
private String var;
@@ -57,7 +57,6 @@
private UIComponent currentComponent;
public DeclarativeTreeDataModelImpl(AbstractTree tree, String var, Map<String, Object> contextMap) {
- super();
this.tree = tree;
this.currentComponent = tree;
this.var = var;
@@ -82,13 +81,9 @@
}
public Iterator<TreeDataModelTuple> children() {
- return new DeclarativeTreeDataModelCompositeTuplesIterator(currentComponent, safeGetRowKey());
+ return new DeclarativeTreeDataModelCompositeTuplesIterator(currentComponent, getRowKey());
}
- public Object getParentRowKey(Object rowKey) {
- return safeGetRowKey().getParent();
- }
-
@Override
public Object getWrappedData() {
throw new UnsupportedOperationException();
@@ -100,7 +95,7 @@
}
@Override
- protected void walkKey(SequenceRowKey<DeclarativeModelKey> key) {
+ protected void setupKey(SequenceRowKey key) {
Object initialContextValue = null;
if (var != null) {
@@ -110,7 +105,7 @@
try {
this.currentComponent = tree;
- super.walkKey(key);
+ super.setupKey(key);
} finally {
if (var != null) {
try {
@@ -121,24 +116,29 @@
}
}
}
-
+
@Override
- protected void walkNext(DeclarativeModelKey segment) {
+ protected Object setupChildContext(Object keyObject) {
+ DeclarativeModelKey segment = (DeclarativeModelKey) keyObject;
+ if (var != null) {
+ contextMap.put(var, getData());
+ }
+
String modelId = segment.getModelId();
-
+
UIComponent modelComponent;
-
+
if (currentComponent instanceof TreeModelRecursiveAdaptor && modelId.equals(currentComponent.getId())) {
modelComponent = currentComponent;
} else {
modelComponent = Iterables.find(currentComponent.getChildren(), ComponentPredicates.withId(modelId));
}
-
+
Object nodes = null;
-
+
if (modelComponent instanceof TreeModelRecursiveAdaptor) {
TreeModelRecursiveAdaptor recursiveAdaptor = (TreeModelRecursiveAdaptor) modelComponent;
-
+
if (currentComponent.equals(modelComponent)) {
nodes = recursiveAdaptor.getNodes();
} else {
@@ -147,20 +147,13 @@
} else {
nodes = ((TreeModelAdaptor) modelComponent).getNodes();
}
-
+
Object data = Iterables.get((Iterable<?>) nodes, (Integer) segment.getModelKey());
- setRowKeyAndData(safeGetRowKey().append(segment), data);
this.currentComponent = modelComponent;
-
- if (var != null) {
- contextMap.put(var, data);
- }
+
+ return data;
}
-
- private SequenceRowKey<DeclarativeModelKey> safeGetRowKey() {
- return firstNonNull(getRowKey(), EMPTY_KEY);
- }
-
+
public TreeDataModelTuple createSnapshot() {
return new DeclarativeTreeDataModelTuple(getRowKey(), getData(), getCurrentComponent());
}
@@ -172,4 +165,7 @@
this.currentComponent = declarativeModelTuple.getComponent();
}
+ public Converter getRowKeyConverter() {
+ return DEFAULT_CONVERTER;
+ }
}
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelTuplesIterator.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelTuplesIterator.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/DeclarativeTreeDataModelTuplesIterator.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -25,17 +25,19 @@
import javax.faces.component.UIComponent;
-final class DeclarativeTreeDataModelTuplesIterator implements Iterator<TreeDataModelTuple> {
+import com.google.common.collect.UnmodifiableIterator;
+
+final class DeclarativeTreeDataModelTuplesIterator extends UnmodifiableIterator<TreeDataModelTuple> {
private UIComponent component;
- private SequenceRowKey<DeclarativeModelKey> baseKey;
+ private SequenceRowKey baseKey;
private int counter = 0;
private Iterator<?> dataIterator;
- public DeclarativeTreeDataModelTuplesIterator(UIComponent component, SequenceRowKey<DeclarativeModelKey> baseKey, Iterator<?> dataIterator) {
+ public DeclarativeTreeDataModelTuplesIterator(UIComponent component, SequenceRowKey baseKey, Iterator<?> dataIterator) {
super();
this.component = component;
this.baseKey = baseKey;
@@ -46,7 +48,7 @@
Object nextNode = dataIterator.next();
DeclarativeModelKey key = new DeclarativeModelKey(component.getId(), counter++);
- SequenceRowKey<DeclarativeModelKey> newKey = baseKey.append(key);
+ SequenceRowKey newKey = (baseKey != null ? baseKey.append(key) : new SequenceRowKey(key));
return new DeclarativeTreeDataModelTuple(newKey, nextNode, component);
}
@@ -55,8 +57,4 @@
return dataIterator.hasNext();
}
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
}
\ No newline at end of file
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -30,41 +30,33 @@
* @author Nick Belaevski
*
*/
-public class SequenceRowKey<T> implements Serializable {
+public class SequenceRowKey implements Serializable {
private static final long serialVersionUID = 5605581090240141910L;
- private T[] simpleKeys;
+ private Object[] simpleKeys;
- public SequenceRowKey(T... keys) {
+ public SequenceRowKey(Object... keys) {
super();
this.simpleKeys = keys;
}
- public T[] getSimpleKeys() {
+ public Object[] getSimpleKeys() {
return simpleKeys;
}
- public SequenceRowKey<T> append(T segment) {
- return new SequenceRowKey<T>(ObjectArrays.concat(simpleKeys, segment));
+ public SequenceRowKey append(Object segment) {
+ return new SequenceRowKey(ObjectArrays.concat(simpleKeys, segment));
}
- public T getLastKeySegment() {
+ public SequenceRowKey getParent() {
if (simpleKeys.length == 0) {
return null;
}
- return simpleKeys[simpleKeys.length - 1];
- }
-
- public SequenceRowKey<T> getParent() {
- if (simpleKeys.length == 0) {
- return null;
- }
-
- T[] parentSimpleKeys = ObjectArrays.newArray(simpleKeys, simpleKeys.length - 1);
+ Object[] parentSimpleKeys = ObjectArrays.newArray(simpleKeys, simpleKeys.length - 1);
System.arraycopy(simpleKeys, 0, parentSimpleKeys, 0, parentSimpleKeys.length);
- return new SequenceRowKey<T>(parentSimpleKeys);
+ return new SequenceRowKey(parentSimpleKeys);
}
@Override
@@ -86,7 +78,7 @@
if (getClass() != obj.getClass()) {
return false;
}
- SequenceRowKey<?> other = (SequenceRowKey<?>) obj;
+ SequenceRowKey other = (SequenceRowKey) obj;
if (!Arrays.equals(simpleKeys, other.simpleKeys)) {
return false;
}
@@ -97,4 +89,5 @@
public String toString() {
return getClass().getName() + Arrays.toString(simpleKeys);
}
-}
+
+}
\ No newline at end of file
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -21,23 +21,24 @@
*/
package org.richfaces.model;
-import static com.google.common.base.Objects.firstNonNull;
-
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
+import javax.faces.convert.Converter;
import javax.swing.tree.TreeNode;
+import org.richfaces.convert.IntegerSequenceRowKeyConverter;
+
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
/**
* @author Nick Belaevski
*
*/
-public class SwingTreeNodeDataModelImpl extends TreeSequenceKeyModel<Integer, TreeNode> {
+public class SwingTreeNodeDataModelImpl extends TreeSequenceKeyModel<TreeNode> {
- private static final SequenceRowKey<Integer> EMPTY_KEY = new SequenceRowKey<Integer>();
+ private static final Converter DEFAULT_CONVERTER = new IntegerSequenceRowKeyConverter();
private boolean asksAllowsChildren = false;
@@ -61,10 +62,6 @@
return treeNodeImpl;
}
- public Object getParentRowKey(Object rowKey) {
- throw new UnsupportedOperationException();
- }
-
public void setWrappedData(Object data) {
this.wrappedData = data;
@@ -93,14 +90,11 @@
}
@Override
- protected void walkNext(Integer segment) {
- TreeNode child = findChild(getData(), segment);
- //TODO what if node is missing?
- //TODO - optimize - remove partial keys creation
- setRowKeyAndData(safeGetRowKey().append(segment), child);
+ protected TreeNode setupChildContext(Object segment) {
+ return findChild(getData(), (Integer) segment);
}
-
- private SequenceRowKey<Integer> safeGetRowKey() {
- return firstNonNull(getRowKey(), EMPTY_KEY);
+
+ public Converter getRowKeyConverter() {
+ return DEFAULT_CONVERTER;
}
}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java.orig 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import javax.swing.tree.TreeNode;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SwingTreeNodeDataModelImpl extends TreeSequenceKeyModel<Integer, TreeNode> {
+
+ private final class SwingTreeNodeRowKeyIterator implements Iterator<TreeDataModelTuple> {
+
+ private SequenceRowKey<Integer> baseKey;
+
+ private Iterator<TreeNode> children;
+
+ private int counter = 0;
+
+ private SwingTreeNodeRowKeyIterator(SequenceRowKey<Integer> baseKey, Iterator<TreeNode> children) {
+ this.baseKey = baseKey;
+ this.children = children;
+ }
+
+ private int getNextCounterValue() {
+ return counter++;
+ }
+
+ public boolean hasNext() {
+ return children.hasNext();
+ }
+
+ public TreeDataModelTuple next() {
+ TreeNode node = children.next();
+
+ SequenceRowKey<Integer> key;
+
+ if (baseKey != null) {
+ key = baseKey.append(getNextCounterValue());
+ } else {
+ key = new SequenceRowKey<Integer>(getNextCounterValue());
+ }
+
+ return new TreeDataModelTuple(key, node);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+ private final class FakeRootNode implements TreeNode {
+
+ private Collection<TreeNode> wrappedData;
+
+ public FakeRootNode(Collection<TreeNode> wrappedData) {
+ super();
+ this.wrappedData = wrappedData;
+ }
+
+ public boolean isLeaf() {
+ return !wrappedData.isEmpty();
+ }
+
+ public TreeNode getParent() {
+ return null;
+ }
+
+ public int getIndex(TreeNode node) {
+ if (wrappedData == null) {
+ return -1;
+ }
+
+ return Iterables.indexOf(wrappedData, Predicates.equalTo(node));
+ }
+
+ public int getChildCount() {
+ if (wrappedData == null) {
+ return 0;
+ }
+
+ return wrappedData.size();
+ }
+
+ public TreeNode getChildAt(int childIndex) {
+ if (wrappedData == null) {
+ throw new NoSuchElementException(String.valueOf(childIndex));
+ }
+
+ return Iterables.get(wrappedData, childIndex);
+ }
+
+ public boolean getAllowsChildren() {
+ return true;
+ }
+
+ public Enumeration<?> children() {
+ if (wrappedData == null) {
+ return Iterators.asEnumeration(Iterators.emptyIterator());
+ }
+
+ return Iterators.asEnumeration(wrappedData.iterator());
+ }
+
+ public Collection<TreeNode> getWrappedData() {
+ return wrappedData;
+ }
+ }
+
+ private boolean asksAllowsChildren = false;
+
+ private Iterator<TreeNode> safeGetChildren(TreeNode treeNode) {
+ if (treeNode == null) {
+ return Iterators.emptyIterator();
+ }
+
+ return Iterators.forEnumeration((Enumeration<TreeNode>) treeNode.children());
+ }
+
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setWrappedData(Object data) {
+ setRootNode(new FakeRootNode((Collection<TreeNode>) data));
+ }
+
+ public Collection<TreeNode> getWrappedData() {
+ FakeRootNode rootNode = (FakeRootNode) getRootNode();
+ if (rootNode == null) {
+ return null;
+ }
+ return rootNode.getWrappedData();
+ }
+
+ protected TreeNode findChild(TreeNode parent, Integer simpleKey) {
+ return parent.getChildAt(simpleKey.intValue());
+ }
+
+ public Iterator<TreeDataModelTuple> children() {
+ return new SwingTreeNodeRowKeyIterator(getRowKey(), safeGetChildren(getData()));
+ }
+
+
+ public boolean isLeaf() {
+ if (!asksAllowsChildren) {
+ return getData().isLeaf();
+ } else {
+ return !getData().getAllowsChildren();
+ }
+ }
+
+ @Override
+ protected void walkNext(Integer segment) {
+ TreeNode child = findChild(getData(), segment);
+ //TODO what if node is missing?
+ //TODO - optimize - remove partial keys creation
+ setRowKeyAndData(safeGetRowKey().append(segment), child);
+ }
+<<<<<<< HEAD
+
+=======
+
+>>>>>>> RF-9680
+}
\ No newline at end of file
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeTuplesIterator.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeTuplesIterator.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeTuplesIterator.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -25,15 +25,17 @@
import javax.swing.tree.TreeNode;
-final class SwingTreeNodeTuplesIterator implements Iterator<TreeDataModelTuple> {
+import com.google.common.collect.UnmodifiableIterator;
- private SequenceRowKey<Integer> baseKey;
+final class SwingTreeNodeTuplesIterator extends UnmodifiableIterator<TreeDataModelTuple> {
+
+ private SequenceRowKey baseKey;
private Iterator<TreeNode> children;
private int counter = 0;
- SwingTreeNodeTuplesIterator(SequenceRowKey<Integer> baseKey, Iterator<TreeNode> children) {
+ SwingTreeNodeTuplesIterator(SequenceRowKey baseKey, Iterator<TreeNode> children) {
this.baseKey = baseKey;
this.children = children;
}
@@ -49,19 +51,15 @@
public TreeDataModelTuple next() {
TreeNode node = children.next();
- SequenceRowKey<Integer> key;
+ SequenceRowKey key;
if (baseKey != null) {
key = baseKey.append(getNextCounterValue());
} else {
- key = new SequenceRowKey<Integer>(getNextCounterValue());
+ key = new SequenceRowKey(getNextCounterValue());
}
return new TreeDataModelTuple(key, node);
}
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
}
\ No newline at end of file
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -32,29 +32,35 @@
* @author Nick Belaevski
*
*/
-public abstract class TreeSequenceKeyModel<K, V> extends ExtendedDataModel<V> implements TreeDataModel<V> {
+public abstract class TreeSequenceKeyModel<V> extends ExtendedDataModel<V> implements TreeDataModel<V> {
private V rootNode;
private V data;
- private SequenceRowKey<K> rowKey;
+ private SequenceRowKey rowKey;
- public SequenceRowKey<K> getRowKey() {
+ public SequenceRowKey getRowKey() {
return rowKey;
}
public void setRowKey(Object rowKey) {
+ SequenceRowKey sequenceKey = (SequenceRowKey) rowKey;
+
if (this.rowKey == null || !this.rowKey.equals(rowKey)) {
- walkKey((SequenceRowKey<K>) rowKey);
+ setupKey(sequenceKey);
}
}
-
+
protected void resetRowKeyAndData() {
setRowKeyAndData(null, rootNode);
}
- protected void setRowKeyAndData(SequenceRowKey<K> key, V data) {
+ protected void setData(V data) {
+ this.data = data;
+ }
+
+ protected void setRowKeyAndData(SequenceRowKey key, V data) {
this.rowKey = key;
this.data = data;
}
@@ -71,17 +77,22 @@
return data;
}
- protected void walkKey(SequenceRowKey<K> key) {
+ protected void setupKey(SequenceRowKey key) {
resetRowKeyAndData();
if (key != null) {
- for (K simpleKey: key.getSimpleKeys()) {
- walkNext(simpleKey);
+ V data = getRootNode();
+
+ for (Object simpleKey: key.getSimpleKeys()) {
+ data = setupChildContext(simpleKey);
+ setData(data);
}
+
+ setRowKeyAndData(key, data);
}
}
- protected abstract void walkNext(K segment);
+ protected abstract V setupChildContext(Object segment);
protected V getRootNode() {
return rootNode;
@@ -132,6 +143,16 @@
}
public void restoreFromSnapshot(TreeDataModelTuple tuple) {
- setRowKeyAndData((SequenceRowKey<K>) tuple.getRowKey(), (V) tuple.getData());
+ setRowKeyAndData((SequenceRowKey) tuple.getRowKey(), (V) tuple.getData());
}
+
+ public Object getParentRowKey(Object rowKey) {
+ SequenceRowKey key = getRowKey();
+
+ if (key == null) {
+ return null;
+ }
+
+ return key.getParent();
+ }
}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/model/TreeSequenceKeyModel.java.orig 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class TreeSequenceKeyModel<K, V> extends ExtendedDataModel<V> implements TreeDataModel<V> {
+
+ private final SequenceRowKey<K> emptyKey = new SequenceRowKey<K>();
+
+<<<<<<< HEAD
+ private V rootNode;
+
+=======
+>>>>>>> RF-9680:
+ private V data;
+
+ private SequenceRowKey<K> rowKey;
+
+ public SequenceRowKey<K> getRowKey() {
+ return rowKey;
+ }
+
+ protected SequenceRowKey<K> safeGetRowKey() {
+ SequenceRowKey<K> key = getRowKey();
+
+ if (key == null) {
+ key = emptyKey;
+ }
+
+ return key;
+ }
+
+ public void setRowKey(Object rowKey) {
+ if (this.rowKey == null || !this.rowKey.equals(rowKey)) {
+<<<<<<< HEAD
+ walkKey((SequenceRowKey<K>) rowKey);
+ }
+ }
+
+ protected void resetRowKeyAndData() {
+ setRowKeyAndData(null, rootNode);
+ }
+
+=======
+ this.rowKey = (SequenceRowKey<K>) rowKey;
+ this.data = findData(this.rowKey);
+ }
+ }
+
+>>>>>>> RF-9680:
+ protected void setRowKeyAndData(SequenceRowKey<K> key, V data) {
+ this.rowKey = key;
+ this.data = data;
+ }
+
+ public boolean isDataAvailable() {
+<<<<<<< HEAD
+ return getRowKey() == null || data != null;
+=======
+ return data != null;
+>>>>>>> RF-9680:
+ }
+
+ public V getData() {
+ if (!isDataAvailable()) {
+ throw new IllegalArgumentException();
+ }
+
+ return data;
+ }
+<<<<<<< HEAD
+
+ protected void walkKey(SequenceRowKey<K> key) {
+ resetRowKeyAndData();
+=======
+
+ protected V findData(SequenceRowKey<K> key) {
+ if (key == null) {
+ return rootNode;
+ }
+
+ V result = rootNode;
+
+ for (K simpleKey : key.getSimpleKeys()) {
+ result = findChild(result, simpleKey);
+>>>>>>> RF-9680:
+
+ if (key != null) {
+ for (K simpleKey: key.getSimpleKeys()) {
+ walkNext(simpleKey);
+ }
+ }
+ }
+
+ protected abstract void walkNext(K segment);
+
+ protected V getRootNode() {
+ return rootNode;
+ }
+
+ protected void setRootNode(V rootNode) {
+ this.rootNode = rootNode;
+ }
+
+ //TODO ExtendedDataModel legacy
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @Override
+ public boolean isRowAvailable() {
+ return isDataAvailable();
+ }
+
+
+ @Override
+ public int getRowCount() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @Override
+ public V getRowData() {
+ return getData();
+ }
+
+
+ @Override
+ public int getRowIndex() {
+ throw new UnsupportedOperationException();
+ }
+
+
+ @Override
+ public void setRowIndex(int rowIndex) {
+ throw new UnsupportedOperationException();
+<<<<<<< HEAD
+ }
+
+ public TreeDataModelTuple createSnapshot() {
+ return new TreeDataModelTuple(getRowKey(), getData());
+ }
+
+ public void restoreFromSnapshot(TreeDataModelTuple tuple) {
+ setRowKeyAndData((SequenceRowKey<K>) tuple.getRowKey(), (V) tuple.getData());
+=======
+>>>>>>> RF-9680:
+ }
+}
Copied: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig (from rev 20315, trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java.orig 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,227 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.component.AbstractTree;
+import org.richfaces.component.AbstractTreeNode;
+import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.model.TreeDataModelTuple;
+import org.richfaces.model.TreeDataVisitor;
+
+abstract class TreeEncoderBase implements TreeDataVisitor {
+
+ private static final class QueuedData {
+
+ private enum State {
+ initial, visited, encoded
+ }
+
+ private State state = State.initial;
+
+ private TreeDataModelTuple tuple;
+
+ public QueuedData(TreeDataModelTuple tuple) {
+ super();
+ this.tuple = tuple;
+ }
+
+ public boolean isEncoded() {
+ return state == State.encoded;
+ }
+
+ public void makeEncoded() {
+ this.state = State.encoded;
+ }
+
+ public void makeVisited() {
+ this.state = State.visited;
+ }
+
+ public boolean isVisited() {
+ return state == State.visited;
+ }
+
+ public TreeDataModelTuple getTuple() {
+ return tuple;
+ }
+
+ }
+
+ static final String TREE_NODE_STATE_ATTRIBUTE = "__treeNodeState";
+
+ protected final FacesContext context;
+
+ protected final ResponseWriter responseWriter;
+
+ protected final AbstractTree tree;
+
+<<<<<<< HEAD
+ private LinkedList<QueuedData> queuedDataList = new LinkedList<QueuedData>();
+
+=======
+>>>>>>> RF-9680:
+ public TreeEncoderBase(FacesContext context, AbstractTree tree) {
+ super();
+ this.context = context;
+ this.responseWriter = context.getResponseWriter();
+ this.tree = tree;
+ }
+
+ protected void encodeTree() throws IOException {
+ tree.walkModel(context, this);
+ }
+
+<<<<<<< HEAD
+ protected void flushParentNode() throws IOException {
+ if (queuedDataList.isEmpty()) {
+ return;
+ }
+
+ QueuedData data = queuedDataList.getLast();
+ if (!data.isEncoded()) {
+ data.makeEncoded();
+ tree.restoreFromSnapshot(context, data.getTuple());
+
+ TreeNodeState nodeState = getNodeState(tree.isLeaf(), false);
+
+ writeTreeNodeStartElement(nodeState);
+ tree.findTreeNodeComponent().encodeAll(context);
+ }
+ }
+
+ private TreeNodeState getNodeState(boolean leaf, boolean visited) {
+ TreeNodeState nodeState;
+ if (leaf) {
+ nodeState = TreeNodeState.leaf;
+ } else if (visited) {
+ nodeState = TreeNodeState.expandedNoChildren;
+ } else if (tree.isExpanded()) {
+ nodeState = TreeNodeState.expanded;
+ } else {
+ nodeState = TreeNodeState.collapsed;
+ }
+ return nodeState;
+ }
+
+ public void beforeChildrenVisit() {
+ if (!queuedDataList.isEmpty()) {
+ queuedDataList.getLast().makeVisited();
+ }
+ }
+
+ public void afterChildrenVisit() {
+ }
+
+ public void enterNode() {
+ TreeDataModelTuple tuple = tree.createSnapshot();
+ QueuedData queuedData = new QueuedData(tuple);
+
+ try {
+ flushParentNode();
+ } catch (IOException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+
+ tree.restoreFromSnapshot(context, tuple);
+ queuedDataList.add(queuedData);
+ }
+
+ public void exitNode() {
+ QueuedData data = queuedDataList.removeLast();
+
+ tree.restoreFromSnapshot(context, data.getTuple());
+ try {
+ if (!data.isEncoded()) {
+ writeTreeNodeStartElement(getNodeState(tree.isLeaf(), data.isVisited()));
+ tree.findTreeNodeComponent().encodeAll(context);
+ }
+
+=======
+ public void enterNode() {
+ TreeNodeState state;
+ if (tree.isLeaf()) {
+ state = TreeNodeState.leaf;
+ } else {
+ if (tree.isExpanded()) {
+ state = TreeNodeState.expanded;
+ } else {
+ state = TreeNodeState.collapsed;
+ }
+ }
+
+ try {
+ writeTreeNodeStartElement(state);
+ tree.findTreeNodeComponent().encodeAll(context);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void exitNode() {
+ try {
+>>>>>>> RF-9680:
+ writeTreeNodeEndElement();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ protected void writeTreeNodeStartElement(TreeNodeState nodeState) throws IOException {
+ AbstractTreeNode treeNodeComponent = tree.findTreeNodeComponent();
+
+ context.getAttributes().put(TREE_NODE_STATE_ATTRIBUTE, nodeState);
+
+ responseWriter.startElement(HtmlConstants.DIV_ELEM, tree);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE,
+ HtmlUtil.concatClasses("rf-tr-nd", nodeState.getNodeClass()),
+ null);
+ responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, treeNodeComponent.getClientId(context), null);
+
+ emitClientToggleEvent(treeNodeComponent, nodeState);
+ }
+
+ protected void writeTreeNodeEndElement() throws IOException {
+ responseWriter.endElement(HtmlConstants.DIV_ELEM);
+ }
+
+ public abstract void encode() throws IOException;
+
+ private void emitClientToggleEvent(AbstractTreeNode treeNode, TreeNodeState nodeState) {
+ if (treeNode.getClientId(context).equals(context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_ATTRIBUTE))) {
+ TreeNodeState initialState = (TreeNodeState) context.getAttributes().get(TreeNodeRendererBase.AJAX_TOGGLED_NODE_STATE_ATTRIBUTE);
+
+ if (initialState.isDifferentThan(nodeState)) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ ajaxContext.appendOncomplete(new JSFunction("RichFaces.ui.TreeNode.emitToggleEvent", treeNode.getClientId(context)));
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert (from rev 20315, trunk/ui/iteration/ui/src/test/java/org/richfaces/convert)
Deleted: branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java
===================================================================
--- trunk/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java 2010-12-02 17:52:54 UTC (rev 20315)
+++ branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -1,194 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.convert;
-
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.richfaces.convert.TreeConverterUtil.escape;
-import static org.richfaces.convert.TreeConverterUtil.unescape;
-
-import java.util.HashMap;
-
-import javax.faces.context.FacesContext;
-
-import org.jboss.test.faces.mock.Environment;
-import org.jboss.test.faces.mock.Mock;
-import org.jboss.test.faces.mock.MockFacesEnvironment;
-import org.jboss.test.faces.mock.MockTestRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * @author Nick Belaevski
- *
- */
-(a)RunWith(MockTestRunner.class)
-public class TreeConverterUtilTest {
-
- @Mock
- private FacesContext context;
-
- @Mock
- @Environment({Environment.Feature.EXTERNAL_CONTEXT})
- private MockFacesEnvironment environment;
-
- @Before
- public void setUp() throws Exception {
- environment.resetToNice();
- FacesContext facesContext = FacesContext.getCurrentInstance();
- expect(facesContext.getAttributes()).andStubReturn(new HashMap<Object, Object>());
- environment.replay();
- }
-
- @Test
- public void testUnescape() throws Exception {
- assertEquals("", unescape(""));
- assertEquals("a", unescape("a"));
- assertEquals("abc", unescape("abc"));
-
-
- assertEquals("_", unescape("__"));
- assertEquals("__", unescape("____"));
-
- assertEquals("_a", unescape("__a"));
- assertEquals("_abc", unescape("__abc"));
-
- assertEquals("a_", unescape("a__"));
- assertEquals("abc_", unescape("abc__"));
-
- assertEquals("some_test", unescape("some__test"));
-
- assertEquals("\u0000", unescape("_x00"));
- assertEquals("\u0001", unescape("_x01"));
- assertEquals("\u0010", unescape("_x10"));
- assertEquals("\u0077", unescape("_x77"));
- assertEquals("\u00A9", unescape("_xa9"));
- assertEquals("\u00FF", unescape("_xFF"));
- assertEquals("\u00FF", unescape("_xff"));
-
- assertEquals(".", unescape("_x2e"));
-
- assertEquals("\u0000", unescape("_u0000"));
- assertEquals("\u0001", unescape("_u0001"));
- assertEquals("\uE1A4", unescape("_ue1a4"));
- assertEquals("\uF000", unescape("_uF000"));
- assertEquals("\uFFFF", unescape("_uFFFF"));
-
-
- assertEquals(".", unescape("_u002E"));
-
- assertEquals("Embedded_underscores\u0312unicode\u0045etc", unescape("Embedded__underscores_u0312unicode_x45etc"));
-
- try {
- unescape("_");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("some _a string");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("_x");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("_x0");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("_u");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("_u-1aaa");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("_u1zaa");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("embedded _x 00 into string");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("embedded _x0 into string");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
-
- try {
- unescape("embedded _u012 into string");
-
- fail();
- } catch (IllegalArgumentException e) {
- System.out.println(e.getMessage());
- }
- }
-
- @Test
- public void testEscape() throws Exception {
- assertEquals("", escape(""));
- assertEquals("__a__b__", escape("_a_b_"));
- assertEquals("_x3a0_x3a1", escape(":0:1"));
- assertEquals("testTEST05", escape("testTEST05"));
- assertEquals("a_xa9c", escape("a\u00a9c"));
- assertEquals("a_u037ec", escape("a\u037ec"));
- assertEquals("a_ue1acd", escape("a\ue1acd"));
- }
-}
Copied: branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java (from rev 20315, trunk/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java)
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java (rev 0)
+++ branches/RF-8742-1/ui/iteration/ui/src/test/java/org/richfaces/convert/TreeConverterUtilTest.java 2010-12-02 18:53:41 UTC (rev 20318)
@@ -0,0 +1,194 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.convert;
+
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.richfaces.convert.TreeConverterUtil.escape;
+import static org.richfaces.convert.TreeConverterUtil.unescape;
+
+import java.util.HashMap;
+
+import javax.faces.context.FacesContext;
+
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+(a)RunWith(MockTestRunner.class)
+public class TreeConverterUtilTest {
+
+ @Mock
+ private FacesContext context;
+
+ @Mock
+ @Environment({Environment.Feature.EXTERNAL_CONTEXT})
+ private MockFacesEnvironment environment;
+
+ @Before
+ public void setUp() throws Exception {
+ environment.resetToNice();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ expect(facesContext.getAttributes()).andStubReturn(new HashMap<Object, Object>());
+ environment.replay();
+ }
+
+ @Test
+ public void testUnescape() throws Exception {
+ assertEquals("", unescape(""));
+ assertEquals("a", unescape("a"));
+ assertEquals("abc", unescape("abc"));
+
+
+ assertEquals("_", unescape("__"));
+ assertEquals("__", unescape("____"));
+
+ assertEquals("_a", unescape("__a"));
+ assertEquals("_abc", unescape("__abc"));
+
+ assertEquals("a_", unescape("a__"));
+ assertEquals("abc_", unescape("abc__"));
+
+ assertEquals("some_test", unescape("some__test"));
+
+ assertEquals("\u0000", unescape("_x00"));
+ assertEquals("\u0001", unescape("_x01"));
+ assertEquals("\u0010", unescape("_x10"));
+ assertEquals("\u0077", unescape("_x77"));
+ assertEquals("\u00A9", unescape("_xa9"));
+ assertEquals("\u00FF", unescape("_xFF"));
+ assertEquals("\u00FF", unescape("_xff"));
+
+ assertEquals(".", unescape("_x2e"));
+
+ assertEquals("\u0000", unescape("_u0000"));
+ assertEquals("\u0001", unescape("_u0001"));
+ assertEquals("\uE1A4", unescape("_ue1a4"));
+ assertEquals("\uF000", unescape("_uF000"));
+ assertEquals("\uFFFF", unescape("_uFFFF"));
+
+
+ assertEquals(".", unescape("_u002E"));
+
+ assertEquals("Embedded_underscores\u0312unicode\u0045etc", unescape("Embedded__underscores_u0312unicode_x45etc"));
+
+ try {
+ unescape("_");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("some _a string");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("_x");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("_x0");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("_u");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("_u-1aaa");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("_u1zaa");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("embedded _x 00 into string");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("embedded _x0 into string");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+
+ try {
+ unescape("embedded _u012 into string");
+
+ fail();
+ } catch (IllegalArgumentException e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testEscape() throws Exception {
+ assertEquals("", escape(""));
+ assertEquals("__a__b__", escape("_a_b_"));
+ assertEquals("_x3a0_x3a1", escape(":0:1"));
+ assertEquals("testTEST05", escape("testTEST05"));
+ assertEquals("a_xa9c", escape("a\u00a9c"));
+ assertEquals("a_u037ec", escape("a\u037ec"));
+ assertEquals("a_ue1acd", escape("a\ue1acd"));
+ }
+}
Modified: branches/RF-8742-1/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss
===================================================================
--- branches/RF-8742-1/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss 2010-12-02 18:06:35 UTC (rev 20317)
+++ branches/RF-8742-1/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/toolBar.ecss 2010-12-02 18:53:41 UTC (rev 20318)
@@ -11,7 +11,6 @@
background-repeat:repeat-x;
/*check gradient from headerGradientColor to headerBackgroundColor*/
background-image:url("#{resource['org.richfaces.renderkit.html.GradientA']}");
- height:36px;
width:100%;
}
13 years, 6 months
JBoss Rich Faces SVN: r20317 - in sandbox/trunk/ui/dropdown-menu/ui/src/main: java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-12-02 13:06:35 -0500 (Thu, 02 Dec 2010)
New Revision: 20317
Modified:
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractDropDownMenu.java
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractMenuGroup.java
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractMenuItem.java
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/dropdownmenu.template.xml
sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menugroup.template.xml
sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menuitem.template.xml
Log:
@ResourceDependencies was added to wrap @ResourceDependency
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractDropDownMenu.java
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractDropDownMenu.java 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractDropDownMenu.java 2010-12-02 18:06:35 UTC (rev 20317)
@@ -23,7 +23,7 @@
@Attribute
public abstract String getShowEvent();
- @Attribute
+ @Attribute(defaultValue = MenuComponent.MODE_SERVER)
public abstract String getMode();
@Attribute
@@ -33,8 +33,17 @@
public abstract int getHideDelay();
@Attribute(defaultValue = "800")
- public abstract int getShowDelay();
+ public abstract int getShowDelay();
+ @Attribute(defaultValue = "250")
+ public abstract int getPopupWith();
+
+ @Attribute(defaultValue = "auto")
+ public abstract String getJointPoint();
+
+ @Attribute(defaultValue = "auto")
+ public abstract String getDirection();
+
@Attribute(events = @EventName("groupshow"))
public abstract String getOngroupshow();
@@ -47,6 +56,9 @@
@Attribute(events = @EventName("hide"))
public abstract String getOnhide();
+ @Attribute(events = @EventName("itemclick"))
+ public abstract String getOnitemclick();
+
public enum Facets {
LABEL("label"), LABEL_DISABLED("labelDisabled");
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractMenuGroup.java
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractMenuGroup.java 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractMenuGroup.java 2010-12-02 18:06:35 UTC (rev 20317)
@@ -38,11 +38,14 @@
@Attribute
public abstract String getStyle();
+ @Attribute(defaultValue = "auto")
+ public abstract String getDirection();
+
@Attribute(defaultValue = "0")
- public abstract int getVerticalOffset();
+ public abstract String getVerticalOffset();
@Attribute(defaultValue = "0")
- public abstract int getHorizontalOffset();
+ public abstract String getHorizontalOffset();
@Attribute(events = @EventName("show"))
public abstract String getOnshow();
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractMenuItem.java
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractMenuItem.java 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/component/AbstractMenuItem.java 2010-12-02 18:06:35 UTC (rev 20317)
@@ -51,5 +51,4 @@
return facetName;
}
}
-
}
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2010-12-02 18:06:35 UTC (rev 20317)
@@ -34,6 +34,8 @@
public static final String RENDERER_TYPE = "org.richfaces.DropDownMenuRenderer";
+ public static final int DEFAULT_MIN_POPUP_WIDTH = 250;
+
@Override
public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
AbstractDropDownMenu dropDownMenu = (AbstractDropDownMenu) component;
@@ -49,14 +51,14 @@
}
}
- protected boolean isDisabled(UIComponent component) {
+ protected boolean isDisabled(FacesContext facesContext, UIComponent component) {
if (component instanceof AbstractDropDownMenu) {
return ((AbstractDropDownMenu) component).isDisabled();
}
return false;
}
- protected UIComponent getLabelFacet(UIComponent component) {
+ protected UIComponent getLabelFacet(FacesContext facesContext, UIComponent component) {
UIComponent facet = null;
AbstractDropDownMenu ddmenu = (AbstractDropDownMenu) component;
if (ddmenu != null) {
@@ -80,6 +82,7 @@
map.put("id", group.getClientId());
map.put("horizontalOffset", group.getHorizontalOffset());
map.put("verticalOffset", group.getVerticalOffset());
+ map.put("direction", group.getDirection());
RenderKitUtils.addToScriptHash(map, "onhide", group.getOnhide(), null, ScriptHashVariableWrapper.eventHandler);
RenderKitUtils.addToScriptHash(map, "onshow", group.getOnshow(), null, ScriptHashVariableWrapper.eventHandler);
results.add(map);
@@ -97,5 +100,12 @@
getMenuGroups(c, list);
}
}
+ }
+
+ protected int getMinPopupWidth(FacesContext facesContext, UIComponent component) {
+ if (component instanceof AbstractDropDownMenu) {
+ ((AbstractDropDownMenu) component).getPopupWith();
+ }
+ return DEFAULT_MIN_POPUP_WIDTH;
}
}
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2010-12-02 18:06:35 UTC (rev 20317)
@@ -13,12 +13,14 @@
public static final String RENDERER_TYPE = "org.richfaces.MenuGroupRenderer";
+ public static final int DEFAULT_MIN_POPUP_WIDTH = 250;
+
@Override
public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
}
- protected boolean isDisabled(UIComponent component) {
+ protected boolean isDisabled(FacesContext facesContext, UIComponent component) {
if (component instanceof AbstractMenuGroup) {
return ((AbstractMenuGroup) component).isDisabled();
}
@@ -36,7 +38,7 @@
}
}
- protected UIComponent getIconFacet(UIComponent component) {
+ protected UIComponent getIconFacet(FacesContext facesContext, UIComponent component) {
UIComponent facet = null;
AbstractMenuGroup menuGroup = (AbstractMenuGroup) component;
if (menuGroup != null) {
@@ -50,7 +52,7 @@
return facet;
}
- protected String getIconAttribute(UIComponent component) {
+ protected String getIconAttribute(FacesContext facesContext, UIComponent component) {
String icon = null;
AbstractMenuGroup menuGroup = (AbstractMenuGroup) component;
if (menuGroup != null) {
@@ -64,8 +66,8 @@
return icon;
}
- protected String getStyleClass(UIComponent component, String styleDDMenu, String styleMenuGroup) {
- UIComponent ddMenu = getDDMenu(component);
+ protected String getStyleClass(FacesContext facesContext, UIComponent component, String styleDDMenu, String styleMenuGroup) {
+ UIComponent ddMenu = getDDMenu(facesContext, component);
String styleClass = "";
if (ddMenu != null) {
if (ddMenu.getAttributes().get(styleDDMenu) != null) {
@@ -76,7 +78,7 @@
return concatClasses(styleClass, component.getAttributes().get(styleMenuGroup));
}
- protected UIComponent getDDMenu(UIComponent component) {
+ protected UIComponent getDDMenu(FacesContext facesContext, UIComponent component) {
UIComponent parent = component.getParent();
while (parent != null) {
if (parent instanceof AbstractDropDownMenu) {
@@ -86,4 +88,12 @@
}
return null;
}
+
+ protected int getMinPopupWidth(FacesContext facesContext, UIComponent component) {
+ UIComponent parent = getDDMenu(facesContext, component);
+ if (parent != null) {
+ return ((AbstractDropDownMenu) parent).getPopupWith();
+ }
+ return DEFAULT_MIN_POPUP_WIDTH;
+ }
}
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2010-12-02 18:06:35 UTC (rev 20317)
@@ -1,8 +1,13 @@
package org.richfaces.renderkit.html;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.javascript.JSFunction;
import org.richfaces.component.AbstractDropDownMenu;
import org.richfaces.component.AbstractMenuGroup;
import org.richfaces.component.AbstractMenuItem;
@@ -13,14 +18,14 @@
public static final String RENDERER_TYPE = "org.richfaces.MenuItemRenderer";
- protected boolean isDisabled(UIComponent component) {
+ protected boolean isDisabled(FacesContext facesContext, UIComponent component) {
if (component instanceof AbstractMenuItem) {
return ((AbstractMenuItem) component).isDisabled();
}
return false;
}
- protected UIComponent getIconFacet(UIComponent component) {
+ protected UIComponent getIconFacet(FacesContext facesContext, UIComponent component) {
UIComponent facet = null;
AbstractMenuItem menuItem = (AbstractMenuItem) component;
if (menuItem != null) {
@@ -34,7 +39,7 @@
return facet;
}
- protected String getIconAttribute(UIComponent component) {
+ protected String getIconAttribute(FacesContext facesContext, UIComponent component) {
String icon = null;
AbstractMenuItem menuItem = (AbstractMenuItem) component;
if (menuItem != null) {
@@ -60,13 +65,42 @@
}
}
- protected String getOnClickFunction(UIComponent component) {
+ private UIComponent getUIForm(UIComponent component) {
+ if (component != null) {
+ UIComponent parent = component.getParent();
+ while (parent != null) {
+ if (parent instanceof UIForm) {
+ return parent;
+ }
+ parent = parent.getParent();
+ }
+ }
+ return null;
+ }
+
+ private String getServerSubmitFunction(UIComponent component) {
+ UIComponent form = getUIForm(component);
+ if (component != null && form != null) {
+ Map<String, Object> param = new HashMap<String, Object>();
+ param.put(component.getClientId(), component.getClientId());
+
+ JSFunction submitFunction = new JSFunction("RichFaces.submitForm");
+ submitFunction.addParameter(form.getClientId());
+ submitFunction.addParameter(param);
+
+ return submitFunction.toScript();
+ }
+
+ return "";
+ }
+
+ protected String getOnClickFunction(FacesContext facesContext, UIComponent component) {
AbstractMenuItem menuItem = (AbstractMenuItem) component;
String subminMode = resolveSubmitMode(menuItem);
if (subminMode == null || MenuComponent.MODE_SERVER.equalsIgnoreCase(subminMode)) {
- return "submit()";
+ return getServerSubmitFunction(menuItem);
} else if (MenuComponent.MODE_AJAX.equalsIgnoreCase(subminMode)) {
- return getOnClick(FacesContext.getCurrentInstance(), menuItem);
+ return getOnClick(facesContext, menuItem);
} else if (menuItem.isDisabled()) {
return "";
} else if (MenuComponent.MODE_CLIENT.equalsIgnoreCase(subminMode)) {
@@ -92,9 +126,9 @@
return MenuComponent.MODE_SERVER;
}
- protected String getStyleClass(UIComponent component, String ddMenuStyle, String menuGroupStyle, String menuItemStyle) {
- UIComponent ddMenu = getDDMenu(component);
- UIComponent menuGroup = getMenuGroup(component);
+ protected String getStyleClass(FacesContext facesContext, UIComponent component, String ddMenuStyle, String menuGroupStyle, String menuItemStyle) {
+ UIComponent ddMenu = getDDMenu(facesContext, component);
+ UIComponent menuGroup = getMenuGroup(facesContext, component);
Object styleClass = null;
if (ddMenu != null && ddMenuStyle != null && ddMenuStyle.length() > 0) {
styleClass = ddMenu.getAttributes().get(ddMenuStyle);
@@ -106,7 +140,13 @@
return concatClasses(styleClass, component.getAttributes().get(menuItemStyle));
}
- protected UIComponent getDDMenu(UIComponent component) {
+ /**
+ * Returns a parent <code>AbstractDropDownMenu</code> object of the given component.
+ * @param facesContext
+ * @param component
+ * @return <code>UIComponent</code>
+ */
+ protected UIComponent getDDMenu(FacesContext facesContext, UIComponent component) {
UIComponent parent = component.getParent();
while (parent != null) {
if (parent instanceof AbstractDropDownMenu) {
@@ -117,7 +157,13 @@
return null;
}
- protected UIComponent getMenuGroup(UIComponent component) {
+ /**
+ * Returns a parent <code>AbstractMenuGroup</code> object of the given component.
+ * @param facesContext
+ * @param component
+ * @return <code>UIComponent</code>
+ */
+ protected UIComponent getMenuGroup(FacesContext facesContext, UIComponent component) {
UIComponent parent = component.getParent();
while (parent != null) {
if (parent instanceof AbstractMenuGroup) {
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/dropdownmenu.template.xml
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/dropdownmenu.template.xml 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/dropdownmenu.template.xml 2010-12-02 18:06:35 UTC (rev 20317)
@@ -18,8 +18,8 @@
<cdk:object name="style" value="#{component.attributes['style']}" />
<cdk:object name="styleClass" value="#{not empty component.attributes['styleClass'] ? component.attributes['styleClass']:''}" />
- <cdk:object name="label" value="#{getLabelFacet(component)}" type="javax.faces.component.UIComponent" />
- <cdk:object name="isDisabled" type="boolean" value="#{isDisabled(component)}" />
+ <cdk:object name="label" value="#{getLabelFacet(facesContext, component)}" type="javax.faces.component.UIComponent" />
+ <cdk:object name="isDisabled" type="boolean" value="#{isDisabled(facesContext, component)}" />
<div id="#{clientId}" class="rf-ddm-lbl #{isDisabled ? 'rf-ddm-lbl-dis' : 'rf-ddm-lbl-unsel '+styleClass} " style="#{style}"
cdk:passThroughWithExclusions="">
@@ -39,7 +39,7 @@
</div>
<div class="rf-ddm-pos">
- <div id="#{clientId}_list" class="rf-ddm-lst" style="display:none;">
+ <div id="#{clientId}_list" class="rf-ddm-lst" style="display:none;min-width:#{getMinPopupWidth(facesContext, component)}px;">
<div class="rf-ddm-lst-bg">
<cdk:body />
</div>
@@ -47,11 +47,11 @@
</div>
<script type="text/javascript">
<cdk:scriptObject name="options">
- <cdk:scriptOption attributes="hideDelay showDelay" />
- <cdk:scriptOption attributes="onshow onhide ongroupshow ongrouphide" wrapper="eventHandler"/>
+ <cdk:scriptOption attributes="hideDelay showDelay popupWith jointPoint direction mode" />
+ <cdk:scriptOption attributes="onshow onhide ongroupshow ongrouphide onitemclick" wrapper="eventHandler"/>
</cdk:scriptObject>
- new RichFaces.ui.Menu("#{clientId}",#{toScriptArgs(options)}).initiateGroups(#{toScriptArgs(getMenuGroups(facesContext, component))});
+ new RichFaces.ui.Menu(#{toScriptArgs(clientId, options)}).initiateGroups(#{toScriptArgs(getMenuGroups(facesContext, component))});
</script>
</div>
</cc:implementation>
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menugroup.template.xml
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menugroup.template.xml 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menugroup.template.xml 2010-12-02 18:06:35 UTC (rev 20317)
@@ -18,13 +18,13 @@
<cdk:object name="style" value="#{component.attributes['style']}" />
<cdk:object name="iconClass" value="#{component.attributes['iconClass']}" />
<cdk:object name="labelClass" value="#{component.attributes['labelClass']}" />
- <cdk:object name="styleClass" type="java.lang.String" value="#{getStyleClass(component, 'groupClass', 'styleClass')}" />
- <cdk:object name="selectedClass" type="java.lang.String" value="#{getStyleClass(component, 'selectedGroupClass', 'selectedClass')}" />
- <cdk:object name="disabledClass" type="java.lang.String" value="#{getStyleClass(component, 'disabledGroupClass', 'disabledClass')}" />
+ <cdk:object name="styleClass" type="java.lang.String" value="#{getStyleClass(facesContext, component, 'groupClass', 'styleClass')}" />
+ <cdk:object name="selectedClass" type="java.lang.String" value="#{getStyleClass(facesContext, component, 'selectedGroupClass', 'selectedClass')}" />
+ <cdk:object name="disabledClass" type="java.lang.String" value="#{getStyleClass(facesContext, component, 'disabledGroupClass', 'disabledClass')}" />
- <cdk:object name="isDisabled" type="boolean" value="#{isDisabled(component)}" />
- <cdk:object name="iconFacet" value="#{getIconFacet(component)}" type="javax.faces.component.UIComponent" />
- <cdk:object name="iconAttribute" value="#{getIconAttribute(component)}" type="java.lang.String" />
+ <cdk:object name="isDisabled" type="boolean" value="#{isDisabled(facesContext, component)}" />
+ <cdk:object name="iconFacet" value="#{getIconFacet(facesContext, component)}" type="javax.faces.component.UIComponent" />
+ <cdk:object name="iconAttribute" value="#{getIconAttribute(facesContext, component)}" type="java.lang.String" />
<cdk:object name="onmouseover" type="java.lang.String" value="this.className='rf-ddm-itm rf-ddm-itm-sel #{selectedClass}'" />
<cdk:object name="onmouseout" type="java.lang.String" value="this.className='rf-ddm-itm rf-ddm-itm-unsel'" />
@@ -59,7 +59,7 @@
<div class="rf-ddm-nd">
<c:choose>
<c:when test="#{not isDisabled}">
- <div id="#{clientId}_list" class="rf-ddm-lst rf-ddm-sublst" style="display:none;">
+ <div id="#{clientId}_list" class="rf-ddm-lst rf-ddm-sublst" style="display:none;min-width:#{getMinPopupWidth(facesContext, component)}px;">
<div class="rf-ddm-lst-bg">
<cdk:call expression="renderChildren(facesContext, component)" />
</div>
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menuitem.template.xml
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menuitem.template.xml 2010-12-02 18:04:58 UTC (rev 20316)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menuitem.template.xml 2010-12-02 18:06:35 UTC (rev 20317)
@@ -12,27 +12,31 @@
<cdk:component-family>org.richfaces.DropDownMenu</cdk:component-family>
<cdk:renderer-type>org.richfaces.MenuItemRenderer</cdk:renderer-type>
<cdk:renders-children>true</cdk:renders-children>
+
+ <cdk:resource-dependency name="dropdownmenu.ecss" library="org.richfaces" />
+ <cdk:resource-dependency name="ajax.reslib" library="org.richfaces" />
+ <cdk:resource-dependency name="base-component.reslib" library="org.richfaces" />
</cc:interface>
<cc:implementation>
<cdk:object name="style" value="#{component.attributes['style']}" />
- <cdk:object name="iconClass" type="java.lang.String" value="#{getStyleClass(component, '', 'iconClass', 'iconClass')}" />
- <cdk:object name="labelClass" type="java.lang.String" value="#{getStyleClass(component, '', 'labelClass', 'labelClass')}" />
- <cdk:object name="styleClass" type="java.lang.String" value="#{getStyleClass(component, 'itemClass', 'styleClass', 'styleClass')}" />
- <cdk:object name="selectedClass" type="java.lang.String" value="#{getStyleClass(component, 'selectedItemClass', 'selectedClass', 'selectedClass')}" />
- <cdk:object name="disabledClass" type="java.lang.String" value="#{getStyleClass(component, 'disabledItemClass', 'disabledClass', 'disabledClass')}" />
+ <cdk:object name="iconClass" type="java.lang.String" value="#{getStyleClass(facesContext, component, '', 'iconClass', 'iconClass')}" />
+ <cdk:object name="labelClass" type="java.lang.String" value="#{getStyleClass(facesContext, component, '', 'labelClass', 'labelClass')}" />
+ <cdk:object name="styleClass" type="java.lang.String" value="#{getStyleClass(facesContext, component, 'itemClass', 'styleClass', 'styleClass')}" />
+ <cdk:object name="selectedClass" type="java.lang.String" value="#{getStyleClass(facesContext, component, 'selectedItemClass', 'selectedClass', 'selectedClass')}" />
+ <cdk:object name="disabledClass" type="java.lang.String" value="#{getStyleClass(facesContext, component, 'disabledItemClass', 'disabledClass', 'disabledClass')}" />
- <cdk:object name="isDisabled" type="boolean" value="#{isDisabled(component)}" />
+ <cdk:object name="isDisabled" type="boolean" value="#{isDisabled(facesContext, component)}" />
<cdk:object name="onmouseover" type="java.lang.String" value="this.className='rf-ddm-itm rf-ddm-itm-sel #{selectedClass}'" />
<cdk:object name="onmouseout" type="java.lang.String" value="this.className='rf-ddm-itm rf-ddm-itm-unsel #{styleClass}'" />
- <cdk:object name="iconFacet" value="#{getIconFacet(component)}" type="javax.faces.component.UIComponent" />
- <cdk:object name="iconAttribute" value="#{getIconAttribute(component)}" type="java.lang.String" />
+ <cdk:object name="iconFacet" value="#{getIconFacet(facesContext, component)}" type="javax.faces.component.UIComponent" />
+ <cdk:object name="iconAttribute" value="#{getIconAttribute(facesContext, component)}" type="java.lang.String" />
<div id="#{clientId}" class="rf-ddm-itm #{isDisabled ? 'rf-ddm-itm-dis '+disabledClass : 'rf-ddm-itm-unsel '+styleClass}" style="#{style}"
onmouseover="#{isDisabled ? '' : onmouseover}"
onmouseout="#{isDisabled ? '' : onmouseout}"
- onclick="#{getOnClickFunction(component)}"
+ onclick="#{getOnClickFunction(facesContext, component)}"
cdk:passThroughWithExclusions="">
<span class="rf-ddm-itm-ic #{iconClass}">
<c:choose>
13 years, 6 months
JBoss Rich Faces SVN: r20316 - in management/design-4x/panelMenu: images and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-02 13:04:58 -0500 (Thu, 02 Dec 2010)
New Revision: 20316
Added:
management/design-4x/panelMenu/images/
management/design-4x/panelMenu/images/gr.png
management/design-4x/panelMenu/images/group_icon.gif
management/design-4x/panelMenu/images/item_icon.gif
management/design-4x/panelMenu/images/spacer.gif
management/design-4x/panelMenu/images/tgl_down.gif
management/design-4x/panelMenu/images/tgl_up.gif
management/design-4x/panelMenu/panelMenu_new.html
Log:
Panel menu markup committed
Added: management/design-4x/panelMenu/images/gr.png
===================================================================
(Binary files differ)
Property changes on: management/design-4x/panelMenu/images/gr.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: management/design-4x/panelMenu/images/group_icon.gif
===================================================================
(Binary files differ)
Property changes on: management/design-4x/panelMenu/images/group_icon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: management/design-4x/panelMenu/images/item_icon.gif
===================================================================
(Binary files differ)
Property changes on: management/design-4x/panelMenu/images/item_icon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: management/design-4x/panelMenu/images/spacer.gif
===================================================================
(Binary files differ)
Property changes on: management/design-4x/panelMenu/images/spacer.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: management/design-4x/panelMenu/images/tgl_down.gif
===================================================================
(Binary files differ)
Property changes on: management/design-4x/panelMenu/images/tgl_down.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: management/design-4x/panelMenu/images/tgl_up.gif
===================================================================
(Binary files differ)
Property changes on: management/design-4x/panelMenu/images/tgl_up.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: management/design-4x/panelMenu/panelMenu_new.html
===================================================================
--- management/design-4x/panelMenu/panelMenu_new.html (rev 0)
+++ management/design-4x/panelMenu/panelMenu_new.html 2010-12-02 18:04:58 UTC (rev 20316)
@@ -0,0 +1,212 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <title>PanelMenu</title>
+
+ <style type="text/css">
+ body{
+ font:normal 11px Verdana, sans-serif;
+ margin:30px;
+ }
+
+ /*--- RF PanelMenu styles ---*/
+ .rf-pm {
+ overflow:hidden;
+ width:200px;
+ }
+ .rf-pm-top-gr{
+ border:1px solid #BED6F8;/*panelBorderColor*/
+ margin-bottom:3px;
+ padding:1px;
+ }
+ .rf-pm-top-gr-hdr{
+ background:#BED6F8 url("images/gr.png") left top repeat-x;/*from headerGradientColor (top) to headerBackgroundColor (bottom), background-color - headerBackgroundColor*/
+ color:#000000;/*headerTextColor*/
+ cursor:pointer;
+ font-family:Arial,Verdana,sans-serif;/*headerFamilyFont*/
+ font-size:11px;/*headerSizeFont*/
+ font-weight:bold;
+ padding:2px;
+ position:relative;
+ }
+ .rf-pm-top-gr-ic{
+ display:inline-block;
+ white-space:nowrap;
+ }
+ .rf-pm-top-gr-ic img{
+ vertical-align:middle;
+ }
+ .rf-pm-top-gr-lbl{
+ display:inline-block;
+ vertical-align:middle;
+ white-space:nowrap;
+ }
+ .rf-pm-top-gr-tgl{
+ display:inline-block;
+ position:absolute;
+ right:2px;
+ top:2px;
+ white-space:nowrap;
+ }
+ .rf-pm-itm {
+ border-top:1px solid #BED6F8;/*panelBorderColor*/
+ color:#000000;
+ cursor:pointer;
+ font-family:Arial,Verdana,sans-serif;/*generalFamilyFont*/
+ font-size:11px;/*generalSizeFont*/
+ margin-top:1px;
+ padding:2px 0 2px 15px;
+ position:relative;
+ }
+ .rf-pm-itm-ic{
+ display:inline-block;
+ white-space:nowrap;
+ }
+ .rf-pm-itm-ic img{
+ vertical-align:middle;
+ }
+ .rf-pm-itm-lbl{
+ display:inline-block;
+ vertical-align:middle;
+ white-space:nowrap;
+ }
+ .rf-pm-itm-tgl{
+ vertical-align:middle;
+ position:absolute;
+ right:2px;
+ top:2px;
+ }
+ .rf-pm-gr{
+ border-top:1px solid #BED6F8;/*panelBorderColor*/
+ }
+ .rf-pm-gr-hdr{
+ color:#000000;
+ cursor:pointer;
+ font-family:Arial,Verdana,sans-serif;/*generalFamilyFont*/
+ font-size:11px;/*generalSizeFont*/
+ font-weight:bold;
+ padding:2px 0 2px 15px;
+ }
+ .rf-pm-gr-ic{
+ white-space:nowrap;
+ }
+ .rf-pm-gr-ic img{
+ vertical-align:middle;
+ }
+ .rf-pm-gr-lbl{
+ vertical-align:middle;
+ white-space:nowrap;
+ }
+ .rf-pm-hov-el{
+ background:#ECF4FE;/*additionalBackgroundColor*/
+ }
+ .rf-pm-sel-el {
+ font-style:italic;
+ }
+ .rf-pm-dis-el {
+ color:#8DB7F3;/*tabDisabledTextColor*/
+ cursor:default;
+ }
+
+ /* Indent for subgroup's items */
+ .rf-pm-gr .rf-pm-itm{
+ padding-left:30px;
+ }
+ </style>
+</head>
+<body>
+ <h1>PanelMenu</h1>
+
+ <div class="rf-pm">
+ <div class="rf-pm-top-gr">
+ <div class="rf-pm-top-gr-hdr">
+ <span class="rf-pm-top-gr-ic"><img width="18" height="18" alt="Menu group icon" src="images/spacer.gif"/></span>
+ <span class="rf-pm-top-gr-lbl">Group 1</span>
+ <span class="rf-pm-top-gr-tgl"><img width="16" height="16" alt="Menu group icon" src="images/tgl_up.gif"></span>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic"><img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/></span>
+ <span class="rf-pm-itm-lbl">Item 1.1</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic"><img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/></span>
+ <span class="rf-pm-itm-lbl">Item 1.2</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ <div class="rf-pm-itm rf-pm-dis-el" onmouseover="this.className='rf-pm-itm rf-pm-dis-el rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm rf-pm-dis-el'">
+ <span class="rf-pm-itm-ic"><img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/></span>
+ <span class="rf-pm-itm-lbl">Item 1.3</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ </div>
+ <div class="rf-pm-top-gr">
+ <div class="rf-pm-top-gr-hdr">
+ <span class="rf-pm-top-gr-ic"><img width="18" height="18" alt="Menu group icon" src="images/spacer.gif"/></span>
+ <span class="rf-pm-top-gr-lbl">Group 2</span>
+ <span class="rf-pm-top-gr-tgl"><img width="16" height="16" alt="Menu group icon" src="images/tgl_up.gif"/></span>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic"><img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/></span>
+ <span class="rf-pm-itm-lbl">Item 2.1</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic"><img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/></span>
+ <span class="rf-pm-itm-lbl">Item 2.2</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic"><img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/></span>
+ <span class="rf-pm-itm-lbl">Item 2.3</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ <div class="rf-pm-gr">
+ <div class="rf-pm-gr-hdr" onmouseover="this.className='rf-pm-gr-hdr rf-pm-hov-el'" onmouseout="this.className='rf-pm-gr-hdr'" onclick="this.className='rf-pm-gr-hdr rf-pm-sel-el'">
+ <span class="rf-pm-gr-ic"><img width="16" height="16" alt="Menu group icon" src="images/group_icon.gif"/></span>
+ <span class="rf-pm-gr-lbl">Group 2.4</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu group icon" src="images/spacer.gif"/></span>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic">
+ <img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/>
+ </span>
+ <span class="rf-pm-itm-lbl">Item 2.4.1</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic">
+ <img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/>
+ </span>
+ <span class="rf-pm-itm-lbl">Item 2.4.2</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic">
+ <img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/>
+ </span>
+ <span class="rf-pm-itm-lbl">Item 2.4.3</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ </div>
+ <div class="rf-pm-itm" onmouseover="this.className='rf-pm-itm rf-pm-hov-el'" onmouseout="this.className='rf-pm-itm'" onclick="this.className='rf-pm-itm rf-pm-sel-el'">
+ <span class="rf-pm-itm-ic"><img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/></span>
+ <span class="rf-pm-itm-lbl">Item 2.5</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ </div>
+ <div class="rf-pm-top-gr">
+ <div class="rf-pm-top-gr-hdr">
+ <span class="rf-pm-top-gr-ic"><img width="18" height="18" alt="Menu group icon" src="images/spacer.gif"/></span>
+ <span class="rf-pm-top-gr-lbl">Group 3</span>
+ <span class="rf-pm-top-gr-tgl"><img width="16" height="16" alt="Menu group icon" src="images/tgl_down.gif"/></span>
+ </div>
+ <div class="rf-pm-itm" style="display: none;">
+ <span class="rf-pm-itm-ic"><img width="16" height="16" alt="Menu item icon" src="images/item_icon.gif"/></span>
+ <span class="rf-pm-itm-lbl">Item 3.1</span>
+ <span class="rf-pm-itm-tgl"><img width="16" height="16" alt="Menu item icon" src="images/spacer.gif"/></span>
+ </div>
+ </div>
+ </div>
+</body>
+</html>
\ No newline at end of file
13 years, 6 months
JBoss Rich Faces SVN: r20315 - trunk/ui/core/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-12-02 12:52:54 -0500 (Thu, 02 Dec 2010)
New Revision: 20315
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
Log:
@ResourceDependencies was added to wrap @ResourceDependency
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-12-02 17:08:19 UTC (rev 20314)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-12-02 17:52:54 UTC (rev 20315)
@@ -25,6 +25,7 @@
import java.util.Map;
+import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -39,7 +40,9 @@
* @version $Revision: 1.1.2.3 $ $Date: 2007/02/12 17:46:53 $
*
*/
-@ResourceDependency(library = "org.richfaces", name = "ajax.reslib")
+@ResourceDependencies({
+ @ResourceDependency(library = "org.richfaces", name = "ajax.reslib")
+})
public abstract class AjaxCommandRendererBase extends RendererBase {
private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
13 years, 6 months
JBoss Rich Faces SVN: r20314 - in sandbox/trunk/ui/dropdown-menu/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-12-02 12:08:19 -0500 (Thu, 02 Dec 2010)
New Revision: 20314
Modified:
sandbox/trunk/ui/dropdown-menu/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js
sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menugroup.template.xml
Log:
drop-down menu client-code + markup update
https://jira.jboss.org/browse/RF-9785
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js 2010-12-02 16:33:17 UTC (rev 20313)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/resources/META-INF/resources/org.richfaces/menu.js 2010-12-02 17:08:19 UTC (rev 20314)
@@ -23,7 +23,6 @@
unselectItemCss: "rf-ddm-itm-unsel",
disabledItemCss: "rf-ddm-itm-dis",
listCss: "rf-ddm-lst"
-
};
//constructor definition
@@ -45,19 +44,22 @@
//menu items list
//this.target = 'dd_menu_id_label_container';
//popup for item menu list
- var base = rf.getDomElement(this.id);
- this.popup = $(rf.getDomElement(this.id + "_list"));
+ //var base = rf.getDomElement(this.id);
+
+ this.displayed = false;
+
+ //this.popup = $(rf.getDomElement(this.id + "_list"));
//this.initiatePopup(this.popup, base, this.options.showEvent);
//this.initiateMenu(this.popup, base, this.options.showEvent);
this.options.attachTo = this.id;
this.popupList = new RichFaces.ui.PopupList(this.id + "_list", this, this.options);
this.selectedGroup = null;
- rf.Event.bindById(this.id, this.options.showEvent, $.proxy(this.showPopup, this), this);
- rf.Event.bindById(this.id, 'mouseenter', $.proxy(this.__enterHandler, this), this);
+ rf.Event.bindById(this.id, this.options.showEvent, $.proxy(this.___showHandler, this), this);
+ //rf.Event.bindById(this.id, 'mouseenter', $.proxy(this.__enterHandler, this), this);
rf.Event.bindById(this.id, "mouseleave", $.proxy(this.__leaveHandler, this), this);
- rf.Event.bindById(this.id, "mouseover", $.proxy(this.__overHandler, this), this);
- rf.Event.bindById(this.id, "blur", $.proxy(this.__blurHandler, this), this);
- rf.Event.bindById(this.id, "focus", $.proxy(this.__focusHandler, this), this);
+ //rf.Event.bindById(this.id, "mouseover", $.proxy(this.__overHandler, this), this);
+ //rf.Event.bindById(this.id, "blur", $.proxy(this.__blurHandler, this), this);
+ // rf.Event.bindById(this.id, "focus", $.proxy(this.__focusHandler, this), this);
//this.popupList.show();
};
@@ -91,7 +93,7 @@
var id = event.target.id;
if (menu.groupList[id]) {
menu.invokeEvent("groupshow", rf.getDomElement(menu.id), null);
- menu.invokeEvent("show", rf.getDomElement(id), null);
+ //menu.invokeEvent("show", rf.getDomElement(id), null);
menu.groupList[id].popup.show();
}
},
@@ -100,8 +102,8 @@
function(event) {
var id = event.target.id;
if (menu.groupList[id]) {
- //this.invokeEvent("grouphide", rf.getDomElement(menu.id), null);
- menu.invokeEvent("hide", rf.getDomElement(id), null);
+ menu.invokeEvent("grouphide", rf.getDomElement(menu.id), null);
+ //menu.invokeEvent("hide", rf.getDomElement(id), null);
menu.groupList[id].popup.hide();
}
});
@@ -122,31 +124,35 @@
},
processItem: function(item) {
- if (item && !this.isDisabled(item) && item.attr('id').search('group') == -1) {
+ if (item && item.atrr('id') && !this.isDisabled(item) && this.isGroup(item)) {
+ this.invokeEvent("itemclick", rf.getDomElement(this.id), null);
this.hidePopup();
- this.submitForm(item);
+ //this.submitForm(item);
}
},
selectItem: function(item) {
- if(item.attr('id') && !this.isDisabled(item)){
- item.addClass(this.selectItemCss);
- if(item.attr('id').search('group') != -1){
- this.selectedGroup=item.attr('id');
- } else {
- this.selectedGroup = null;
- }
- }
+// if(item.attr('id') && !this.isDisabled(item)){
+// item.addClass(this.selectItemCss);
+// if(item.attr('id').search('group') != -1){
+// this.selectedGroup=item.attr('id');
+// } else {
+// this.selectedGroup = null;
+// }
+// }
},
unselectItem: function(item) {
- var nextItem = this.popupList.nextSelectItem();
- if (item.attr('id') && (nextItem.attr('id') != this.selectedGroup) && !this.isWithin(nextItem) ){
- item.removeClass(this.selectItemCss);
- item.addClass(this.unselectItemCss);
- }
+// var nextItem = this.popupList.nextSelectItem();
+// if (item.attr('id') && (nextItem.attr('id') != this.selectedGroup) && !this.isWithin(nextItem) ){
+// item.removeClass(this.selectItemCss);
+// item.addClass(this.unselectItemCss);
+// }
},
- isDisabled: function(item){
+ isGroup: function(item) {
+ return 'object' == typeof this.groupList[item.atrr('id')];
+ },
+ isDisabled: function(item) {
return item.hasClass(this.options.disabledItemCss);
},
isWithin: function(item){
@@ -158,17 +164,28 @@
},
showPopup: function() {
- this.invokeEvent("show", rf.getDomElement(this.id), null);
- this.popupList.show();
+ if (!this.___isShown()){
+ this.invokeEvent("show", rf.getDomElement(this.id), null);
+ this.popupList.show();
+ this.displayed=true;
+ }
},
hidePopup: function() {
for (var i in this.groupList) {
this.groupList[i].popup.hide();
}
- this.invokeEvent("hide", rf.getDomElement(this.id), null);
+ if (this.___isShown()){
+ this.invokeEvent("hide", rf.getDomElement(this.id), null);
+ this.popupList.hide();
+ this.displayed=false;
+ }
this.popupList.hide();
},
+ ___isShown: function() {
+ return this.displayed;
+
+ },
___showHandler: function() {
this.showTimeoutId = window.setTimeout($.proxy(function(){
this.showPopup();
@@ -181,6 +198,7 @@
// this.showPopup();
},
__leaveHandler: function(e) {
+ window.clearTimeout(this.showTimeoutId);
this.hideTimeoutId = window.setTimeout($.proxy(function(){
this.hidePopup();
}, this), this.options.hideDelay);
Modified: sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menugroup.template.xml
===================================================================
--- sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menugroup.template.xml 2010-12-02 16:33:17 UTC (rev 20313)
+++ sandbox/trunk/ui/dropdown-menu/ui/src/main/templates/menugroup.template.xml 2010-12-02 17:08:19 UTC (rev 20314)
@@ -29,7 +29,7 @@
<cdk:object name="onmouseover" type="java.lang.String" value="this.className='rf-ddm-itm rf-ddm-itm-sel #{selectedClass}'" />
<cdk:object name="onmouseout" type="java.lang.String" value="this.className='rf-ddm-itm rf-ddm-itm-unsel'" />
- <div id="#{clientId}_group" class="rf-ddm-itm #{isDisabled ? 'rf-ddm-itm-dis '+disabledClass : 'rf-ddm-itm-unsel '+styleClass}" style="#{style}"
+ <div id="#{clientId}" class="rf-ddm-itm #{isDisabled ? 'rf-ddm-itm-dis '+disabledClass : 'rf-ddm-itm-unsel '+styleClass}" style="#{style}"
onmouseover="#{isDisabled ? '' : onmouseover}"
onmouseout="#{isDisabled ? '' : onmouseout}"
cdk:passThroughWithExclusions="" >
@@ -59,7 +59,7 @@
<div class="rf-ddm-nd">
<c:choose>
<c:when test="#{not isDisabled}">
- <div class="rf-ddm-lst rf-ddm-sublst" style="display:none;">
+ <div id="#{clientId}_list" class="rf-ddm-lst rf-ddm-sublst" style="display:none;">
<div class="rf-ddm-lst-bg">
<cdk:call expression="renderChildren(facesContext, component)" />
</div>
13 years, 6 months