Author: ppitonak(a)redhat.com
Date: 2010-09-14 09:26:21 -0400 (Tue, 14 Sep 2010)
New Revision: 19193
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAutocompleteBean.java
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichAutocompleteBean.properties
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/autocomplete.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/list.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
Log:
https://jira.jboss.org/browse/RFPL-669
* autocomplete added to Metamer
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAutocompleteBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAutocompleteBean.java
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAutocompleteBean.java 2010-09-14
13:26:21 UTC (rev 19193)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.bean;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.ViewScoped;
+import org.richfaces.component.UIAutocomplete;
+
+import org.richfaces.tests.metamer.Attributes;
+import org.richfaces.tests.metamer.model.Capital;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for rich:autocomplete.
+ *
http://community.jboss.org/wiki/richfacesautocompletecomponentbehavior
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "richAutocompleteBean")
+@ViewScoped
+public class RichAutocompleteBean implements Serializable {
+
+ private static final long serialVersionUID = -1L;
+ private static Logger logger;
+ private Attributes attributes;
+ @ManagedProperty(value = "#{model.capitals}")
+ private List<Capital> capitals;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+
+ attributes = Attributes.getUIComponentAttributes(UIAutocomplete.class,
getClass());
+ attributes.setAttribute("mode", "cachedAjax");
+ attributes.setAttribute("rendered", true);
+
+
+ attributes.remove("autocompleteMethod");
+ attributes.remove("converter");
+ attributes.remove("itemConverter");
+
+ // these are hidden attributes
+ attributes.remove("autocompleteList");
+ attributes.remove("localValue");
+ attributes.remove("localValueSet");
+ attributes.remove("submittedValue");
+ attributes.remove("valid");
+ attributes.remove("validators");
+ attributes.remove("valueChangeListeners");
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+ public List<String> autocomplete(String prefix) {
+ ArrayList<String> result = new ArrayList<String>();
+ if (prefix.length() > 0) {
+ Iterator<Capital> iterator = capitals.iterator();
+ while (iterator.hasNext()) {
+ Capital elem = ((Capital) iterator.next());
+ if ((elem.getState() != null &&
elem.getState().toLowerCase().indexOf(prefix.toLowerCase()) == 0)
+ || "".equals(prefix)) {
+ result.add(elem.getState());
+ }
+ }
+ } else {
+ for (int i = 0; i < 10; i++) {
+ result.add(capitals.get(i).getState());
+ }
+ }
+ return result;
+ }
+
+ public void setCapitals(List<Capital> capitals) {
+ this.capitals = capitals;
+ }
+}
Property changes on:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichAutocompleteBean.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-09-14
13:24:47 UTC (rev 19192)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-09-14
13:26:21 UTC (rev 19193)
@@ -110,6 +110,7 @@
components.put("hDataTable", "JSF Data Table");
components.put("richAccordion", "Rich Accordion");
components.put("richAccordionItem", "Rich Accordion Item");
+ components.put("richAutocomplete", "Rich Autocomplete");
components.put("richColumn", "Rich Column");
components.put("richColumnGroup", "Rich Column Group");
components.put("richComponentControl", "Rich Component
Control");
Added:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichAutocompleteBean.properties
===================================================================
---
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichAutocompleteBean.properties
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/RichAutocompleteBean.properties 2010-09-14
13:26:21 UTC (rev 19193)
@@ -0,0 +1,4 @@
+attr.mode.client=client
+attr.mode.ajax=ajax
+attr.mode.cachedAjax=cachedAjax
+attr.mode.none=
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/autocomplete.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/autocomplete.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/autocomplete.xhtml 2010-09-14
13:26:21 UTC (rev 19193)
@@ -0,0 +1,115 @@
+<!--
+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.
+-->
+
+<!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:metamer="http://java.sun.com/jsf/composite/metamer"
+
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <rich:autocomplete id="autocomplete"
+
autofill="#{richAutocompleteBean.attributes['autofill'].value}"
+
autocompleteMethod="#{richAutocompleteBean.autocomplete}"
+
clientFilter="#{richAutocompleteBean.attributes['clientFilter'].value}"
+
converterMessage="#{richAutocompleteBean.attributes['converterMessage'].value}"
+
disabled="#{richAutocompleteBean.attributes['disabled'].value}"
+
fetchValue="#{richAutocompleteBean.attributes['fetchValue'].value}"
+
filterFunction="#{richAutocompleteBean.attributes['filterFunction'].value}"
+
immediate="#{richAutocompleteBean.attributes['immediate'].value}"
+
layout="#{richAutocompleteBean.attributes['layout'].value}"
+
minChars="#{richAutocompleteBean.attributes['minChars'].value}"
+
mode="#{richAutocompleteBean.attributes['mode'].value}"
+
onbeforedomupdate="#{richAutocompleteBean.attributes['onbeforedomupdate'].value}"
+
onbegin="#{richAutocompleteBean.attributes['onbegin'].value}"
+
onblur="#{richAutocompleteBean.attributes['onblur'].value}"
+
onchange="#{richAutocompleteBean.attributes['onchange'].value}"
+
onclick="#{richAutocompleteBean.attributes['onclick'].value}"
+
oncomplete="#{richAutocompleteBean.attributes['oncomplete'].value}"
+
ondblclick="#{richAutocompleteBean.attributes['ondblclick'].value}"
+
onerror="#{richAutocompleteBean.attributes['onerror'].value}"
+
onfocus="#{richAutocompleteBean.attributes['onfocus'].value}"
+
onkeydown="#{richAutocompleteBean.attributes['onkeydown'].value}"
+
onkeypress="#{richAutocompleteBean.attributes['onkeypress'].value}"
+
onkeyup="#{richAutocompleteBean.attributes['onkeyup'].value}"
+
onlistblur="#{richAutocompleteBean.attributes['onlistblur'].value}"
+
onlistclick="#{richAutocompleteBean.attributes['onlistclick'].value}"
+
onlistdblclick="#{richAutocompleteBean.attributes['onlistdblclick'].value}"
+
onlistfocus="#{richAutocompleteBean.attributes['onlistfocus'].value}"
+
onlistkeydown="#{richAutocompleteBean.attributes['onlistkeydown'].value}"
+
onlistkeypress="#{richAutocompleteBean.attributes['onlistkeypress'].value}"
+
onlistkeyup="#{richAutocompleteBean.attributes['onlistkeyup'].value}"
+
onlistmousedown="#{richAutocompleteBean.attributes['onlistmousedown'].value}"
+
onlistmousemove="#{richAutocompleteBean.attributes['onlistmousemove'].value}"
+
onlistmouseout="#{richAutocompleteBean.attributes['onlistmouseout'].value}"
+
onlistmouseover="#{richAutocompleteBean.attributes['onlistmouseover'].value}"
+
onlistmouseup="#{richAutocompleteBean.attributes['onlistmouseup'].value}"
+
onmousedown="#{richAutocompleteBean.attributes['onmousedown'].value}"
+
onmousemove="#{richAutocompleteBean.attributes['onmousemove'].value}"
+
onmouseout="#{richAutocompleteBean.attributes['onmouseout'].value}"
+
onmouseover="#{richAutocompleteBean.attributes['onmouseover'].value}"
+
onmouseup="#{richAutocompleteBean.attributes['onmouseup'].value}"
+
rendered="#{richAutocompleteBean.attributes['rendered'].value}"
+
required="#{richAutocompleteBean.attributes['required'].value}"
+
requiredMessage="#{richAutocompleteBean.attributes['requiredMessage'].value}"
+
selectFirst="#{richAutocompleteBean.attributes['selectFirst'].value}"
+
selectItemClass="#{richAutocompleteBean.attributes['selectItemClass'].value}"
+
showButton="#{richAutocompleteBean.attributes['showButton'].value}"
+
tokens="#{richAutocompleteBean.attributes['tokens'].value}"
+
validator="#{richAutocompleteBean.attributes['validator'].value}"
+
validatorMessage="#{richAutocompleteBean.attributes['validatorMessage'].value}"
+
value="#{richAutocompleteBean.attributes['value'].value}"
+
valueChangeListener="#{richAutocompleteBean.attributes['valueChangeListener'].value}"
+
var="#{richAutocompleteBean.attributes['var'].value}"
+ >
+
+ <ui:remove>
+ <!-- TODO enable as soon as event "select" is
implemented and add it to component above -->
+ <a4j:ajax id="autocompleteAjax" event="select"
render="output"/>
+ </ui:remove>
+ </rich:autocomplete>
+
+ <br/><br/>
+ <a4j:outputPanel id="outputPanel" layout="block">
+ Your selection: <h:outputText id="output"
value="#{richAutocompleteBean.attributes['value'].value}"/>
+ </a4j:outputPanel>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richAutocompleteBean.attributes}"
id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/list.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richAutocomplete/list.xhtml 2010-09-14
13:26:21 UTC (rev 19193)
@@ -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.
+-->
+
+<!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:ui="http://java.sun.com/jsf/facelets"
+
xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
+
+ <ui:composition template="/templates/list.xhtml">
+
+ <ui:define name="pageTitle">Rich Autocomplete</ui:define>
+
+ <ui:define name="links">
+
+ <metamer:testPageLink id="autocomplete"
outcome="autocomplete" value="Simple">
+ Simple page that contains <b>rich:autocomplete</b> (with
model containing capitals) and
+ input boxes for all its attributes.
+ </metamer:testPageLink>
+
+ </ui:define>
+
+ </ui:composition>
+
+</html>