JBoss Rich Faces SVN: r18661 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-08-16 09:28:02 -0400 (Mon, 16 Aug 2010)
New Revision: 18661
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
Log:
fix recursive calls
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss 2010-08-16 13:15:57 UTC (rev 18660)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.ecss 2010-08-16 13:28:02 UTC (rev 18661)
@@ -153,3 +153,7 @@
.rf-ii-none {
clip:rect(0px, 0px, 1px, 1px);
}
+
+.rf-ii-none {
+ clip:rect(0px 0px 1px 1px);
+}
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-08-16 13:15:57 UTC (rev 18660)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-08-16 13:28:02 UTC (rev 18661)
@@ -15,11 +15,12 @@
this.label = $(document.getElementById(options.label));
this.initialValue = this.label.text();
- richfaces.Event.bind(this.element, this.editEvent, this.edit, this);
- richfaces.Event.bind(this.input, "change", this.save, this);
- richfaces.Event.bind(this.input, "blur", this.save, this);
- richfaces.Event.bind(this.input, "focus", this.edit, this);
-
+ richfaces.Event.bind(this.element, this.editEvent, this.__editHandler, this);
+ richfaces.Event.bind(this.input, "change", this.__saveHandler, this);
+ richfaces.Event.bind(this.input, "blur", this.__saveHandler, this);
+
+ /* TODO: discuss this with Pavel */
+ this.__boundEditFunc = richfaces.Event.bind(this.input, "focus", this.__editHandler, this);
if(this.showControls) {
this.okbtn = $(document.getElementById(options.okbtn));
this.cancelbtn = $(document.getElementById(options.cancelbtn));
@@ -42,7 +43,7 @@
edit: function() {
this.editContainer.removeClass(this.noneCss);
- this.input.focus();
+ this.input.focus();
},
save: function() {
@@ -79,15 +80,27 @@
/****************** private methods *****************************************/
- __saveBtnHandler: function() {
- this.save();
+ __saveBtnHandler: function(e) {
+ this.input.blur();
this.editContainer.addClass(this.noneCss);
return false;
},
- __cancelBtnHandler: function() {
- this.cancel(); return false;
+ __cancelBtnHandler: function(e) {
+ this.cancel(); this.input.blur(); return false;
+ },
+
+ __editHandler: function(e) {
+ richfaces.Event.unbind(this.input, "focus", this.__boundEditFunc);
+ this.__boundEditFunc = null;
+ this.edit();
+ this.__boundEditFunc = richfaces.Event.bind(this.input, "focus", this.__editHandler, this);
+ },
+
+ __saveHandler: function(e) {
+ this.save();
}
+
}
})());
15 years, 9 months
JBoss Rich Faces SVN: r18660 - in trunk/ui: output/ui/src/main/resources/META-INF/resources/org.richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-08-16 09:15:57 -0400 (Mon, 16 Aug 2010)
New Revision: 18660
Added:
trunk/ui/output/ui/src/test/java/org/richfaces/component/AbstractAccordionTest.java
Modified:
trunk/ui/dist/richfaces-components-api/pom.xml
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss
Log:
skinning for accordion
Modified: trunk/ui/dist/richfaces-components-api/pom.xml
===================================================================
--- trunk/ui/dist/richfaces-components-api/pom.xml 2010-08-16 13:04:29 UTC (rev 18659)
+++ trunk/ui/dist/richfaces-components-api/pom.xml 2010-08-16 13:15:57 UTC (rev 18660)
@@ -152,7 +152,7 @@
<configuration>
<classifier>sources</classifier>
- <includeGroupIds>org.richfaces.ui.common, org.richfaces.ui.core, org.richfaces.ui.iteration, org.richfaces.ui.output</includeGroupIds>
+ <includeGroupIds>org.richfaces.ui.common, org.richfaces.ui.core, org.richfaces.ui.iteration, org.richfaces.ui.output, org.richfaces.ui.input</includeGroupIds>
<useSubDirectoryPerArtifact>true</useSubDirectoryPerArtifact>
<excludeTransitive>true</excludeTransitive>
</configuration>
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss 2010-08-16 13:04:29 UTC (rev 18659)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss 2010-08-16 13:15:57 UTC (rev 18660)
@@ -1,24 +1,33 @@
.rf-ac {
width: 300px; /*visible width*/
- border: 1px solid #{richSkin.panelBorderColor};
+ border-width: 1px;
+ border-style: solid;
+ border-color: '#{richSkin.panelBorderColor}';
border-bottom: 0px;
- background: #{richSkin.generalBackgroundColor};
+ background: '#{richSkin.generalBackgroundColor}';
}
.rf-aci-h {
- border-bottom: 1px solid #{richSkin.panelBorderColor};
- background: url(images/bg_header.png) /*from headerGradientColor to headerBackgroundColor, picture height 20px*/ repeat-x top left #{richSkin.headerBackgroundColor};
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+ border-bottom-color: '#{richSkin.panelBorderColor}';
+ background-image: "url(#{resource['org.richfaces.renderkit.html.GradientA']})";
+ background-repeat: repeat-x;
+ background-position: top left;
+ background-color: '#{richSkin.headerBackgroundColor}';
position: relative;
padding: 8px 10px 7px 10px;
- font-weight: #{richSkin.headerWeightFont};
- color: #{richSkin.headerTextColor};
- font-family: #{richSkin.headerFamilyFont};
- font-size: #{richSkin.headerSizeFont};
+ font-weight: '#{richSkin.headerWeightFont}';
+ color: '#{richSkin.headerTextColor}';
+ font-family: '#{richSkin.headerFamilyFont}';
+ font-size: '#{richSkin.headerSizeFont}';
cursor: pointer;
}
.rf-aci-c {
- border-bottom: 1px solid #{richSkin.panelBorderColor};
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+ border-bottom-color: '#{richSkin.panelBorderColor}';
height: 100px /*visible modal panel height minus header height*/;
position: relative;
overflow: auto;
Added: trunk/ui/output/ui/src/test/java/org/richfaces/component/AbstractAccordionTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/component/AbstractAccordionTest.java (rev 0)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/component/AbstractAccordionTest.java 2010-08-16 13:15:57 UTC (rev 18660)
@@ -0,0 +1,78 @@
+/*
+ * 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 org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.faces.component.UIComponent;
+import java.util.List;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-14
+ */
+public class AbstractAccordionTest {
+
+ private static final String ITEM1 = "item1";
+ private static final String ITEM2 = "item2";
+ private static final String ITEM3 = "item3";
+
+ private AbstractAccordion accordion;
+ private AbstractTogglePanelTitledItem item1;
+ private AbstractTogglePanelTitledItem item2;
+ private AbstractTogglePanelTitledItem item3;
+
+ @Before
+ public void setUp () {
+ accordion = new AbstractAccordion();
+ List<UIComponent> children = accordion.getChildren();
+
+ item1 = createItem(ITEM1);
+ children.add(item1);
+
+ item2 = createItem(ITEM2);
+ children.add(item2);
+
+ item3 = createItem(ITEM3);
+ children.add(item3);
+ }
+
+ @Test
+ public void testDefaultActiveItem() {
+ Assert.assertNotNull(accordion);
+ Assert.assertEquals(ITEM1, accordion.getActiveItem());
+
+ accordion.setActiveItem(ITEM2);
+ Assert.assertEquals(ITEM2, accordion.getActiveItem());
+ }
+
+ private static AbstractTogglePanelTitledItem createItem(String name) {
+ AbstractTogglePanelTitledItem item = new UITogglePanelTitledItem();
+ item.setName(name);
+
+ return item;
+ }
+}
+
15 years, 9 months
JBoss Rich Faces SVN: r18659 - sandbox/trunk/examples/components.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-16 09:04:29 -0400 (Mon, 16 Aug 2010)
New Revision: 18659
Removed:
sandbox/trunk/examples/components/combobox-demo/
Modified:
sandbox/trunk/examples/components/pom.xml
Log:
AutoComplete moving to main area
Modified: sandbox/trunk/examples/components/pom.xml
===================================================================
--- sandbox/trunk/examples/components/pom.xml 2010-08-16 13:03:43 UTC (rev 18658)
+++ sandbox/trunk/examples/components/pom.xml 2010-08-16 13:04:29 UTC (rev 18659)
@@ -16,7 +16,6 @@
<name>Richfaces Examples Sandbox: Component Demos Aggregator</name>
<modules>
- <module>combobox-demo</module>
</modules>
<dependencies>
15 years, 9 months
JBoss Rich Faces SVN: r18658 - sandbox/trunk/ui/inputs.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-16 09:03:43 -0400 (Mon, 16 Aug 2010)
New Revision: 18658
Removed:
sandbox/trunk/ui/inputs/combobox/
Modified:
sandbox/trunk/ui/inputs/pom.xml
Log:
AutoComplete moving to main area
Modified: sandbox/trunk/ui/inputs/pom.xml
===================================================================
--- sandbox/trunk/ui/inputs/pom.xml 2010-08-16 12:48:14 UTC (rev 18657)
+++ sandbox/trunk/ui/inputs/pom.xml 2010-08-16 13:03:43 UTC (rev 18658)
@@ -36,7 +36,6 @@
<modules>
<module>parent</module>
- <module>combobox</module>
</modules>
<scm>
15 years, 9 months
JBoss Rich Faces SVN: r18657 - in trunk/examples/input-demo/src/main: java/org/richfaces/demo and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-16 08:48:14 -0400 (Mon, 16 Aug 2010)
New Revision: 18657
Added:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CountriesBean.java
trunk/examples/input-demo/src/main/java/org/richfaces/demo/Country.java
trunk/examples/input-demo/src/main/resources/
trunk/examples/input-demo/src/main/resources/org/
trunk/examples/input-demo/src/main/webapp/autoComplete.xhtml
Modified:
trunk/examples/input-demo/src/main/webapp/index.xhtml
Log:
AutoComplete moving to main area
Copied: trunk/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java (from rev 18655, sandbox/trunk/examples/components/combobox-demo/src/main/java/org/richfaces/demo/TestBean.java)
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java (rev 0)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java 2010-08-16 12:48:14 UTC (rev 18657)
@@ -0,0 +1,75 @@
+/*
+ * 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.demo;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class AutoCompleteBean implements Serializable {
+
+ private static final long serialVersionUID = 3072125097847582809L;
+
+ private class CountryNamePredicate implements Predicate<Country> {
+
+ private String countryNamePrefix;
+
+ public CountryNamePredicate(String countryNamePrefix) {
+ super();
+ this.countryNamePrefix = countryNamePrefix;
+ }
+
+ public boolean apply(Country input) {
+ if (countryNamePrefix == null || countryNamePrefix.length() == 0) {
+ return true;
+ }
+
+ return input.getName().toLowerCase(Locale.US).startsWith(countryNamePrefix);
+ }
+ }
+
+ @ManagedProperty(value = "#{countriesBean}")
+ private CountriesBean countriesBean;
+
+ public void setCountriesBean(CountriesBean countriesBean) {
+ this.countriesBean = countriesBean;
+ }
+
+ public Object autocomplete(FacesContext facesContext, UIComponent component, String value) {
+ return Collections2.filter(countriesBean.getCountries(), new CountryNamePredicate(value));
+ }
+
+}
Copied: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CountriesBean.java (from rev 18655, sandbox/trunk/examples/components/combobox-demo/src/main/java/org/richfaces/demo/CountriesBean.java)
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/CountriesBean.java (rev 0)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/CountriesBean.java 2010-08-16 12:48:14 UTC (rev 18657)
@@ -0,0 +1,80 @@
+/*
+ * 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.demo;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.faces.FacesException;
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author nick
+ *
+ */
+@ManagedBean(eager = true)
+@ApplicationScoped
+public class CountriesBean {
+
+ private List<Country> countries;
+
+ @XmlRootElement(name = "countries", namespace = Country.NAMESPACE)
+ private static class Countries {
+
+ @XmlElement(name = "country", namespace = Country.NAMESPACE)
+ private List<Country> countries;
+
+ public List<Country> getCountries() {
+ return countries;
+ }
+ }
+
+ public CountriesBean() {
+ }
+
+ @PostConstruct
+ public void initialize() {
+ try {
+ JAXBContext countryContext = JAXBContext.newInstance(Countries.class);
+ Unmarshaller unmarshaller = countryContext.createUnmarshaller();
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ URL dataUrl = classLoader.getResource("org/richfaces/demo/countries.xml");
+
+ countries = ((Countries) unmarshaller.unmarshal(dataUrl)).getCountries();
+ } catch (JAXBException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+
+ public List<Country> getCountries() {
+ return countries;
+ }
+}
Copied: trunk/examples/input-demo/src/main/java/org/richfaces/demo/Country.java (from rev 18655, sandbox/trunk/examples/components/combobox-demo/src/main/java/org/richfaces/demo/Country.java)
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/Country.java (rev 0)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/Country.java 2010-08-16 12:48:14 UTC (rev 18657)
@@ -0,0 +1,79 @@
+/*
+ * 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.demo;
+
+import javax.xml.bind.annotation.XmlElement;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * @author nick
+ *
+ */
+public class Country {
+
+ public static final String NAMESPACE = "http://richfaces.org/demos/countries";
+
+ private String name;
+
+ private String iso;
+
+ private String domain;
+
+ @XmlElement(namespace = Country.NAMESPACE)
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIso() {
+ return iso;
+ }
+
+ @XmlElement(namespace = Country.NAMESPACE)
+ public void setIso(String iso) {
+ this.iso = iso;
+ }
+
+ public String getDomain() {
+ return domain;
+ }
+
+ @XmlElement(namespace = Country.NAMESPACE)
+ public void setDomain(String domain) {
+ this.domain = domain;
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper helper = Objects.toStringHelper(this);
+
+ helper.add("name", name).add("iso", iso).add("domain", domain);
+
+ return helper.toString();
+ }
+}
Copied: trunk/examples/input-demo/src/main/resources/org (from rev 18655, sandbox/trunk/examples/components/combobox-demo/src/main/resources/org)
Copied: trunk/examples/input-demo/src/main/webapp/autoComplete.xhtml (from rev 18655, sandbox/trunk/examples/components/combobox-demo/src/main/webapp/index.xhtml)
===================================================================
--- trunk/examples/input-demo/src/main/webapp/autoComplete.xhtml (rev 0)
+++ trunk/examples/input-demo/src/main/webapp/autoComplete.xhtml 2010-08-16 12:48:14 UTC (rev 18657)
@@ -0,0 +1,59 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:input="http://richfaces.org/input">
+<f:view contentType="text/html" />
+
+<h:head>
+ <title>Richfaces ComboBox</title>
+</h:head>
+
+<h:body style="margin: 30px;">
+
+ <h:form id="form">
+ <div style="height: 300px; width: 300px; overflow: auto;">Text
+ block text block text block text block text block text block text
+ block text block
+
+ <input:autoComplete autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country" fetchValue="#{country.name}">
+ #{country.name} #{country.iso} #{country.domain}
+ </input:autoComplete>
+
+ <br />
+ <select style="width: 200px" name="select">
+ <option>ccccc</option>
+ </select> text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block text block text block text block text
+ block text block text block
+ </div>
+ </h:form>
+</h:body>
+</html>
Modified: trunk/examples/input-demo/src/main/webapp/index.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/index.xhtml 2010-08-16 12:46:35 UTC (rev 18656)
+++ trunk/examples/input-demo/src/main/webapp/index.xhtml 2010-08-16 12:48:14 UTC (rev 18657)
@@ -10,6 +10,7 @@
<ul>
<li><h:link outcome="inplaceInput">rich:inplaceInput</h:link></li>
<li><h:link outcome="inputNumberSlider">rich:inputNumberSlider</h:link></li>
+ <li><h:link outcome="autoComplete">rich:autoComplete</h:link></li>
</ul>
<h:form>
15 years, 9 months
JBoss Rich Faces SVN: r18656 - in trunk/ui/input: ui/src/main/java/org/richfaces and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-16 08:46:35 -0400 (Mon, 16 Aug 2010)
New Revision: 18656
Added:
trunk/ui/input/api/src/main/java/org/richfaces/component/AutocompleteLayout.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutoComplete.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AbstractAutocompleteLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutoCompleteEncodeStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutoCompleteRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteBaseGradient.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteButtonGradient.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteFieldGradient.java
trunk/ui/input/ui/src/main/java/org/richfaces/view/
trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.ecss
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/combo_down_button.gif
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/combo_list_shadow.png
trunk/ui/input/ui/src/main/templates/autoComplete.template.xml
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/AutoCompleteHandler.java
Log:
AutoComplete moving to main area
Copied: trunk/ui/input/api/src/main/java/org/richfaces/component/AutocompleteLayout.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/component/AutocompleteLayout.java)
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/component/AutocompleteLayout.java (rev 0)
+++ trunk/ui/input/api/src/main/java/org/richfaces/component/AutocompleteLayout.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -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.component;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+//TODO nick - move to API
+public enum AutocompleteLayout {
+
+ table,
+ list,
+ grid,
+ //TODO nick - rename into 'simple'?
+ div
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutoComplete.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/component/AbstractAutoComplete.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutoComplete.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutoComplete.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,256 @@
+/*
+ * 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 javax.el.MethodExpression;
+import javax.el.ValueExpression;
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+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 org.ajax4jsf.util.ELUtils;
+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.cdk.annotations.TagType;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.context.ExtendedVisitContextMode;
+import org.richfaces.renderkit.MetaComponentRenderer;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@JsfComponent(tag = @Tag(type = TagType.Facelets, handler = "org.richfaces.view.facelets.AutoCompleteHandler"), renderer = @JsfRenderer(type = "org.richfaces.AutoCompleteRenderer"))
+public abstract class AbstractAutoComplete extends UIInput implements MetaComponentResolver, MetaComponentEncoder {
+
+ public static final String ITEMS_META_COMPONENT_ID = "items";
+
+ public static final String COMPONENT_TYPE = "org.richfaces.AutoComplete";
+
+ public static final String COMPONENT_FAMILY = UIInput.COMPONENT_FAMILY;
+
+ // TODO nick - change to Object - https://jira.jboss.org/browse/RF-8897
+ public abstract Object getAutocompleteList();
+
+ @Attribute(signature = @Signature(returnType = Object.class, parameters = {FacesContext.class, UIComponent.class, String.class}))
+ public abstract MethodExpression getAutocompleteMethod();
+
+ public abstract void setAutocompleteMethod(MethodExpression expression);
+
+ public abstract void setItemConverter(Converter converter);
+
+ @Attribute(literal = true)
+ public abstract String getVar();
+
+ // TODO nick - el-only?
+ @Attribute(literal = false)
+ public abstract Object getFetchValue();
+
+ @Attribute(defaultValue = "1")
+ public abstract int getMinChars();
+
+ @Attribute
+ public abstract String getFilterFunction();
+
+ @Attribute
+ public abstract String getMode();
+
+ @Attribute
+ public abstract String getLayout();
+
+ @Attribute
+ public abstract Converter getItemConverter();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isAutoFill();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isDisabled();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isShowButton();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isSelectFirst();
+
+ @Attribute(events = @EventName("click"))
+ public abstract String getOnclick();
+
+ @Attribute(events = @EventName("dblclick"))
+ public abstract String getOndblclick();
+
+ @Attribute(events = @EventName("mousedown"))
+ public abstract String getOnmousedown();
+
+ @Attribute(events = @EventName("mouseup"))
+ public abstract String getOnmouseup();
+
+ @Attribute(events = @EventName("mouseover"))
+ public abstract String getOnmouseover();
+
+ @Attribute(events = @EventName("mousemove"))
+ public abstract String getOnmousemove();
+
+ @Attribute(events = @EventName("mouseout"))
+ public abstract String getOnmouseout();
+
+ @Attribute(events = @EventName("keypress"))
+ public abstract String getOnkeypress();
+
+ @Attribute(events = @EventName("keydown"))
+ public abstract String getOnkeydown();
+
+ @Attribute(events = @EventName("keyup"))
+ public abstract String getOnkeyup();
+
+ @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("change"))
+ public abstract String getOnchange();
+
+ @Attribute(events = @EventName("blur"))
+ public abstract String getOnblur();
+
+ @Attribute(events = @EventName("focus"))
+ public abstract String getOnfocus();
+
+ @Attribute(events = @EventName("listblur"))
+ public abstract String getOnlistblur();
+
+ @Attribute(events = @EventName("listfocus"))
+ public abstract String getOnlistfocus();
+
+ @Attribute(events = @EventName("begin"))
+ public abstract String getOnbegin();
+
+ @Attribute(events = @EventName("error"))
+ public abstract String getOnerror();
+
+ @Attribute(events = @EventName("complete"))
+ public abstract String getOncomplete();
+
+ @Attribute(events = @EventName("beforedomupdate"))
+ public abstract String getOnbeforedomupdate();
+
+ @Override
+ public Converter getConverter() {
+ Converter converter = super.getConverter();
+ if (converter == null) {
+ converter = getConverterForValue(FacesContext.getCurrentInstance());
+ }
+
+ return converter;
+ }
+
+ private Converter getConverterForType(FacesContext context, Class<?> type) {
+
+ if (!Object.class.equals(type) && type != null) {
+ Application application = context.getApplication();
+ return application.createConverter(type);
+ }
+
+ return null;
+ }
+
+ public Converter getConverterForValue(FacesContext context) {
+ Converter converter = null;
+ ValueExpression expression = this.getValueExpression("value");
+
+ if (expression != null) {
+ Class<?> containerClass = ELUtils.getContainerClass(context, expression);
+
+ converter = getConverterForType(context, containerClass);
+ }
+
+ return converter;
+ }
+
+ public String resolveClientId(FacesContext facesContext, UIComponent contextComponent, String metaComponentId) {
+ if (ITEMS_META_COMPONENT_ID.equals(metaComponentId)) {
+ return getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean visitTree(VisitContext context, VisitCallback callback) {
+ if (context instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) context;
+ if (extendedVisitContext.getVisitMode() == ExtendedVisitContextMode.RENDER) {
+
+ VisitResult result = extendedVisitContext.invokeMetaComponentVisitCallback(this, callback,
+ ITEMS_META_COMPONENT_ID);
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ } else if (result == VisitResult.REJECT) {
+ return false;
+ }
+ }
+ }
+
+ return super.visitTree(context, callback);
+ }
+
+ public void encodeMetaComponent(FacesContext context, String metaComponentId) throws IOException {
+ ((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(context, this, metaComponentId);
+ }
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AbstractAutocompleteLayoutStrategy.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/AbstractAutocompleteLayoutStrategy.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AbstractAutocompleteLayoutStrategy.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AbstractAutocompleteLayoutStrategy.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,11 @@
+package org.richfaces.renderkit;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+public class AbstractAutocompleteLayoutStrategy {
+
+ public String getContainerElementId(FacesContext facesContext, UIComponent component) {
+ return component.getClientId(facesContext) + "Items";
+ }
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutoCompleteEncodeStrategy.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/AutoCompleteEncodeStrategy.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutoCompleteEncodeStrategy.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutoCompleteEncodeStrategy.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,22 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.AbstractAutoComplete;
+
+
+public interface AutoCompleteEncodeStrategy {
+ void encodeItemsContainerBegin(FacesContext facesContext, UIComponent component) throws IOException ;
+
+ void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component) throws IOException ;
+
+ void encodeFakeItem(FacesContext facesContext, UIComponent component) throws IOException ;
+
+ void encodeItem(FacesContext facesContext, AbstractAutoComplete comboBox,
+ Object nextItem) throws IOException;
+
+ public String getContainerElementId(FacesContext facesContext, UIComponent component);
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutoCompleteRendererBase.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/AutoCompleteRendererBase.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutoCompleteRendererBase.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutoCompleteRendererBase.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,261 @@
+/*
+ * 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 java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
+import javax.faces.context.PartialViewContext;
+import javax.faces.model.ArrayDataModel;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.model.ResultDataModel;
+import javax.faces.model.ResultSetDataModel;
+import javax.servlet.jsp.jstl.sql.Result;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.util.InputUtils;
+import org.richfaces.component.AbstractAutoComplete;
+import org.richfaces.component.AutocompleteLayout;
+import org.richfaces.component.MetaComponentResolver;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterators;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "jquery.position.js"),
+ @ResourceDependency(name = "richfaces.js"), @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"), @ResourceDependency(name = "richfaces-selection.js"),
+ @ResourceDependency(library = "org.richfaces", name = "AutoCompleteBase.js"),
+ @ResourceDependency(library = "org.richfaces", name = "AutoComplete.js"),
+ @ResourceDependency(library = "org.richfaces", name = "AutoComplete.ecss")
+
+})
+public abstract class AutoCompleteRendererBase extends InputRendererBase implements MetaComponentRenderer {
+
+ public String getScriptOptions(UIComponent component) {
+ Map<String, Object> attributes = component.getAttributes();
+ Map<String, Object> options = new HashMap<String, Object>();
+ RendererUtils utils = getUtils();
+ utils.addToScriptHash(options, "buttonId", component.getClientId() + "Button");
+ utils.addToScriptHash(options, "selectedItemClass", "cb_select");
+ utils.addToScriptHash(options, "minChars", attributes.get("minChars"), "1");
+ utils.addToScriptHash(options, "mode", attributes.get("mode"), "ajax");
+ utils.addToScriptHash(options, "filterFunction", attributes.get("filterFunction"));
+ utils.addToScriptHash(options, "autoFill", attributes.get("autoFill"), "false");
+ utils.addToScriptHash(options, "disabled", attributes.get("disabled"), "false");
+ utils.addToScriptHash(options, "selectFirst", attributes.get("selectFirst"), "false");
+ utils.addToScriptHash(options, "onbegin", attributes.get("onbegin"));
+ utils.addToScriptHash(options, "oncomplete", attributes.get("oncomplete"));
+ utils.addToScriptHash(options, "onerror", attributes.get("onerror"));
+ utils.addToScriptHash(options, "onbeforedomupdate", attributes.get("onbeforedomupdate"));
+ utils.addToScriptHash(options, "onchange", attributes.get("onchange"));
+ StringBuilder builder = new StringBuilder();
+ builder.append(ScriptUtils.toScript(options));
+ return builder.toString();
+ }
+
+ // TODO nick - handle parameter
+ @SuppressWarnings("unchecked")
+ private DataModel<Object> getItems(FacesContext facesContext, AbstractAutoComplete component) {
+ Object itemsObject = null;
+
+ MethodExpression autocompleteMethod = component.getAutocompleteMethod();
+ if (autocompleteMethod != null) {
+ Map<String, String> requestParameters = facesContext.getExternalContext().getRequestParameterMap();
+ String value = requestParameters.get(component.getClientId(facesContext) + "Value");
+ try {
+ // String value = getInputValue(facesContext, component);
+
+ itemsObject = autocompleteMethod.invoke(facesContext.getELContext(), new Object[] { facesContext,
+ component, value });
+ } catch (ELException e) {
+ try {
+ autocompleteMethod = facesContext
+ .getApplication()
+ .getExpressionFactory()
+ .createMethodExpression(facesContext.getELContext(), autocompleteMethod.getExpressionString(),
+ Void.class, new Class[] { String.class });
+ itemsObject = autocompleteMethod.invoke(facesContext.getELContext(), new Object[] { value });
+ } catch (ELException ee) {
+ ee.printStackTrace();
+ }
+
+ }
+ } else {
+ itemsObject = component.getAutocompleteList();
+ }
+
+ DataModel result;
+
+ if (itemsObject instanceof Object[]) {
+ result = new ArrayDataModel((Object[]) itemsObject);
+ } else if (itemsObject instanceof List) {
+ result = new ListDataModel((List<Object>) itemsObject);
+ } else if (itemsObject instanceof Result) {
+ result = new ResultDataModel((Result) itemsObject);
+ } else if (itemsObject instanceof ResultSet) {
+ result = new ResultSetDataModel((ResultSet) itemsObject);
+ } else if (itemsObject != null) {
+ List<Object> temp = new ArrayList<Object>();
+ Iterator<Object> iterator = ((Iterable<Object>) itemsObject).iterator();
+ while (iterator.hasNext()) {
+ temp.add(iterator.next());
+ }
+ result = new ListDataModel(temp);
+ } else {
+ result = new ListDataModel(null);
+ }
+
+ return result;
+ }
+
+ private Object saveVar(FacesContext context, String var) {
+ if (var != null) {
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ return requestMap.get(var);
+ }
+
+ return null;
+ }
+
+ private void setVar(FacesContext context, String var, Object varObject) {
+ if (var != null) {
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ requestMap.put(var, varObject);
+ }
+ }
+
+ protected void encodeItems(FacesContext facesContext, UIComponent component, List<Object> fetchValues)
+ throws IOException {
+ AbstractAutoComplete comboBox = (AbstractAutoComplete) component;
+ AutoCompleteEncodeStrategy strategy = getStrategy(component);
+ strategy.encodeItemsContainerBegin(facesContext, component);
+
+ boolean hasEncodedElements = false;
+
+ Object savedVar = saveVar(facesContext, comboBox.getVar());
+ DataModel<Object> model = getItems(facesContext, comboBox);
+ for (Iterator<Object> items = model.iterator(); items.hasNext();) {
+ hasEncodedElements = true;
+
+ Object nextItem = items.next();
+ setVar(facesContext, comboBox.getVar(), nextItem);
+
+ strategy.encodeItem(facesContext, comboBox, nextItem);
+ if (comboBox.getFetchValue() != null) {
+ fetchValues.add(comboBox.getFetchValue());
+ } else {
+ // TODO use converter
+ fetchValues.add(nextItem);
+ }
+ }
+
+ setVar(facesContext, comboBox.getVar(), savedVar);
+
+ if (!hasEncodedElements) {
+ strategy.encodeFakeItem(facesContext, component);
+ }
+
+ strategy.encodeItemsContainerEnd(facesContext, component);
+ }
+
+ protected void encodeItemsContainer(FacesContext facesContext, UIComponent component) throws IOException {
+ AutoCompleteEncodeStrategy strategy = getStrategy(component);
+ strategy.encodeItemsContainerBegin(facesContext, component);
+ strategy.encodeFakeItem(facesContext, component);
+ strategy.encodeItemsContainerEnd(facesContext, component);
+ }
+
+ private AutoCompleteEncodeStrategy getStrategy(UIComponent component) {
+ AbstractAutoComplete comboBox = (AbstractAutoComplete) component;
+ if (comboBox.getLayout() != null) {
+ if (comboBox.getLayout().equals(AutocompleteLayout.div)) {
+ return new AutocompleteDivLayoutStrategy();
+ }
+ if (comboBox.getLayout().equals(AutocompleteLayout.grid)) {
+ return new AutocompleteGridLayoutStrategy();
+ }
+ if (comboBox.getLayout().equals(AutocompleteLayout.list)) {
+ return new AutocompleteListLayoutStrategy();
+ }
+ if (comboBox.getLayout().equals(AutocompleteLayout.table)) {
+ return new AutocompleteTableLayoutStrategy();
+ }
+ }
+ return new AutocompleteDivLayoutStrategy();
+ }
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ if (InputUtils.isDisabled(component)) {
+ return;
+ }
+ super.doDecode(context, component);
+
+ Map<String, String> requestParameters = context.getExternalContext().getRequestParameterMap();
+ if (requestParameters.get(component.getClientId(context) + ".ajax") != null) {
+ PartialViewContext pvc = context.getPartialViewContext();
+ pvc.getRenderIds().add(
+ component.getClientId(context) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR
+ + AbstractAutoComplete.ITEMS_META_COMPONENT_ID);
+ }
+ }
+
+ public void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId)
+ throws IOException {
+ if (AbstractAutoComplete.ITEMS_META_COMPONENT_ID.equals(metaComponentId)) {
+
+ List<Object> fetchValues = new ArrayList<Object>();
+
+ PartialResponseWriter partialWriter = context.getPartialViewContext().getPartialResponseWriter();
+ partialWriter.startUpdate(getStrategy(component).getContainerElementId(context, component));
+ encodeItems(context, component, fetchValues);
+ partialWriter.endUpdate();
+
+ if (!fetchValues.isEmpty() && Iterators.find(fetchValues.iterator(), Predicates.notNull()) != null) {
+ Map<String, Object> dataMap = AjaxContext.getCurrentInstance(context).getResponseComponentDataMap();
+ dataMap.put(component.getClientId(context), fetchValues);
+ }
+ } else {
+ throw new IllegalArgumentException(metaComponentId);
+ }
+ }
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,86 @@
+/*
+ * 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.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.AbstractAutoComplete;
+
+public class AutocompleteDivLayoutStrategy extends AbstractAutocompleteLayoutStrategy implements
+ AutoCompleteEncodeStrategy {
+
+ public void encodeFakeItem(FacesContext facesContext, UIComponent component) throws IOException {
+ ResponseWriter responseWriter = facesContext.getResponseWriter();
+ responseWriter.startElement(HTML.DIV_ELEM, component);
+ responseWriter.writeAttribute(HTML.STYLE_ATTRIBUTE, "display:none", null);
+ responseWriter.endElement(HTML.DIV_ELEM);
+
+ }
+
+ public void encodeItemsContainerBegin(FacesContext facesContext, UIComponent component) throws IOException {
+ ResponseWriter responseWriter = facesContext.getResponseWriter();
+ responseWriter.startElement(HTML.DIV_ELEM, component);
+ responseWriter.writeAttribute(HTML.ID_ATTRIBUTE, getContainerElementId(facesContext, component), null);
+ // responseWriter.writeAttribute(HTML.CLASS_ATTRIBUTE, "cb_list_ul", null);
+ }
+
+ public void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component) throws IOException {
+ ResponseWriter responseWriter = facesContext.getResponseWriter();
+ responseWriter.endElement(HTML.DIV_ELEM);
+ }
+
+ public void encodeItem(FacesContext facesContext, AbstractAutoComplete comboBox, Object item) throws IOException {
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ writer.startElement(HTML.DIV_ELEM, comboBox);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "cb_option cb_font rf-ac-i", null);
+
+ if (comboBox.getChildCount() > 0) {
+ for (UIComponent child : comboBox.getChildren()) {
+ child.encodeAll(facesContext);
+ }
+ } else {
+ if (item != null) {
+ // TODO nick - use converter
+ String value = null;
+ if (comboBox.getItemConverter() != null) {
+ value = comboBox.getItemConverter().getAsString(facesContext, comboBox, item);
+ }
+ if (value != null) {
+ writer.writeText(value, null);
+ }
+ writer.writeText(item, null);
+ // writer.writeText(InputUtils.getConvertedValue(facesContext, comboBox, item), null);
+ }
+ }
+
+ writer.endElement(HTML.DIV_ELEM);
+
+ }
+
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,34 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.AbstractAutoComplete;
+
+public class AutocompleteGridLayoutStrategy extends AbstractAutocompleteLayoutStrategy implements
+ AutoCompleteEncodeStrategy {
+
+ public void encodeFakeItem(FacesContext facesContext, UIComponent component) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void encodeItemsContainerBegin(FacesContext facesContext, UIComponent component) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void encodeItem(FacesContext facesContext, AbstractAutoComplete comboBox, Object nextItem)
+ throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,63 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.AbstractAutoComplete;
+
+public class AutocompleteListLayoutStrategy extends AbstractAutocompleteLayoutStrategy implements
+ AutoCompleteEncodeStrategy {
+
+ public void encodeFakeItem(FacesContext facesContext, UIComponent component) throws IOException {
+ ResponseWriter responseWriter = facesContext.getResponseWriter();
+ responseWriter.startElement(HTML.LI_ELEMENT, component);
+ responseWriter.writeAttribute(HTML.STYLE_ATTRIBUTE, "display:none", null);
+ responseWriter.endElement(HTML.LI_ELEMENT);
+
+ }
+
+ public void encodeItemsContainerBegin(FacesContext facesContext, UIComponent component) throws IOException {
+ ResponseWriter responseWriter = facesContext.getResponseWriter();
+ responseWriter.startElement(HTML.UL_ELEMENT, component);
+ responseWriter.writeAttribute(HTML.ID_ATTRIBUTE, getContainerElementId(facesContext, component), null);
+ responseWriter.writeAttribute(HTML.CLASS_ATTRIBUTE, "cb_list_ul", null);
+ }
+
+ public void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component) throws IOException {
+ ResponseWriter responseWriter = facesContext.getResponseWriter();
+ responseWriter.endElement(HTML.UL_ELEMENT);
+ }
+
+ public void encodeItem(FacesContext facesContext, AbstractAutoComplete comboBox, Object item) throws IOException {
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ writer.startElement(HTML.LI_ELEMENT, comboBox);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "cb_option cb_font rf-ac-i", null);
+
+ if (comboBox.getChildCount() > 0) {
+ for (UIComponent child : comboBox.getChildren()) {
+ child.encodeAll(facesContext);
+ }
+ } else {
+ if (item != null) {
+ // TODO nick - use converter
+ String value = null;
+ if (comboBox.getItemConverter() != null) {
+ value = comboBox.getItemConverter().getAsString(facesContext, comboBox, item);
+ }
+ if (value != null) {
+ writer.writeText(value, null);
+ }
+ writer.writeText(item, null);
+ }
+ }
+
+ writer.endElement(HTML.LI_ELEMENT);
+
+ }
+
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,34 @@
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.AbstractAutoComplete;
+
+public class AutocompleteTableLayoutStrategy extends AbstractAutocompleteLayoutStrategy implements
+ AutoCompleteEncodeStrategy {
+
+ public void encodeFakeItem(FacesContext facesContext, UIComponent component) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void encodeItemsContainerBegin(FacesContext facesContext, UIComponent component) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void encodeItem(FacesContext facesContext, AbstractAutoComplete comboBox, Object nextItem)
+ throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteBaseGradient.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteBaseGradient.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteBaseGradient.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteBaseGradient.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,126 @@
+/*
+ * 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.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.CacheableResource;
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public abstract class AutoCompleteBaseGradient implements Java2DUserResource, CacheableResource, StateHolderResource {
+
+ private static final Dimension DIMENSION = new Dimension(18, 8);
+
+ private String topColorSkinParameter;
+
+ private String bottomColorSkinParameter;
+
+ private Color topColor;
+
+ private Color bottomColor;
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public Dimension getDimension() {
+ return DIMENSION;
+ }
+
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ GradientPaint paint = new GradientPaint(0, 0, topColor, 0, dimension.height, bottomColor);
+ graphics2d.setPaint(paint);
+ graphics2d.fill(new Rectangle(dimension));
+ }
+
+ public boolean isCacheable(FacesContext context) {
+ return true;
+ }
+
+ public Date getExpires(FacesContext context) {
+ return null;
+ }
+
+ public int getTimeToLive(FacesContext context) {
+ return 0;
+ }
+
+ public String getEntityTag(FacesContext context) {
+ return null;
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+
+ Integer topColor = skin.getColorParameter(context, topColorSkinParameter);
+ Integer bottomColor = skin.getColorParameter(context, bottomColorSkinParameter);
+
+ dataOutput.writeInt(topColor);
+ dataOutput.writeInt(bottomColor);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ topColor = new Color(dataInput.readInt());
+ bottomColor = new Color(dataInput.readInt());
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ protected void setTopColorSkinParameter(String topColorSkinParameter) {
+ this.topColorSkinParameter = topColorSkinParameter;
+ }
+
+ protected void setBottomColorSkinParameter(String bottomColorSkinParameter) {
+ this.bottomColorSkinParameter = bottomColorSkinParameter;
+ }
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteButtonGradient.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteButtonGradient.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteButtonGradient.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteButtonGradient.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,39 @@
+/*
+ * 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.html.images;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.skin.Skin;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class AutoCompleteButtonGradient extends AutoCompleteBaseGradient {
+
+ public AutoCompleteButtonGradient() {
+ setTopColorSkinParameter(Skin.HEADER_GRADIENT_COLOR);
+ setBottomColorSkinParameter(Skin.HEADER_BACKGROUND_COLOR);
+ }
+
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteFieldGradient.java (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteFieldGradient.java)
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteFieldGradient.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/html/images/AutoCompleteFieldGradient.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -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.renderkit.html.images;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.skin.Skin;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class AutoCompleteFieldGradient extends AutoCompleteBaseGradient {
+
+ public AutoCompleteFieldGradient() {
+ setTopColorSkinParameter(Skin.ADDITIONAL_BACKGROUND_COLOR);
+ setBottomColorSkinParameter(Skin.CONTROL_BACKGROUND_COLOR);
+ }
+}
Copied: trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/view/facelets)
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/AutoCompleteHandler.java
===================================================================
--- sandbox/trunk/ui/inputs/combobox/src/main/java/org/richfaces/view/facelets/AutoCompleteHandler.java 2010-08-16 11:52:42 UTC (rev 18655)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/AutoCompleteHandler.java 2010-08-16 12:46:35 UTC (rev 18656)
@@ -22,10 +22,7 @@
package org.richfaces.view.facelets;
import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.DateTimeConverter;
import javax.faces.view.facelets.ComponentConfig;
import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.FaceletContext;
@@ -34,6 +31,7 @@
import javax.faces.view.facelets.Metadata;
import javax.faces.view.facelets.MetadataTarget;
import javax.faces.view.facelets.TagAttribute;
+
import org.richfaces.MethodMetadata;
import org.richfaces.component.AbstractAutoComplete;
@@ -41,11 +39,11 @@
* @author Nick Belaevski
*
*/
-//TODO nick - this should be generated by CDK
+// TODO nick - this should be generated by CDK
public class AutoCompleteHandler extends ComponentHandler {
private static final MetaRule AUTOCOMPLETE_METHOD_META_RULE = new MetaRule() {
-
+
@Override
public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
if (meta.isTargetInstanceOf(AbstractAutoComplete.class)) {
@@ -56,28 +54,22 @@
}
};
}
- /*if ("converter".equals(name)) {
- return new ConverterMetadata(attribute) {
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractComboBox) instance).setConverter((Converter) this.getAttr()
- .getObject(ctx, Converter.class));
- }
- };
- }*/
- /*if ("itemConverter".equals(name)) {
- return new ConverterMetadata(attribute) {
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractComboBox) instance).setItemConverter((Converter) this.getAttr()
- .getObject(ctx, Converter.class));
- }
- };
- }*/
+ /*
+ * if ("converter".equals(name)) { return new ConverterMetadata(attribute) { public void
+ * applyMetadata(FaceletContext ctx, Object instance) { ((AbstractComboBox)
+ * instance).setConverter((Converter) this.getAttr() .getObject(ctx, Converter.class)); } }; }
+ */
+ /*
+ * if ("itemConverter".equals(name)) { return new ConverterMetadata(attribute) { public void
+ * applyMetadata(FaceletContext ctx, Object instance) { ((AbstractComboBox)
+ * instance).setItemConverter((Converter) this.getAttr() .getObject(ctx, Converter.class)); } }; }
+ */
}
-
+
return null;
}
};
-
+
public AutoCompleteHandler(ComponentConfig config) {
super(config);
}
@@ -88,17 +80,18 @@
metaRuleset.addRule(AUTOCOMPLETE_METHOD_META_RULE);
return metaRuleset;
}
- static abstract class ConverterMetadata extends Metadata {
+ abstract static class ConverterMetadata extends Metadata {
+
private final TagAttribute attr;
public ConverterMetadata(TagAttribute attr) {
this.attr = attr;
}
- public TagAttribute getAttr() {
- return attr;
- }
-
+ public TagAttribute getAttr() {
+ return attr;
+ }
+
}
}
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.ecss (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.ecss)
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.ecss (rev 0)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.ecss 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,152 @@
+.cb_field_width {
+ width: 200px;
+}
+
+.cb_list_width {
+ width: 200px;
+}
+
+.cb_list_height {
+ max-height: 100px;
+ min-height: 20px;
+}
+
+.cb_input.cb_font, .cb_option.cb_font {
+ color: '#{richSkin.generalTextColor}';
+ font-size: '#{richSkin.generalSizeFont}';
+ font-family: '#{richSkin.generalFamilyFont}';
+}
+
+input.cb_input {
+ border-width: 0px;
+ background: none;
+ width: 100%;
+}
+
+.cb_field {
+ 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}';
+}
+
+.cb_button {
+ 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}';
+ width: 15px;
+ position: absolute;
+ top: 0px;
+ right: 0px;
+ height: 200px;
+ padding-top: 1px
+}
+
+.cb_button_arrow {
+ background-position: center;
+ background-repeat: no-repeat;
+ background-image: "url(#{resource['org.richfaces:combo_down_button.gif']})";
+ cursor: pointer;
+ width: 15px;
+ height: 15px;
+}
+
+.cb_list_cord {
+ position: absolute;
+ /* TODO nick - review: font-size: 0px; */
+ display: none;
+}
+
+.cb_list_decoration {
+ border-width: 1px;
+ border-style: solid;
+ border-color: '#{richSkin.panelBorderColor}';
+ padding: 0px;
+ background-color: '#{richSkin.tableBackgroundColor}';
+}
+
+.cb_list_scroll {
+ overflow: auto;
+ overflow-x: hidden;
+}
+
+.cb_option {
+ padding: 2px;
+ white-space: nowrap;
+ cursor: default;
+ list-style-type: none;
+}
+
+.cb_select {
+ padding: 1px;
+ width: 100%;
+ background-color: #DFE8F6;
+ border-width: 1px;
+ border-style: dotted;
+ border-color: '#{richSkin.generalTextColor}';
+}
+
+.cb_shadow {
+ border: 0px solid red;
+ display: inline-block;
+ position: absolute;
+ float: left;
+ padding: 6px 6px 6px 6px;
+ top: -6px;
+ left: -7px;
+}
+
+.cb_shadow_t {
+ background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
+ background-position: top left;
+ position: absolute;
+ width: 6px;
+ top: 0px;
+ bottom: 6px;
+ left: 0px
+}
+
+.cb_shadow_l {
+ background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
+ background-position: bottom left;
+ position: absolute;
+ height: 6px;
+ bottom: 0px;
+ left: 0px;
+ right: 6px;
+}
+
+.cb_shadow_r {
+ background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
+ background-position: bottom right;
+ position: absolute;
+ width: 6px;
+ top: 6px;
+ bottom: 0px;
+ right: 0px;
+}
+
+.cb_shadow_b {
+ background-image: "url(#{resource['org.richfaces:combo_list_shadow.png']})";
+ background-position: right top;
+ position: absolute;
+ height: 6px;
+ top: 0px;
+ left: 6px;
+ right: 0px;
+}
+
+.cb_list_ul {
+ margin: 0px;
+ padding: 0px;
+}
\ No newline at end of file
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js)
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js (rev 0)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoComplete.js 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,408 @@
+(function ($, rf) {
+ rf.utils = rf.utils || {};
+
+ rf.utils.Cache = function (key, items, values) {
+ this.key = key;
+ this.cache = {}
+ this.cache[this.key] = items || [];
+ this.values = typeof values != "function" ? values || this.cache[this.key] : values(items);
+ };
+
+ var getItems = function (key) {
+ var newCache = [];
+
+ if (key.length < this.key.length) {
+ return newCache;
+ }
+
+ if (this.cache[key]) {
+ newCache = this.cache[key];
+ } else {
+ var itemsCache = this.cache[this.key];
+ for (var i = 0; i<this.values.length; i++) {
+ var value = this.values[i].toLowerCase();
+ var p = value.indexOf(key.toLowerCase());
+ if (p == 0) {
+ newCache.push(itemsCache[i]);
+ }
+ }
+
+ if ((!this.lastKey || key.indexOf(this.lastKey)!=0) && newCache.length > 0) {
+ this.cache[key] = newCache;
+ if (newCache.length==1) {
+ this.lastKey = key;
+ }
+ }
+ }
+
+ return newCache;
+ };
+
+ var getItemValue = function (item) {
+ return this.values[this.cache[this.key].index(item)];
+ };
+
+ var isCached = function (key) {
+ return this.cache[key];
+ };
+
+ $.extend(rf.utils.Cache.prototype, (function () {
+ return {
+ getItems: getItems,
+ getItemValue: getItemValue,
+ isCached: isCached
+ };
+ })());
+
+})(jQuery, RichFaces);
+
+(function ($, rf) {
+
+ /*
+ * TODO: add user's event handlers call from options
+ * TODO: add fire events
+ */
+
+ rf.ui = rf.ui || {};
+ // Constructor definition
+ rf.ui.AutoComplete = function(componentId, fieldId, options) {
+ this.namespace = "."+rf.Event.createNamespace(this.name, this.id);
+ this.options = {};
+ // call constructor of parent class
+ $super.constructor.call(this, componentId, componentId+ID.SELECT, fieldId, options);
+ this.attachToDom(componentId);
+ this.options = $.extend(this.options, defaultOptions, options);
+ this.value = this.__getSubValue();
+ this.index = -1;
+ this.isFirstAjax = true;
+ updateTokenOptions.call(this);
+ bindEventHandlers.call(this);
+ updateItemsList.call(this, "");
+ };
+
+ // Extend component class and add protected methods from parent class to our container
+ rf.ui.AutoCompleteBase.extend(rf.ui.AutoComplete);
+
+ // define super class link
+ var $super = rf.ui.AutoComplete.$super;
+
+ var defaultOptions = {
+ selectedItemClass:'cb_select',
+ autoFill:true,
+ minChars:1,
+ selectFirst:true,
+ ajaxMode:true,
+ tokens: ",",
+ attachToBody:true
+ };
+
+ var ID = {
+ SELECT:'List',
+ ITEMS:'Items',
+ VALUE:'Value'
+ };
+
+ var REGEXP_TRIM = /^[\n\s]*(.*)[\n\s]*$/;
+ var REGEXP_TOKEN_LEFT;
+ var REGEXP_TOKEN_RIGHT;
+
+ var getData = function (nodeList) {
+ var data = [];
+ nodeList.each(function () {;
+ data.push($(this).text().replace(REGEXP_TRIM, "$1"));
+ });
+ return data;
+ }
+
+ var updateTokenOptions = function () {
+ this.useTokens = (typeof this.options.tokens == "string" && this.options.tokens.length>0);
+ if (this.useTokens) {
+ var escapedTokens = this.options.tokens.split('').join("\\");
+ REGEXP_TOKEN_LEFT = new RegExp('[^'+escapedTokens+']+$','i');
+ REGEXP_TOKEN_RIGHT = new RegExp('['+escapedTokens+']','i');
+ this.hasSpaceToken = this.options.tokens.indexOf(' ')!=-1;
+ };
+ };
+
+ var bindEventHandlers = function () {
+ rf.Event.bind(rf.getDomElement(this.id+ID.ITEMS).parentNode, "click"+this.namespace+" mouseover"+this.namespace, onMouseAction, this);
+ };
+
+ var onMouseAction = function(event) {
+ var element = $(event.target).closest(".rf-ac-i", event.currentTarget).get(0);
+
+ if (element) {
+ if (event.type=="mouseover") {
+ var index = this.items.index(element);
+ if (index!=this.index) {
+ selectItem.call(this, index);
+ }
+ } else {
+ this.__onChangeValue(event, getSelectedItemValue.call(this));
+ rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
+ this.hide(event);
+ }
+ }
+ };
+
+ var updateItemsList = function (value, fetchValues) {
+ this.items = $(rf.getDomElement(this.id+ID.ITEMS)).find(".rf-ac-i");
+ if (this.items.length>0) {
+ this.cache = new rf.utils.Cache(value, this.items, fetchValues || getData);
+ }
+ };
+
+ var scrollToSelectedItem = function() {
+ var offset = 0;
+ this.items.slice(0, this.index).each(function() {
+ offset += this.offsetHeight;
+ });
+ var parentContainer = $(rf.getDomElement(this.id+ID.ITEMS)).parent();
+ if(offset < parentContainer.scrollTop()) {
+ parentContainer.scrollTop(offset);
+ } else {
+ offset+=this.items.get(this.index).offsetHeight;
+ if(offset - parentContainer.scrollTop() > parentContainer.get(0).clientHeight) {
+ parentContainer.scrollTop(offset - parentContainer.innerHeight());
+ }
+ }
+ };
+
+ var autoFill = function (inputValue, value) {
+ if( this.options.autoFill) {
+ var field = rf.getDomElement(this.fieldId);
+ var start = rf.Selection.getStart(field);
+ this.setInputValue(inputValue + value.substring(inputValue.length));
+ var end = start+value.length - inputValue.length;
+ rf.Selection.set(field, start, end);
+ }
+ };
+
+ var callAjax = function(event, value) {
+
+ $(rf.getDomElement(this.id+ID.ITEMS)).removeData().empty();
+ rf.getDomElement(this.id+ID.VALUE).value = value;
+
+ var _this = this;
+ var ajaxSuccess = function (event) {
+ updateItemsList.call(_this, _this.value, event.componentData && event.componentData[_this.id]);
+ if (_this.isVisible && _this.options.selectFirst) {
+ selectItem.call(_this, 0);
+ }
+ }
+
+ var ajaxError = function (event) {
+ //alert("error");
+ }
+
+ this.isFirstAjax = false;
+ //caution: JSF submits inputs with empty names causing "WARNING: Parameters: Invalid chunk ignored." in Tomcat log
+ var params = {};
+ params[this.id + ".ajax"] = "1";
+ rf.ajax(this.id, event, {parameters: params, error: ajaxError, complete:ajaxSuccess});
+ };
+
+ var selectItem = function(index, isOffset, noAutoFill) {
+ if (this.items.length==0) return;
+
+ if (this.index!=-1) {
+ this.items.eq(this.index).removeClass(this.options.selectedItemClass);
+ }
+
+ if (index==undefined) {
+ this.index = -1;
+ return;
+ }
+
+ if (isOffset) {
+ this.index += index;
+ if ( this.index<0 ) {
+ this.index = this.items.length - 1;
+ } else if (this.index >= this.items.length) {
+ this.index = 0;
+ }
+ } else {
+ if (index<0) {
+ index = 0;
+ } else if (index>=this.items.length) {
+ index = this.items.length - 1;
+ }
+ this.index = index;
+ }
+ var item = this.items.eq(this.index);
+ item.addClass(this.options.selectedItemClass);
+ scrollToSelectedItem.call(this);
+ !noAutoFill && autoFill.call(this, this.value, getSelectedItemValue.call(this));
+ };
+
+ var onChangeValue = function (event, value) {
+ //if(this.options.onchange){
+ //this.options.onchange.call(this, event);
+ //}
+ selectItem.call(this);
+
+ // value is undefined if called from AutoCompleteBase onChange
+ var subValue = (typeof value == "undefined") ? this.__getSubValue() : value;
+
+ // TODO: ajax call here if needed
+ if ((!this.cache || subValue.length==0 || subValue.toLowerCase().indexOf(this.cache.key.toLowerCase())!=0) &&
+ subValue.length>=this.options.minChars) {
+ this.value = subValue;
+ this.options.ajaxMode && callAjax.call(this, event, subValue);
+ return;
+ }
+ if(!this.cache){
+ return;
+ }
+ var newItems = this.cache.getItems(subValue);
+ this.items = $(newItems);
+ //TODO: works only with simple markup, not with <tr>
+ $(rf.getDomElement(this.id+ID.ITEMS)).empty().append(newItems);
+ this.index = -1;
+ this.value = subValue;
+ if (subValue.length<this.options.minChars){
+ this.hide();
+ }
+ if (this.options.selectFirst) {
+ if (event.which == rf.KEYS.RETURN || event.type == "click") {
+ this.setInputValue(subValue);
+ return;
+ } else {
+ selectItem.call(this, 0, false, event.which == rf.KEYS.BACKSPACE || event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT);
+ return;
+ }
+ }
+ this.setInputValue(subValue);
+ };
+
+ var getSelectedItemValue = function () {
+ if ( this.index>=0) {
+ var element = this.items.eq(this.index);
+ return this.cache.getItemValue(element);
+ }
+ return undefined;
+ };
+
+ var getSubValue = function () {
+ //TODO: add posibility to use space chars before and after tokens if space not a token char
+ if (this.useTokens) {
+ var field = rf.getDomElement(this.fieldId);
+ var value = field.value;
+ var cursorPosition = rf.Selection.getStart(field);
+ var beforeCursorStr = value.substring(0, cursorPosition);
+ var afterCursorStr = value.substring(cursorPosition);
+ var r = REGEXP_TOKEN_LEFT.exec(beforeCursorStr);
+ var result = "";
+ if (r) {
+ result = r[0];
+ }
+ r = afterCursorStr.search(REGEXP_TOKEN_RIGHT);
+ if (r==-1) r = afterCursorStr.length;
+ result += afterCursorStr.substring(0, r);
+
+ return result;
+ } else {
+ return this.getInputValue();
+ }
+ };
+
+ var updateInputValue = function (value) {
+ var field = rf.getDomElement(this.fieldId);
+ var inputValue = field.value;
+
+ var cursorPosition = rf.Selection.getStart(field);
+ var beforeCursorStr = inputValue.substring(0, cursorPosition);
+ var afterCursorStr = inputValue.substring(cursorPosition);
+
+ var pos = beforeCursorStr.search(REGEXP_TOKEN_LEFT);
+ var startPos = pos!=-1 ? pos : beforeCursorStr.length;
+ pos = afterCursorStr.search(REGEXP_TOKEN_RIGHT);
+ var endPos = pos!=-1 ? pos : afterCursorStr.length;
+
+ var beginNewValue = inputValue.substring(0, startPos) + value;
+ cursorPosition = beginNewValue.length;
+ field.value = beginNewValue + afterCursorStr.substring(endPos);
+ field.focus();
+ rf.Selection.setCaretTo(field, cursorPosition);
+ return field.value;
+ };
+
+ /*
+ * Prototype definition
+ */
+ $.extend(rf.ui.AutoComplete.prototype, (function () {
+ return {
+ /*
+ * public API functions
+ */
+ name:"AutoComplete",
+ /*
+ * Protected methods
+ */
+ __updateState: function (event) {
+ var subValue = this.__getSubValue();
+ // called from onShow method, not actually value changed
+ if (this.items.length==0 && this.isFirstAjax) {
+ this.options.ajaxMode && callAjax.call(this, event, subValue);
+ }
+ return;
+ },
+ __getSubValue: getSubValue,
+ __updateInputValue: function (value) {
+ if (this.useTokens) {
+ return updateInputValue.call(this, value);
+ } else {
+ return $super.__updateInputValue.call(this, value);
+ }
+ },
+ __onChangeValue: onChangeValue,
+ /*
+ * Override abstract protected methods
+ */
+ __onKeyUp: function () {
+ selectItem.call(this, -1, true);
+ },
+ __onKeyDown: function () {
+ selectItem.call(this, 1, true);
+ },
+ __onPageUp: function () {
+
+ },
+ __onPageDown: function () {
+
+ },
+ __onBeforeShow: function (event) {
+ },
+ __onEnter: function (event) {
+ this.__onChangeValue(event, getSelectedItemValue.call(this));
+ //rf.getDomElement(this.fieldId).blur();
+ //rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
+ //rf.getDomElement(this.fieldId).focus();
+ },
+ __onShow: function (event) {
+ if (event.which != rf.KEYS.BACKSPACE) {
+ if(this.items && this.items.length>0){
+ if (this.index!=0 && this.options.selectFirst) {
+ selectItem.call(this, 0);
+ }
+ }
+ }
+ },
+ __onHide: function () {
+ selectItem.call(this);
+ },
+ /*
+ * Destructor
+ */
+ destroy: function () {
+ //TODO: add all unbind
+ this.items = null;
+ this.cache = null;
+ var itemsContainer = rf.getDomElement(this.id+ID.ITEMS);
+ $(itemsContainer).removeData();
+ rf.Event.unbind(itemsContainer.parentNode, this.namespace);
+ $super.destroy.call(this);
+ }
+ };
+ })());
+})(jQuery, RichFaces);
\ No newline at end of file
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js)
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js (rev 0)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutoCompleteBase.js 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,297 @@
+// TODO: move this extend to RichFaces.Event for exapmle
+$.extend(RichFaces.Event, {
+ bindScrollEventHandlers: function(element, handler, component) {
+ var elements = [];
+ element = RichFaces.getDomElement(element).parentNode;
+ while (element && element!=window.document.body)
+ {
+ if (element.offsetWidth!=element.scrollWidth || element.offsetHeight!=element.scrollHeight)
+ {
+ elements.push(element);
+ RichFaces.Event.bind(element, "scroll"+component.getNamespace(), handler, component);
+ }
+ element = element.parentNode;
+ }
+ return elements;
+ },
+ unbindScrollEventHandlers: function(elements, component) {
+ RichFaces.Event.unbind(elements, component.getNamespace());
+ }
+});
+
+(function (rf) {
+ rf.KEYS = {
+ BACKSPACE: 8,
+ TAB: 9,
+ RETURN: 13,
+ ESC: 27,
+ PAGEUP: 33,
+ PAGEDOWN: 34,
+ LEFT: 37,
+ UP: 38,
+ RIGHT: 39,
+ DOWN: 40,
+ DEL: 46,
+ }
+})(RichFaces);
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ // Constructor definition
+ rf.ui.AutoCompleteBase = function(componentId, selectId, fieldId, options) {
+ // call constructor of parent class
+ $super.constructor.call(this, componentId);
+ this.selectId = selectId;
+ this.fieldId = fieldId;
+ this.options = $.extend({}, defaultOptions, options);
+ this.namespace = this.namespace || "."+rf.Event.createNamespace(this.name, this.selectId);
+ this.currentValue = this.getInputValue();
+ bindEventHandlers.call(this);
+ };
+
+ // Extend component class and add protected methods from parent class to our container
+ rf.BaseComponent.extend(rf.ui.AutoCompleteBase);
+
+ // define super class link
+ var $super = rf.ui.AutoCompleteBase.$super;
+
+ var defaultOptions = {
+ changeDelay:8
+ };
+
+ var bindEventHandlers = function() {
+
+ var inputEventHandlers = {};
+
+ if (this.options.buttonId && !this.options.disabled) {
+ inputEventHandlers["mousedown"+this.namespace] = onButtonShow;
+ inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
+ rf.Event.bindById(this.options.buttonId, inputEventHandlers, this);
+ }
+
+ inputEventHandlers = {};
+ inputEventHandlers["focus"+this.namespace] = onFocus;
+ inputEventHandlers["blur"+this.namespace] = onBlur;
+ inputEventHandlers["click"+this.namespace] = onClick;
+ inputEventHandlers[($.browser.opera ? "keypress" : "keydown")+this.namespace] = onKeyDown;
+ rf.Event.bindById(this.fieldId, inputEventHandlers, this);
+
+ inputEventHandlers = {};
+ inputEventHandlers["mousedown"+this.namespace] = onSelectMouseDown;
+ inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
+ rf.Event.bindById(this.selectId, inputEventHandlers, this);
+ };
+
+ var onSelectMouseDown = function () {
+ this.isMouseDown = true;
+ };
+ var onSelectMouseUp = function () {
+ rf.getDomElement(this.fieldId).focus();
+ };
+
+ var onButtonShow = function (event) {
+ this.isMouseDown = true;
+ if (this.timeoutId) {
+ window.clearTimeout(this.timeoutId);
+ this.timeoutId = null;
+ rf.getDomElement(this.fieldId).focus();
+ }
+
+ if (this.isVisible) {
+ this.hide(event);
+ } else {
+ onShow.call(this, event);
+ }
+ };
+
+ var onFocus = function (event) {
+ };
+
+ var onBlur = function (event) {
+ if (this.isMouseDown) {
+ rf.getDomElement(this.fieldId).focus();
+ this.isMouseDown = false;
+ } else if (this.isVisible && !this.isMouseDown) {
+ var _this = this;
+ this.timeoutId = window.setTimeout(function(){_this.hide();}, 200);
+ }
+ };
+
+ var onClick = function (event) {
+ };
+
+ var onChange = function (event) {
+ var value = this.getInputValue();
+ var flag = value != this.currentValue;
+ //TODO: is it needed to chesk keys?
+ //TODO: we need to set value when autoFill used when LEFT or RIGHT was pressed
+ if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
+ if (flag || this.isVisible) {
+ this.__onChangeValue(event);
+ }
+ if (flag) {
+ this.currentValue = this.getInputValue();
+ if(value && value.length>=this.options.minChars){
+ onShow.call(this, event);
+ }
+
+ }
+ }
+ };
+
+ var onShow = function (event) {
+ this.__updateState(event);
+ this.show(event);
+ };
+
+ var onKeyDown = function (event) {
+ switch(event.which) {
+ case rf.KEYS.UP:
+ event.preventDefault();
+ if (this.isVisible) {
+ this.__onKeyUp(event);
+ }
+ break;
+ case rf.KEYS.DOWN:
+ event.preventDefault();
+ if (this.isVisible) {
+ this.__onKeyDown(event);
+ } else {
+ onShow.call(this, event);
+ }
+ break;
+ case rf.KEYS.PAGEUP:
+ event.preventDefault();
+ if (this.isVisible) {
+ this.__onPageUp(event);
+ }
+ break;
+ case rf.KEYS.PAGEDOWN:
+ event.preventDefault();
+ if (this.isVisible) {
+ this.__onPageDown(event);
+ }
+ break;
+ case rf.KEYS.RETURN:
+
+ event.preventDefault();
+ this.__onEnter(event);
+ //TODO: bind form submit event handler to cancel form submit under the opera
+ //cancelSubmit = true;
+ this.hide();
+ return false;
+ break;
+ case rf.KEYS.ESC:
+ this.hide();
+ break;
+ default:
+ if (!this.options.selectOnly) {
+ var _this = this;
+ window.clearTimeout(this.changeTimerId);
+ this.changeTimerId = window.setTimeout(function(){onChange.call(_this, event);}, this.options.changeDelay)
+ }
+ break;
+ }
+ }
+
+ /*
+ * public API functions definition
+ */
+ var show = function (event, showButtonPressed) {
+ if (!this.isVisible) {
+ if (this.__onBeforeShow(event)!=false) {
+ this.scrollElements = rf.Event.bindScrollEventHandlers(this.selectId, this.hide, this, this.namespace);
+ if (this.options.attachToBody) {
+ var element = rf.getDomElement(this.selectId);
+ this.parentElement = element.parentNode;
+ $(element).detach().appendTo("body");
+ }
+ $(rf.getDomElement(this.selectId)).setPosition({id: this.fieldId}, {type:"DROPDOWN", offset:[0,20]}).show();
+ this.isVisible = true;
+ this.__onShow(event, showButtonPressed);
+ }
+ }
+ };
+ var hide = function (event) {
+ if (this.isVisible) {
+ rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
+ this.scrollElements = null;
+ $(rf.getDomElement(this.selectId)).hide();
+ this.isVisible = false;
+ if (this.options.attachToBody && this.parentElement) {
+ $(rf.getDomElement(this.selectId)).detach().appendTo(this.parentElement);
+ this.parentElement = null;
+ }
+ this.__onHide(event);
+ }
+ };
+
+ /*
+ * Prototype definition
+ */
+ $.extend(rf.ui.AutoCompleteBase.prototype, (function () {
+ return {
+ /*
+ * public API functions
+ */
+ name:"AutoCompleteBase",
+ show: show,
+ hide: hide,
+ getNamespace: function () {
+ return this.namespace;
+ },
+ getInputValue: function () {
+ return this.fieldId ? rf.getDomElement(this.fieldId).value : "";
+ },
+ setInputValue: function (value) {
+ this.currentValue = this.__updateInputValue(value);
+ },
+ /*
+ * Protected methods
+ */
+ __updateInputValue: function (value) {
+ if (this.fieldId) {
+ rf.getDomElement(this.fieldId).value = value;
+ return value;
+ } else {
+ return "";
+ }
+ },
+ /*
+ * abstract protected methods
+ */
+ __onChangeValue: function (event) {
+ },
+ __onKeyUp: function () {
+ },
+ __onKeyDown: function () {
+ },
+ __onPageUp: function () {
+ },
+ __onPageDown: function () {
+ },
+ __onBeforeShow: function () {
+ },
+ __onShow: function () {
+ },
+ __onHide: function () {
+ },
+ /*
+ * Destructor
+ */
+ destroy: function () {
+ this.parentNode = null;
+ if (this.scrollElements) {
+ rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
+ this.scrollElements = null;
+ }
+ this.options.buttonId && rf.Event.unbindById(this.options.buttonId, this.namespace);
+ rf.Event.unbindById(this.fieldId, this.namespace);
+ rf.Event.unbindById(this.selectId, this.namespace);
+ $super.destroy.call(this);
+ }
+ };
+ })());
+})(jQuery, RichFaces);
\ No newline at end of file
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/combo_down_button.gif (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/resources/META-INF/resources/org.richfaces/combo_down_button.gif)
===================================================================
(Binary files differ)
Copied: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/combo_list_shadow.png (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/resources/META-INF/resources/org.richfaces/combo_list_shadow.png)
===================================================================
(Binary files differ)
Copied: trunk/ui/input/ui/src/main/templates/autoComplete.template.xml (from rev 18655, sandbox/trunk/ui/inputs/combobox/src/main/templates/comboBox.template.xml)
===================================================================
--- trunk/ui/input/ui/src/main/templates/autoComplete.template.xml (rev 0)
+++ trunk/ui/input/ui/src/main/templates/autoComplete.template.xml 2010-08-16 12:46:35 UTC (rev 18656)
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://richfaces.org/cdk/xhtml-el" xmlns:cdk="http://richfaces.org/cdk/core"
+ xmlns:c="http://richfaces.org/cdk/jstl/core" xmlns:cc="http://richfaces.org/cdk/jsf/composite"
+ xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.AutoCompleteRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.AutoCompleteRendererBase</cdk:superclass>
+ <cdk:component-family>javax.faces.Input</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.AutoCompleteRenderer
+ </cdk:renderer-type>
+ <cdk:renders-children>true</cdk:renders-children>
+ </cc:interface>
+
+ <cc:implementation>
+ <cdk:object type="java.lang.Object" name="disabled" value="#{component.attributes['disabled']}" />
+ <div id="#{clientId}" class="cb_field_width cb_field">
+ <input id="#{clientId}Value" name="#{clientId}Value" type="hidden" class="cb_font cb_input" />
+ <div style="position : relative; overflow : hidden; text-align : left; padding-right : 21px;">
+ <input onclick="#{component.attributes['onclick']}"
+ ondblclick="#{component.attributes['ondblclick']}"
+ onmouseup="#{component.attributes['onmouseup']}"
+ onmousedown="#{component.attributes['onmousedown']}"
+ onmousemove="#{component.attributes['onmousemove']}"
+ onblur="#{component.attributes['onblur']}"
+ onfocus="#{component.attributes['onfocus']}"
+ onmouseover="#{component.attributes['onmouseover']}"
+ onmouseout="#{component.attributes['onmouseout']}"
+ onkeyup="#{component.attributes['onkeyup']}"
+ onkeydown="#{component.attributes['onkeydown']}"
+ onkeypress="#{component.attributes['onkeypress']}" id="#{clientId}Input" disabled="#{disabled}" name="#{clientId}" type="text" class="cb_font cb_input" />
+ <c:if test="#{component.attributes['showButton']}">
+ <c:if test="#{component.attributes['disabled']}">
+ <div id="#{clientId}Button" class="cb_button">
+ <div class="cb_button_arrow"></div>
+ </div>
+ </c:if>
+ <c:if test="#{!component.attributes['disabled']}">
+ <div id="#{clientId}Button" class="cb_button">
+ <div class="cb_button_arrow"></div>
+ </div>
+ </c:if>
+ </c:if>
+ </div>
+
+ <div onclick="#{component.attributes['onlistclick']}"
+ ondblclick="#{component.attributes['onlistdblclick']}"
+ onmouseup="#{component.attributes['onlistmouseup']}"
+ onmousedown="#{component.attributes['onlistmousedown']}"
+ onmousemove="#{component.attributes['onlistmousemove']}"
+ onmouseover="#{component.attributes['onlistmouseover']}"
+ onmouseout="#{component.attributes['onlistmouseout']}"
+ onblur="#{component.attributes['onlistblur']}"
+ onfocus="#{component.attributes['onlistfocus']}"
+ onkeyup="#{component.attributes['onlistkeyup']}"
+ onkeydown="#{component.attributes['onlistkeydown']}"
+ onkeypress="#{component.attributes['onlistkeypress']}"
+ id="#{clientId}List" class="cb_list_cord">
+
+ <div class="cb_shadow">
+ <div class="cb_shadow_t"></div>
+ <div class="cb_shadow_l"></div>
+ <div class="cb_shadow_r"></div>
+ <div class="cb_shadow_b"></div>
+
+ <div class="cb_list_decoration">
+ <div class="cb_list_scroll cb_list_width cb_list_height">
+ <cdk:body>
+ <cdk:call expression="encodeItemsContainer(facesContext, component)"/>
+ </cdk:body>
+ </div>
+ </div>
+ </div>
+ </div>
+ <script type="text/javascript">
+ new RichFaces.ui.AutoComplete("#{clientId}",
+ "#{clientId}Input", #{getScriptOptions(component)}
+ );
+ </script>
+ </div>
+ </cc:implementation>
+
+</cdk:root>
15 years, 9 months
JBoss Rich Faces SVN: r18655 - trunk/ui/core/api/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-16 07:52:42 -0400 (Mon, 16 Aug 2010)
New Revision: 18655
Modified:
trunk/ui/core/api/src/main/java/org/richfaces/component/LogMode.java
Log:
https://jira.jboss.org/browse/RF-7816
Modified: trunk/ui/core/api/src/main/java/org/richfaces/component/LogMode.java
===================================================================
--- trunk/ui/core/api/src/main/java/org/richfaces/component/LogMode.java 2010-08-16 11:52:10 UTC (rev 18654)
+++ trunk/ui/core/api/src/main/java/org/richfaces/component/LogMode.java 2010-08-16 11:52:42 UTC (rev 18655)
@@ -27,6 +27,7 @@
*/
public enum LogMode {
- popup, inline, console
+ popup, inline, console;
+ public static final LogMode DEFAULT = inline;
}
15 years, 9 months
JBoss Rich Faces SVN: r18654 - in trunk/examples/core-demo/src/main: webapp and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-16 07:52:10 -0400 (Mon, 16 Aug 2010)
New Revision: 18654
Added:
trunk/examples/core-demo/src/main/java/org/richfaces/demo/LogBean.java
Modified:
trunk/examples/core-demo/src/main/webapp/log.xhtml
Log:
https://jira.jboss.org/browse/RF-7816
Added: trunk/examples/core-demo/src/main/java/org/richfaces/demo/LogBean.java
===================================================================
--- trunk/examples/core-demo/src/main/java/org/richfaces/demo/LogBean.java (rev 0)
+++ trunk/examples/core-demo/src/main/java/org/richfaces/demo/LogBean.java 2010-08-16 11:52:10 UTC (rev 18654)
@@ -0,0 +1,57 @@
+/*
+ * 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.demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+
+import org.richfaces.component.LogMode;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class LogBean {
+
+ private LogMode mode = LogMode.inline;
+
+ private Character hotkey = 'l';
+
+ public LogMode getMode() {
+ return mode;
+ }
+
+ public void setMode(LogMode logMode) {
+ this.mode = logMode;
+ }
+
+ public Character getHotkey() {
+ return hotkey;
+ }
+
+ public void setHotkey(Character hotkey) {
+ this.hotkey = hotkey;
+ }
+
+}
Modified: trunk/examples/core-demo/src/main/webapp/log.xhtml
===================================================================
--- trunk/examples/core-demo/src/main/webapp/log.xhtml 2010-08-16 11:51:50 UTC (rev 18653)
+++ trunk/examples/core-demo/src/main/webapp/log.xhtml 2010-08-16 11:52:10 UTC (rev 18654)
@@ -8,14 +8,30 @@
<f:view>
<h:head>
<style>
- <!--
- .log{
- background: gray;
+ .log {
+ border: 2px dotted navy;
}
- -->
</style>
</h:head>
<h:body>
+ <h:form>
+ <h:panelGrid columns="2">
+ <h:outputText value="Mode: "/>
+ <h:selectOneMenu value="#{logBean.mode}" onchange="submit()">
+ <f:selectItem itemValue="popup" />
+ <f:selectItem itemValue="inline" />
+ </h:selectOneMenu>
+
+ <h:outputText value="Hotkey: "/>
+ <h:inputText value="#{logBean.hotkey}" size="1" onchange="submit()" />
+ </h:panelGrid>
+ </h:form>
+ <h:form>
+ <h:commandLink value="Fire ajax request">
+ <f:ajax />
+ </h:commandLink>
+ </h:form>
+
<input id="input" type="text" />
<select id="select" class="rich-log-element">
<option value="debug">debug</option>
@@ -24,7 +40,7 @@
<option value="error">error</option>
</select>
<input type="button" value="Log" onclick="eval('RichFaces.log.' + jQuery('#select').val() + '(\'' + jQuery('#input').val() + '\')')"/>
- <a4j:log level="debug" style="border: solid red 1px" styleClass="log"/>
+ <a4j:log level="debug" style="border: solid red 1px" styleClass="log" hotkey="#{logBean.hotkey}" mode="#{logBean.mode}" />
</h:body>
</f:view>
</html>
\ No newline at end of file
15 years, 9 months
JBoss Rich Faces SVN: r18653 - in trunk/ui/core/ui/src/main: resources/META-INF/resources/org.richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-16 07:51:50 -0400 (Mon, 16 Aug 2010)
New Revision: 18653
Added:
trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/LogRendererBase.java
Modified:
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
Log:
https://jira.jboss.org/browse/RF-7816
Added: trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/LogRendererBase.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/LogRendererBase.java (rev 0)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/renderkit/LogRendererBase.java 2010-08-16 11:51:50 UTC (rev 18653)
@@ -0,0 +1,42 @@
+/*
+ * 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 org.ajax4jsf.renderkit.RendererBase;
+import org.richfaces.component.LogMode;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class LogRendererBase extends RendererBase {
+
+ protected boolean isInline(Object attributeValue) {
+ LogMode mode = (LogMode) attributeValue;
+ if (mode == null) {
+ mode = LogMode.DEFAULT;
+ }
+
+ return mode == LogMode.inline;
+ }
+
+}
Modified: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss 2010-08-16 11:16:23 UTC (rev 18652)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss 2010-08-16 11:51:50 UTC (rev 18653)
@@ -1,14 +1,21 @@
.rf-log {
color: '#{richSkin.generalTextColor}';
- height: 300px;
- overflow: auto;
- width: 100%;
}
.rf-log-popup {
overflow: visible;
}
+.rf-log-popup-cnt {
+ display: none;
+}
+
+.rf-log-inline {
+ height: 300px;
+ overflow: auto;
+ width: 100%;
+}
+
.rf-log-contents {
font-family: monospace;
}
Modified: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2010-08-16 11:16:23 UTC (rev 18652)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2010-08-16 11:51:50 UTC (rev 18653)
@@ -169,9 +169,13 @@
},
init: function(options) {
+ this.$super.constructor.call(this, 'richfaces.log');
+ this.__initialLogImpl = richfaces.log;
+ richfaces.log = this;
+
this.level = options.level;
this.hotkey = options.hotkey;
- this.mode = options.mode;
+ this.mode = (options.mode || 'inline');
if (this.mode == 'popup') {
this.__boundHotkeyHandler = jquery.proxy(this.__hotkeyHandler, this);
@@ -182,6 +186,9 @@
},
destroy: function() {
+ richfaces.log = this.__initialLogImpl;
+ this.__initialLogImpl = null;
+
//TODO test this method
if (this.__popupWindow) {
this.__popupWindow.close();
Modified: trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
===================================================================
--- trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-08-16 11:16:23 UTC (rev 18652)
+++ trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-08-16 11:51:50 UTC (rev 18653)
@@ -6,15 +6,15 @@
<cc:interface>
<cdk:class>org.richfaces.renderkit.html.AjaxLogRenderer</cdk:class>
- <cdk:superclass>org.ajax4jsf.renderkit.RendererBase</cdk:superclass>
+ <cdk:superclass>org.richfaces.renderkit.LogRendererBase</cdk:superclass>
<cdk:component-family>org.richfaces.AjaxLog</cdk:component-family>
<cdk:renderer-type>org.richfaces.AjaxLogRenderer</cdk:renderer-type>
</cc:interface>
<cc:implementation>
- <div id="richfaces.log" class="rf-log #{component.attributes['styleClass']}">
+ <div id="richfaces.log" class="rf-log #{isInline(component.attributes['mode']) ? 'rf-log-inline' : 'rf-log-popup rf-log-popup-cnt'} #{component.attributes['styleClass']}">
<script type="text/javascript">
- RichFaces.log = new RichFaces.HtmlLog({
+ new RichFaces.HtmlLog({
level: "#{component.attributes['level']}",
hotkey: "#{component.attributes['hotkey']}",
mode: "#{component.attributes['mode']}"
15 years, 9 months
JBoss Rich Faces SVN: r18652 - in trunk/ui/core/ui/src/main: resources/META-INF/resources/org.richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-16 07:16:23 -0400 (Mon, 16 Aug 2010)
New Revision: 18652
Added:
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss
Removed:
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java
trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
Log:
https://jira.jboss.org/browse/RF-7816
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java 2010-08-16 10:48:28 UTC (rev 18651)
+++ trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractAjaxLog.java 2010-08-16 11:16:23 UTC (rev 18652)
@@ -41,8 +41,8 @@
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js") ,
@ResourceDependency(name = "richfaces-base-component.js") ,
- @ResourceDependency(library = "org.richfaces", name = "log.js"),
- @ResourceDependency(library = "org.richfaces", name = "log.css")
+ @ResourceDependency(library = "org.richfaces", name = "log.js"),
+ @ResourceDependency(library = "org.richfaces", name = "log.ecss")
})
@JsfComponent(
tag = @Tag(name = "log", type = TagType.Facelets),
Deleted: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css 2010-08-16 10:48:28 UTC (rev 18651)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css 2010-08-16 11:16:23 UTC (rev 18652)
@@ -1,10 +0,0 @@
-.rich-log {
- height: 300px;
- overflow: auto;
- width: 100%;
-}
-
-.rich-log-contents {
- font-family: monospace;
- font-size: 14px;
-}
Copied: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss (from rev 18650, trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.css)
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss (rev 0)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.ecss 2010-08-16 11:16:23 UTC (rev 18652)
@@ -0,0 +1,43 @@
+.rf-log {
+ color: '#{richSkin.generalTextColor}';
+ height: 300px;
+ overflow: auto;
+ width: 100%;
+}
+
+.rf-log-popup {
+ overflow: visible;
+}
+
+.rf-log-contents {
+ font-family: monospace;
+}
+
+.rf-log-entry-lbl {
+}
+
+.rf-log-entry-lbl-debug {
+ color: darkblue;
+}
+
+.rf-log-entry-lbl-info {
+ color: blue;
+}
+
+.rf-log-entry-lbl-warn {
+ color: gold;
+}
+
+.rf-log-entry-lbl-error {
+ color: red;
+}
+
+.rf-log-entry-msg {
+}
+
+.rf-log-entry-msg-debug, .rf-log-entry-msg-info, .rf-log-entry-msg-warn, .rf-log-entry-msg-error {
+}
+
+.rf-log-entry-msg-xml {
+ color: dimgray;
+}
\ No newline at end of file
Modified: trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js
===================================================================
--- trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2010-08-16 10:48:28 UTC (rev 18651)
+++ trunk/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/log.js 2010-08-16 11:16:23 UTC (rev 18652)
@@ -2,19 +2,67 @@
var logLevels = ['debug', 'info', 'warn', 'error'];
var logLevelsPadded = {'debug': 'debug', 'info': 'info ', 'warn': 'warn ', 'error': 'error'};
var logLevelValues = {'debug': 1, 'info': 2, 'warn': 3, 'error': 4};
- var logLevelColors = {'debug': 'darkblue', 'info': 'blue', 'warn': 'gold', 'error': 'red'};
var logClassMethods = {
+ __import: function(doc, node) {
+ if (doc === document) {
+ return node;
+ }
+
+ var result = jquery();
+ for (var i = 0; i < node.length; i++) {
+ if (doc.importNode) {
+ result = result.add(doc.importNode(node[i], true));
+ } else {
+ var container = doc.createElement("div");
+ container.innerHTML = node[i].outerHTML;
+ for (var child = container.firstChild; child; child = child.nextSibling) {
+ result = result.add(child);
+ }
+ }
+ }
+
+ return result;
+ },
+
+ __getStyles: function() {
+ var head = jQuery("head");
+
+ if (head.length == 0) {
+ return "";
+ }
+
+ try {
+ //TODO - BASE element support?
+ var clonedHead = head.clone();
+ if (clonedHead.children().length == head.children().length) {
+ return clonedHead.children(":not(style):not(link[rel='stylesheet'])").remove().end().html();
+ } else {
+ var result = new Array();
+ head.children("style, link[rel='stylesheet']").each(function() {
+ result.push(this.outerHTML);
+ });
+
+ return result.join('');
+ }
+ } catch (e) {
+ return "";
+ }
+ },
+
__openPopup: function() {
if (!this.__popupWindow || this.__popupWindow.closed) {
this.__popupWindow = open("", "_richfaces_logWindow", "height=400, width=600, resizable = yes, status=no, " +
"scrollbars = yes, statusbar=no, toolbar=no, menubar=no, location=no");
- this.__popupWindow.document.write("<html><head></head><body><div id='richfaces.log'></div></body></html>");
- this.__popupWindow.document.close();
- this.__consoleElement = jquery("#richfaces\\.log", this.__popupWindow.document);
- this.__initializeControls();
+ var doc = this.__popupWindow.document;
+
+ doc.write("<!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\"><head>" + this.__getStyles() + "</head>" +
+ "<body onunload='window.close()'><div id='richfaces.log' clas='rf-log rf-log-popup'></div></body></html>");
+ doc.close();
+ this.__initializeControls(doc);
} else {
this.__popupWindow.focus();
}
@@ -32,7 +80,7 @@
var date = new Date();
var timeString = this.__lzpad(date.getHours(), 2) + ':' + this.__lzpad(date.getMinutes(), 2) + ':' +
- this.__lzpad(date.getSeconds(), 2) + '.' + this.__lzpad(date.getMilliseconds(), 3);
+ this.__lzpad(date.getSeconds(), 2) + '.' + this.__lzpad(date.getMilliseconds(), 3);
return timeString;
},
@@ -55,54 +103,68 @@
this.setLevel(event.target.value);
},
- __initializeControls : function() {
- var console = this.__consoleElement;
-
- var clearBtn = console.children("button.rich-log-element");
+ __initializeControls : function(doc) {
+ var console = jquery("#richfaces\\.log", doc);
+
+ var clearBtn = console.children("button.rf-log-element");
if (clearBtn.length == 0) {
- clearBtn = jquery("<button type='button' class='rich-log-element'>Clear</button>").appendTo(console);
+ clearBtn = jquery("<button type='button' class='rf-log-element'>Clear</button>", doc).appendTo(console);
}
clearBtn.click(jquery.proxy(this.clear, this));
- var levelSelect = console.children("select.rich-log-element");
+ var levelSelect = console.children("select.rf-log-element");
if (levelSelect.length == 0) {
- levelSelect = jquery("<select class='rich-log-element' name='richfaces.log' />").appendTo(console);
+ levelSelect = jquery("<select class='rf-log-element' name='richfaces.log' />", doc).appendTo(console);
}
if (levelSelect.children().length == 0) {
for (var l = 0; l < logLevels.length; l++) {
- jquery("<option value='" + logLevels[l]+ "'>" + logLevels[l] + "</option>").appendTo(levelSelect);
+ jquery("<option value='" + logLevels[l]+ "'>" + logLevels[l] + "</option>", doc).appendTo(levelSelect);
}
}
levelSelect.val(this.getLevel());
levelSelect.change(jquery.proxy(this.__setLevelFromSelect, this));
- var consoleEntries = console.children(".rich-log-contents");
+ var consoleEntries = console.children(".rf-log-contents");
if (consoleEntries.length == 0) {
- consoleEntries = jquery("<div class='rich-log-contents'></div>").appendTo(console);
+ consoleEntries = jquery("<div class='rf-log-contents'></div>", doc).appendTo(console);
}
+ this.__contentsElement = consoleEntries;
},
+ __append: function(element) {
+ var target = this.__contentsElement;
+ if (this.mode == "popup") {
+ var doc = this.__popupWindow.document;
+ jquery(doc.createElement("div")).appendTo(target).append(this.__import(doc, element));
+ } else {
+ jquery(document.createElement("div")).appendTo(target).append(element);
+ }
+ },
+
__log: function(level, message) {
//TODO scroll to the added message
- if (!this.__consoleElement) {
+ //TODO check popup is opened
+ if (!this.__contentsElement) {
return;
}
- var console = this.__consoleElement;
-
if (logLevelValues[level] >= logLevelValues[this.getLevel()]) {
- var newEntry = jquery(document.createElement("div")).appendTo(console.children(".rich-log-contents"));
- jquery("<span style='color: " + logLevelColors[level] + "'></span>").appendTo(newEntry).text(this.__getMessagePrefix(level));
+ var newEntry = jquery();
+ newEntry = newEntry.add(jquery("<span class='rf-log-entry-lbl rf-log-entry-lbl-" + level + "'></span>").text(this.__getMessagePrefix(level)));
- var entrySpan = jquery(document.createElement("span")).appendTo(newEntry);
+ var entrySpan = jquery("<span class='rf-log-entry-msg rf-log-entry-msg-" + level + "'></span>");
if (typeof message != 'object' || !message.appendTo) {
entrySpan.text(message);
} else {
message.appendTo(entrySpan);
}
+
+ newEntry = newEntry.add(entrySpan);
+
+ this.__append(newEntry);
}
},
@@ -115,8 +177,7 @@
this.__boundHotkeyHandler = jquery.proxy(this.__hotkeyHandler, this);
jquery(document).bind('keydown', this.__boundHotkeyHandler);
} else {
- this.__consoleElement = jquery("#richfaces\\.log");
- this.__initializeControls();
+ this.__initializeControls(document);
}
},
@@ -127,10 +188,12 @@
}
this.__popupWindow = null;
- jquery(document).unbind('keydown', this.__boundHotkeyHandler);
- this.__boundHotkeyHandler = null;
+ if (this.__boundHotkeyHandler) {
+ jquery(document).unbind('keydown', this.__boundHotkeyHandler);
+ this.__boundHotkeyHandler = null;
+ }
- this.__consoleElement = null;
+ this.__contentsElement = null;
this.$super.destroy.call(this);
},
@@ -144,7 +207,9 @@
},
clear: function() {
- this.__consoleElement.children(".rich-log-contents").children().remove();
+ if (this.__contentsElement) {
+ this.__contentsElement.children().remove();
+ }
}
};
@@ -188,7 +253,7 @@
}
jQuery(document.createElement("br")).appendTo(logElement);
- jQuery("<span style='color:dimgray'></span>").appendTo(logElement).text(change.toXML());
+ jQuery("<span class='rf-log-entry-msg-xml'></span>").appendTo(logElement).text(change.toXML());
jQuery(document.createElement("br")).appendTo(logElement);
}
@@ -231,7 +296,7 @@
partialResponse = jQuery(responseXML).children("partial-response");
}
- var responseTextEntry = jQuery("<span>Server returned responseText: </span><span style='color:dimgray'></span>").eq(1).text(responseText).end();
+ var responseTextEntry = jQuery("<span>Server returned responseText: </span><span class='rf-log-entry-msg-xml'></span>").eq(1).text(responseText).end();
if (partialResponse && partialResponse.length) {
log.debug(responseTextEntry);
Modified: trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml
===================================================================
--- trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-08-16 10:48:28 UTC (rev 18651)
+++ trunk/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/log.template.xml 2010-08-16 11:16:23 UTC (rev 18652)
@@ -12,12 +12,13 @@
</cc:interface>
<cc:implementation>
- <div id="richfaces.log" class="rich-log #{component.attributes['styleClass']}">
+ <div id="richfaces.log" class="rf-log #{component.attributes['styleClass']}">
<script type="text/javascript">
RichFaces.log = new RichFaces.HtmlLog({
level: "#{component.attributes['level']}",
hotkey: "#{component.attributes['hotkey']}",
mode: "#{component.attributes['mode']}"
+ /* TODO: pass styleClass in */
});
</script>
</div>
15 years, 9 months