You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2010/06/22 10:13:57 UTC
svn commit: r956809 - in /myfaces/tobago/trunk/tobago-example:
tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/
tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/
tobago-example-demo/src/main/web...
Author: lofwyr
Date: Tue Jun 22 08:13:56 2010
New Revision: 956809
URL: http://svn.apache.org/viewvc?rev=956809&view=rev
Log:
clean up input suggest example
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/OverviewController.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/overview/basic.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview_de.properties.xml
myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java?rev=956809&r1=956808&r2=956809&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-data/src/main/java/org/apache/myfaces/tobago/example/data/LocaleList.java Tue Jun 22 08:13:56 2010
@@ -17,16 +17,46 @@ package org.apache.myfaces.tobago.exampl
* limitations under the License.
*/
+import org.apache.commons.lang.StringUtils;
+
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
import java.util.Locale;
+import java.util.Set;
+
+public class LocaleList {
+
+ public static final List<LocaleEntry> DATA;
-public class LocaleList extends ArrayList<LocaleEntry> {
+ public static final List<String> COUNTRY_LANGUAGE;
- {
+ static {
+ List<LocaleEntry> init = new ArrayList<LocaleEntry>();
for (Locale displayLocale : Locale.getAvailableLocales()) {
for (Locale locale : Locale.getAvailableLocales()) {
- add(new LocaleEntry(locale, displayLocale));
+ init.add(new LocaleEntry(locale, displayLocale));
}
}
+ DATA = Collections.unmodifiableList(init);
+ }
+
+ static {
+ Set<String> init = new HashSet<String>();
+ for (LocaleEntry localeEntry : DATA) {
+ if (StringUtils.isNotBlank(localeEntry.getCountry())
+ && StringUtils.isNotBlank(localeEntry.getLanguage())) {
+ final String name = localeEntry.getCountry() + " (" + localeEntry.getLanguage() + ")";
+ init.add(name);
+ }
+ }
+ final ArrayList<String> list = new ArrayList<String>(init);
+ Collections.sort(list);
+ COUNTRY_LANGUAGE = Collections.unmodifiableList(list);
+ }
+
+ private LocaleList() {
+ // do not call
}
}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/OverviewController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/OverviewController.java?rev=956809&r1=956808&r2=956809&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/OverviewController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/overview/OverviewController.java Tue Jun 22 08:13:56 2010
@@ -17,11 +17,14 @@ package org.apache.myfaces.tobago.exampl
* limitations under the License.
*/
+import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.tobago.component.UISheet;
import org.apache.myfaces.tobago.component.UIToolBar;
import org.apache.myfaces.tobago.context.ResourceManager;
import org.apache.myfaces.tobago.context.ResourceManagerFactory;
import org.apache.myfaces.tobago.event.SortActionEvent;
+import org.apache.myfaces.tobago.example.data.LocaleEntry;
+import org.apache.myfaces.tobago.example.data.LocaleList;
import org.apache.myfaces.tobago.example.data.Salutation;
import org.apache.myfaces.tobago.example.data.SolarObject;
import org.apache.myfaces.tobago.model.SelectItem;
@@ -67,6 +70,8 @@ public class OverviewController {
private String basicInput = "";
+ private String suggestInput;
+
private String basicArea = "";
private Date basicDate = new Date();
@@ -340,6 +345,14 @@ public class OverviewController {
this.basicInput = basicInput;
}
+ public String getSuggestInput() {
+ return suggestInput;
+ }
+
+ public void setSuggestInput(String suggestInput) {
+ this.suggestInput = suggestInput;
+ }
+
public String getBasicArea() {
return basicArea;
}
@@ -403,11 +416,16 @@ public class OverviewController {
public List<String> getInputSuggestItems(UIInput component) {
String prefix = (String) component.getSubmittedValue();
LOG.info("Creating items for prefix: '" + prefix + "'");
- List<String> li = new ArrayList<String>();
- for (int i = 1; i <= 6; i++) {
- li.add(prefix + i);
+ List<String> result = new ArrayList<String>();
+ for (String name : LocaleList.COUNTRY_LANGUAGE) {
+ if (StringUtils.startsWithIgnoreCase(name, prefix)) {
+ result.add(name);
+ }
+ if (result.size() > 100) { // this value should be greater than the value of the input control
+ break;
+ }
}
- return li;
+ return result;
}
public String noop() {
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/overview/basic.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/overview/basic.xhtml?rev=956809&r1=956808&r2=956809&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/overview/basic.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/overview/basic.xhtml Tue Jun 22 08:13:56 2010
@@ -32,7 +32,7 @@
</f:facet>
-->
<f:facet name="layout">
- <tc:gridLayout rows="fixed;fixed;*;*;fixed;*;*;fixed;*;*"/>
+ <tc:gridLayout rows="fixed;fixed;2*;3*;fixed;2*;2*;fixed;2*;2*"/>
<!--<tc:gridLayout border="0" rows="*;*;*;*;*;*;*;*;*;*"/>-->
</f:facet>
@@ -53,17 +53,19 @@
<tc:panel>
<f:facet name="layout">
- <tc:gridLayout rows="fixed;fixed;fixed"/>
+ <tc:gridLayout rows="fixed;fixed;fixed;fixed"/>
</f:facet>
<tx:in value="#{overviewController.basicInput}" required="true" tabIndex="1"
- label="#{overviewBundle.basic_textboxLabel}" tip="test"
+ label="#{overviewBundle.basic_textboxLabel}" tip="#{overviewBundle.basic_textboxTip}"/>
+ <tx:in value="#{overviewController.suggestInput}" tabIndex="3"
+ label="#{overviewBundle.basic_suggestLabel}" tip="#{overviewBundle.basic_suggestTip}"
suggestMethod="#{overviewController.getInputSuggestItems}"/>
- <tx:date value="#{overviewController.basicDate}" tabIndex="3"
+ <tx:date value="#{overviewController.basicDate}" tabIndex="4"
label="#{overviewBundle.basic_dateLabel}" required="true">
<f:convertDateTime pattern="dd/MM/yyyy"/>
<tc:validateSubmittedValueLength maximum="10"/>
</tx:date>
- <tx:time label="#{overviewBundle.basic_timeLabel}" tabIndex="4"
+ <tx:time label="#{overviewBundle.basic_timeLabel}" tabIndex="5"
value="#{overviewController.basicTime}"/>
</tc:panel>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml?rev=956809&r1=956808&r2=956809&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview.properties.xml Tue Jun 22 08:13:56 2010
@@ -110,6 +110,9 @@
<entry key="basic_itemMr">Mr.</entry>
<entry key="basic_itemMrs">Mrs.</entry>
<entry key="basic_textboxLabel">Inputfield</entry>
+ <entry key="basic_textboxTip">A simple input field</entry>
+ <entry key="basic_suggestLabel">Suggest (AJAX)</entry>
+ <entry key="basic_suggestTip">Please type in "po" for example</entry>
<entry key="basic_dateLabel">Date</entry>
<entry key="basic_timeLabel">Time</entry>
<entry key="basic_textareaLabel">Textarea</entry>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview_de.properties.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview_de.properties.xml?rev=956809&r1=956808&r2=956809&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview_de.properties.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/tobago-resource/html/standard/standard/property/overview_de.properties.xml Tue Jun 22 08:13:56 2010
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -84,6 +84,9 @@
<entry key="basic_itemMr">Herr</entry>
<entry key="basic_itemMrs">Frau</entry>
<entry key="basic_textboxLabel">Eingabefeld</entry>
+ <entry key="basic_textboxTip">Ein einfaches Eingabefeld</entry>
+ <entry key="basic_suggestLabel">Vorschlag (AJAX)</entry>
+ <entry key="basic_suggestTip">Bitte geben Sie beispielsweise "po" ein</entry>
<entry key="basic_dateLabel">Datum</entry>
<entry key="basic_timeLabel">Uhrzeit</entry>
<entry key="basic_textareaLabel">Textfeld</entry>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java?rev=956809&r1=956808&r2=956809&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-test/src/main/java/org/apache/myfaces/tobago/example/test/SheetController.java Tue Jun 22 08:13:56 2010
@@ -17,20 +17,25 @@ package org.apache.myfaces.tobago.exampl
* limitations under the License.
*/
+import org.apache.myfaces.tobago.example.data.LocaleEntry;
import org.apache.myfaces.tobago.example.data.LocaleList;
import org.apache.myfaces.tobago.example.data.SolarObject;
+import java.util.ArrayList;
+import java.util.List;
+
public class SheetController {
private SolarObject[] solarArray = SolarObject.getArray();
- private LocaleList localeList = new LocaleList();
+ // Create a copy for sorting, because the LocaleList.DATA is not modifiable.
+ private List<LocaleEntry> localeList = new ArrayList<LocaleEntry>(LocaleList.DATA);
public SolarObject[] getSolarArray() {
return solarArray;
}
- public LocaleList getLocaleList() {
+ public List<LocaleEntry> getLocaleList() {
return localeList;
}
}