[richfaces-svn-commits] JBoss Rich Faces SVN: r18657 - in trunk/examples/input-demo/src/main: java/org/richfaces/demo and 2 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Aug 16 08:48:15 EDT 2010


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
+ *
+ */
+ at ManagedBean
+ at 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
+ *
+ */
+ at ManagedBean(eager = true)
+ at 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> &nbsp;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>



More information about the richfaces-svn-commits mailing list