You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2019/11/29 15:46:02 UTC
[myfaces-tobago] 11/19: Tobago-1999: demo page
This is an automated email from the ASF dual-hosted git repository.
weber pushed a commit to branch TOBAGO-1999_Select2
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit 0542bb88d21f0450ebdbfac5fd29f0130c4a45fe
Author: Volker Weber <v....@inexso.de>
AuthorDate: Mon Aug 26 15:18:30 2019 +0200
Tobago-1999: demo page
---
.../component/SelectManyBoxTagDeclaration.java | 7 +-
.../component/SelectOneChoiceTagDeclaration.java | 12 ++
.../internal/taglib/declaration/Select2.java | 8 +-
.../content/25-select/00-select2/select2.xhtml | 148 +++++++++++++++++++++
.../src/main/webapp/content/25-select/select.xhtml | 8 +-
.../tobago/renderkit/html/Select2Options.java | 10 ++
6 files changed, 184 insertions(+), 9 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyBoxTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyBoxTagDeclaration.java
index bea3ff0..9187f61 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyBoxTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyBoxTagDeclaration.java
@@ -32,6 +32,7 @@ import org.apache.myfaces.tobago.internal.taglib.declaration.HasId;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasLabel;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasMarkup;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasOnchange;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasPlaceholder;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasRequiredMessageForSelect;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasTabIndex;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasTip;
@@ -65,7 +66,7 @@ public interface SelectManyBoxTagDeclaration
IsReadonly, HasConverter, IsRequiredForSelect, HasMarkup, HasCurrentMarkup,
HasLabel, HasValidator, HasOnchange, HasValueChangeListener,
HasValidatorMessage, HasConverterMessage, HasRequiredMessageForSelect, HasTabIndex, IsFocus, IsGridLayoutComponent,
- Select2 {
+ Select2, HasPlaceholder {
/**
* The value of the multi select.
@@ -81,7 +82,7 @@ public interface SelectManyBoxTagDeclaration
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
- @UIComponentTagAttribute(type = "string", generate = false)
+ @UIComponentTagAttribute(generate = false)
void setTokenizer(String tokenizer);
/**
@@ -89,6 +90,6 @@ public interface SelectManyBoxTagDeclaration
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
- @UIComponentTagAttribute(type = "string", generate = false)
+ @UIComponentTagAttribute(generate = false)
void setTokenSeparators(String tokenSeparators);
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectOneChoiceTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectOneChoiceTagDeclaration.java
index 3748acd..b3ff946 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectOneChoiceTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectOneChoiceTagDeclaration.java
@@ -86,9 +86,21 @@ public interface SelectOneChoiceTagDeclaration
/**
* The minimum number of results required to display the search box.
+ *
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
@UIComponentTagAttribute(type = "int", defaultValue = "20", generate = false)
void setMinimumResultsForSearch(String disabled);
+
+ /**
+ * Displays a short text in the input field, that describes the meaning of this field.
+ * This is part of HTML 5, the theme should emulate the behaviour, when the browser doesn't support it.
+ *
+ * This is a select2 feature and will force select2=true
+ */
+ @TagAttribute()
+ @UIComponentTagAttribute
+ void setPlaceholder(String allowed);
+
}
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/Select2.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/Select2.java
index c27512c..b5506f6 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/Select2.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/declaration/Select2.java
@@ -7,6 +7,7 @@ public interface Select2 {
/**
* Flag indicating that this select provides support for clearable selections.
+ *
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
@@ -15,6 +16,7 @@ public interface Select2 {
/**
* Flag indicating that this select enables free text responses.
+ *
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
@@ -23,14 +25,16 @@ public interface Select2 {
/**
* Javascript callback to handle custom search matching
+ *
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
- @UIComponentTagAttribute(type = "string", generate = false)
+ @UIComponentTagAttribute(generate = false)
void setMatcher(String matcher);
/**
* Maximum number of characters that may be provided for a search term.
+ *
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
@@ -39,6 +43,7 @@ public interface Select2 {
/**
* Minimum number of characters required to start a search.
+ *
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
@@ -48,6 +53,7 @@ public interface Select2 {
/**
* The maximum number of items that may be selected in a multi-select control.
* If the value of this option is less than 1, the number of selected items will not be limited.
+ *
* This is a select2 feature and will force select2=true
*/
@TagAttribute()
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
new file mode 100644
index 0000000..7a6efab
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<ui:composition template="/WEB-INF/tags/layout/overview.xhtml"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:tx="http://myfaces.apache.org/tobago/extension"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+ <ui:param name="title" value="Select2 Controls"/>
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;auto;auto;*;auto"/>
+ </f:facet>
+
+ <tc:panel>
+ <tc:gridLayoutConstraint height="75px"/>
+ <f:facet name="layout">
+ <tc:flowLayout/>
+ </f:facet>
+ <tc:out value="Tobago integration of "/>
+ <tc:link label="https://select2.org" link="https://select2.org"/>
+ <tc:out value=" component features"/>
+
+
+ </tc:panel>
+
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;auto"/>
+ </f:facet>
+
+ <tc:separator label="SelectOneChoice"/>
+
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout columns="400px;1*"/>
+ </f:facet>
+
+ <tc:label value="No further options set" for="one_1"/>
+ <tc:selectOneChoice id="one_1"
+ value=""
+ select2="true">
+
+ <tc:selectItem itemLabel="Letter" itemValue="letter"/>
+ <tc:selectItem itemLabel="Phone" itemValue="phone"/>
+ <tc:selectItem itemLabel="eMail" itemValue="eMail"/>
+ <tc:selectItem itemLabel="Fax" itemValue="fax"/>
+ </tc:selectOneChoice>
+
+ <tc:label value="Suppressed filter input " for="one_2"/>
+ <tc:selectOneChoice id="one_2"
+ minimumResultsForSearch="10"
+ value=""
+ select2="true">
+
+ <tc:selectItem itemLabel="Letter" itemValue="letter"/>
+ <tc:selectItem itemLabel="Phone" itemValue="phone"/>
+ <tc:selectItem itemLabel="eMail" itemValue="eMail"/>
+ <tc:selectItem itemLabel="Fax" itemValue="fax"/>
+ </tc:selectOneChoice>
+
+ <tc:label value="Custom input allowed and clearabel" for="one_3"/>
+ <tc:selectOneChoice id="one_3"
+ allowCustom="true"
+ placeholder="Custom input allowed"
+ allowClear="true"
+ value=""
+ select2="true">
+
+ <tc:selectItem itemLabel="Letter" itemValue="letter"/>
+ <tc:selectItem itemLabel="Phone" itemValue="phone"/>
+ <tc:selectItem itemLabel="eMail" itemValue="eMail"/>
+ <tc:selectItem itemLabel="Fax" itemValue="fax"/>
+ </tc:selectOneChoice>
+
+ </tc:panel>
+ </tc:panel>
+
+
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout rows="auto;auto;auto"/>
+ </f:facet>
+
+ <tc:separator label="SelectManyBox"/>
+
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout columns="400px;1*" rows="45px"/>
+ </f:facet>
+
+ <tc:label value="No further options set" for="many_1"/>
+ <tc:selectManyBox id="many_1">
+ <f:selectItem itemValue="Phone" itemLabel="Phone"/>
+ <f:selectItem itemValue="eMail" itemLabel="eMail"/>
+ <f:selectItem itemValue="Mobile" itemLabel="Mobile"/>
+ <f:selectItem itemValue="Fax" itemLabel="Faxscimile"/>
+ </tc:selectManyBox>
+
+ </tc:panel>
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout columns="400px;1*" rows="45px"/>
+ </f:facet>
+
+ <tc:label value="Custom input allowed" for="many_2"/>
+ <tc:selectManyBox id="many_2"
+ placeholder="Custom input allowed"
+ allowCustom="true">
+ <f:selectItem itemValue="Phone" itemLabel="Phone"/>
+ <f:selectItem itemValue="eMail" itemLabel="eMail"/>
+ <f:selectItem itemValue="Mobile" itemLabel="Mobile"/>
+ <f:selectItem itemValue="Fax" itemLabel="Faxscimile"/>
+ </tc:selectManyBox>
+
+ </tc:panel>
+ </tc:panel>
+
+
+ <tc:panel/>
+
+ <tc:panel>
+ <f:facet name="layout">
+ <tc:gridLayout columns="*;auto"/>
+ </f:facet>
+ <tc:panel/>
+ <tc:button action="/content/25-select/select.xhtml" label="Submit"/>
+ </tc:panel>
+
+ </tc:panel>
+
+</ui:composition>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/select.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/select.xhtml
index 9b248bd..b315d6b 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/select.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/select.xhtml
@@ -47,12 +47,12 @@
</tc:selectBooleanCheckbox>
<!-- code-sniplet-start id="selectManyListbox" -->
- <tx:selectManyBox label="Select Many Box: ">
+ <tx:selectManyListbox label="Contact via: ">
<f:selectItem itemValue="Phone" itemLabel="Phone"/>
<f:selectItem itemValue="eMail" itemLabel="eMail"/>
<f:selectItem itemValue="Mobile" itemLabel="Mobile"/>
<f:selectItem itemValue="Fax" itemLabel="Faxscimile"/>
- </tx:selectManyBox>
+ </tx:selectManyListbox>
<tx:selectManyListbox label="Contact via: ">
<f:selectItem itemValue="Phone" itemLabel="Phone"/>
<f:selectItem itemValue="eMail" itemLabel="eMail"/>
@@ -66,9 +66,7 @@
<!-- code-sniplet-start id="selectOneChoice" -->
<tx:selectOneChoice value="selectOneChoice0"
- label="Select 2 single: "
- select2="true">
-
+ label="Contact me1: ">
<tc:selectItem itemLabel="Letter" itemValue="letter"/>
<tc:selectItem itemLabel="Phone" itemValue="phone"/>
<tc:selectItem itemLabel="eMail" itemValue="eMail"/>
diff --git a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Select2Options.java b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Select2Options.java
index ca3933d..54122b1 100644
--- a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Select2Options.java
+++ b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Select2Options.java
@@ -80,6 +80,11 @@ public class Select2Options {
options.setMaximumSelectionLength(select.getMaximumSelectionLength());
}
+ String placeholder = select.getPlaceholder();
+ if (placeholder != null && placeholder.length() > 0) {
+ options.setPlaceholder(placeholder);
+ }
+
return options;
}
@@ -119,6 +124,11 @@ public class Select2Options {
options.setMaximumSelectionLength(select.getMaximumSelectionLength());
}
+ String placeholder = select.getPlaceholder();
+ if (placeholder != null && placeholder.length() > 0) {
+ options.setPlaceholder(placeholder);
+ }
+
return options;
}