Skip to content

Commit

Permalink
Fix #633: add tags for all OmniFaces converters
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed May 10, 2024
1 parent fc11a01 commit f27f7d4
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
* <f:selectItems value="#{bean.availableEnums}" />
* </h:selectManyCheckbox>
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:genericEnumConverter&gt;</code> tag.
* <pre>
* &lt;h:selectManyCheckbox value="#{bean.selectedEnums}"&gt;
* &lt;f:selectItems value="#{bean.availableEnums}" /&gt;
* &lt;o:genericEnumConverter /&gt;
* &lt;/h:selectManyCheckbox&gt;
* </pre>
*
* <p><strong>See also</strong>:
* <br><a href="https://stackoverflow.com/q/3822058/157882">Use enum in &lt;h:selectManyCheckbox&gt;</a>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/omnifaces/converter/ImplicitNumberConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@
* &lt;/h:inputText&gt;
* &lt;/span&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:implicitNumberConverter&gt;</code> tag.
* <pre>
* &lt;span class="currency"&gt;
* &lt;span class="symbol"&gt;$&lt;/span&gt;
* &lt;h:inputText value="#{bean.price}"&gt;
* &lt;o:implicitNumberConverter type="currency" currencySymbol="$" /&gt;
* &lt;/h:inputText&gt;
* &lt;/span&gt;
* </pre>
*
* @author Bauke Scholtz
* @since 3.0
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/omnifaces/converter/ListConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
* &lt;o:converter converterId="omnifaces.ListConverter" list="#{bean.dualListModel.source}" /&gt;
* &lt;/p:pickList&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:listConverter&gt;</code> tag.
* <pre>
* &lt;p:pickList value="#{bean.dualListModel}" var="entity" itemValue="#{entity}" itemLabel="#{entity.someProperty}"&gt;
* &lt;o:listConverter" list="#{bean.dualListModel.source}" /&gt;
* &lt;/p:pickList&gt;
* </pre>
*
* <h2>Make sure that your entity has a good <code>toString()</code> implementation</h2>
* <p>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/omnifaces/converter/ListIndexConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
* &lt;o:converter converterId="omnifaces.ListIndexConverter" list="#{bean.dualListModel.source}" /&gt;
* &lt;/p:pickList&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:listIndexConverter&gt;</code> tag.
* <pre>
* &lt;p:pickList value="#{bean.dualListModel}" var="entity" itemValue="#{entity}" itemLabel="#{entity.someProperty}"&gt;
* &lt;o:listIndexConverter" list="#{bean.dualListModel.source}" /&gt;
* &lt;/p:pickList&gt;
* </pre>
*
* <h2>Pros and cons as compared to {@link ListConverter}</h2>
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
* &lt;f:selectItems value="#{bean.availableItems}" /&gt;
* &lt;/h:selectOneMenu&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:selectItemsConverter&gt;</code> tag.
* <pre>
* &lt;h:selectOneMenu value="#{bean.selectedItem}"&gt;
* &lt;f:selectItems value="#{bean.availableItems}" /&gt;
* &lt;o:selectItemsConverter /&gt;
* &lt;/h:selectOneMenu&gt;
* </pre>
*
* <h2>Make sure that your entity has a good <code>toString()</code> implementation</h2>
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
* &lt;f:selectItems value="#{bean.availableItems}" /&gt;
* &lt;/h:selectOneMenu&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:selectItemsIndexConverter&gt;</code> tag.
* <pre>
* &lt;h:selectOneMenu value="#{bean.selectedItem}"&gt;
* &lt;f:selectItems value="#{bean.availableItems}" /&gt;
* &lt;o:selectItemsIndexConverter /&gt;
* &lt;/h:selectOneMenu&gt;
* </pre>
*
* <h2>Pros and cons as compared to {@link SelectItemsConverter}</h2>
* <p>
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/org/omnifaces/converter/ToCollectionConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,26 @@
* &lt;h:inputText value="#{bean.commaSeparatedValues}" converter="omnifaces.ToCollectionConverter" /&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:toCollectionConverter&gt;</code> tag.
* <pre>
* &lt;h:inputText value="#{bean.commaSeparatedValues}"&gt;
* &lt;o:toCollectionConverter /&gt;
* &lt;/h:inputText&gt;
* </pre>
*
* <p>
* The default delimiter is comma followed by space <code>, </code> and the default collection type is
* <code>java.util.LinkedHashSet</code> for a <code>Set</code> property and <code>java.util.ArrayList</code> for anything
* else, and the default converter for each item will in <code>getAsString()</code> be determined based on item type and
* in <code>getAsObject()</code> be determined based on generic return type of the getter method.
* <p>
* You can use <code>&lt;o:converter&gt;</code> to specify those attributes. The <code>delimiter</code> must be a
* <code>String</code>, the <code>collectionType</code> must be a FQN and the <code>itemConverter</code> can be
* anything which is acceptable by {@link Faces#createConverter(Object)}.
* The <code>delimiter</code> must be a <code>String</code>, the <code>collectionType</code> must be a FQN and the
* <code>itemConverter</code> can be anything which is acceptable by {@link Faces#createConverter(Object)}.
* <pre>
* &lt;h:inputText value="#{bean.uniqueOrderedSemiColonSeparatedNumbers}"&gt;
* &lt;o:converter converterId="omnifaces.ToCollectionConverter"
* delimiter=";"
* collectionType="java.util.TreeSet"
* itemConverter="jakarta.faces.Integer" &gt;
* &lt;o:toCollectionConverter delimiter=";"
* collectionType="java.util.TreeSet"
* itemConverter="jakarta.faces.Integer" /&gt;
* &lt;/h:inputText&gt;
* </pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
* <pre>
* &lt;h:inputText value="#{bean.email}" converter="omnifaces.ToLowerCaseConverter" /&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:toLowerCaseConverter&gt;</code> tag.
* <pre>
* &lt;h:inputText value="#{bean.email}"&gt;
* &lt;o:toLowerCaseConverter /&gt;
* &lt;/h:inputText&gt;
* </pre>
*
* @author Bauke Scholtz
* @see TrimConverter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
* <pre>
* &lt;h:inputText value="#{bean.zipCode}" converter="omnifaces.ToUpperCaseConverter" /&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:toUpperCaseConverter&gt;</code> tag.
* <pre>
* &lt;h:inputText value="#{bean.zipCode}"&gt;
* &lt;o:toUpperCaseConverter /&gt;
* &lt;/h:inputText&gt;
* </pre>
*
* @author Bauke Scholtz
* @see TrimConverter
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/omnifaces/converter/TrimConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
* &lt;h:inputText value="#{bean.username}" converter="omnifaces.TrimConverter" /&gt;
* </pre>
* <p>
* Since OmniFaces 4.5 it's also available by <code>&lt;o:trimConverter&gt;</code> tag.
* <pre>
* &lt;h:inputText value="#{bean.username}"&gt;
* &lt;o:trimConverter /&gt;
* &lt;/h:inputText&gt;
* </pre>
* <p>
* You can also configure it application wide via below entry in <code>faces-config.xml</code> without the need to
* specify it in every single input component:
* <pre>
Expand Down
135 changes: 135 additions & 0 deletions src/main/resources/META-INF/omnifaces-ui.taglib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6516,4 +6516,139 @@ String name2 = Faces.getRequestParameter("name2"); // value2
<type>java.lang.Object</type>
</attribute>
</tag>

<tag>
<description><![CDATA[Automatically detects enum type in generic collections. See <a href="https://showcase.omnifaces.org/converters/GenericEnumConverter">GenericEnumConverter</a> showcase.]]></description>
<tag-name>genericEnumConverter</tag-name>
<converter>
<converter-id>omnifaces.GenericEnumConverter</converter-id>
</converter>
</tag>

<tag>
<description><![CDATA[Extends <code>NumberConverter</code> to automatically drop/imply currency and percent symbol. See <a href="https://showcase.omnifaces.org/converters/ImplicitNumberConverter">ImplicitNumberConverter</a> showcase.]]></description>
<tag-name>implicitNumberConverter</tag-name>
<converter>
<converter-id>omnifaces.ImplicitNumberConverter</converter-id>
</converter>
<attribute>
<description>Sets the number type to be used. Valid values are "currency" and "percent".</description>
<name>type</name>
<required>true</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description>Sets the ISO 4217 currency code when type="currency" is used. For example "USD".</description>
<name>currencyCode</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description>Sets the currency symbol when type="currency" is used without any currencyCode. For example "$".</description>
<name>currencySymbol</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description>Sets the locale to be used. When unspecified this defaults to view root locale.</description>
<name>locale</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
</tag>

<tag>
<description><![CDATA[Automatically converts based on <code>toString()</code> of given list items. See <a href="https://showcase.omnifaces.org/converters/ListConverter">ListConverter</a> showcase.]]></description>
<tag-name>listConverter</tag-name>
<converter>
<converter-id>omnifaces.ListConverter</converter-id>
</converter>
<attribute>
<description>Sets the list of available items.</description>
<name>list</name>
<required>true</required>
<type>java.util.List</type>
</attribute>
</tag>

<tag>
<description><![CDATA[Automatically converts based on index of given list items. See <a href="https://showcase.omnifaces.org/converters/ListIndexConverter">ListIndexConverter</a> showcase.]]></description>
<tag-name>listIndexConverter</tag-name>
<converter>
<converter-id>omnifaces.ListIndexConverter</converter-id>
</converter>
<attribute>
<description>Sets the list of available items.</description>
<name>list</name>
<required>true</required>
<type>java.util.List</type>
</attribute>
</tag>

<tag>
<description><![CDATA[Automatically converts based on <code>toString()</code> of <code>UISelectItem(s)</code> entries. See <a href="https://showcase.omnifaces.org/converters/SelectItemsConverter">SelectItemsConverter</a> showcase.]]></description>
<tag-name>selectItemsConverter</tag-name>
<converter>
<converter-id>omnifaces.SelectItemsConverter</converter-id>
</converter>
</tag>

<tag>
<description><![CDATA[Automatically converts based on index of <code>UISelectItem(s)</code> entries.See <a href="https://showcase.omnifaces.org/converters/SelectItemsIndexConverter">SelectItemsIndexConverter</a> showcase.]]></description>
<tag-name>selectItemsIndexConverter</tag-name>
<converter>
<converter-id>omnifaces.SelectItemsIndexConverter</converter-id>
</converter>
</tag>

<tag>
<description><![CDATA[Automatically converts between <code>String</code> and <code>Collection</code> based on delimiter. See <a href="https://showcase.omnifaces.org/converters/ToCollectionConverter">ToCollectionConverter</a> showcase.]]></description>
<tag-name>toCollectionConverter</tag-name>
<converter>
<converter-id>omnifaces.ToCollectionConverter</converter-id>
</converter>
<attribute>
<description>Sets the delimiter to split on.</description>
<name>delimiter</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description>Sets the FQN of the collection to create.</description>
<name>collectionType</name>
<required>false</required>
<type>java.lang.String</type>
</attribute>
<attribute>
<description>Sets the converter for the item.</description>
<name>itemConverter</name>
<required>false</required>
<type>java.lang.Object</type>
</attribute>
</tag>

<tag>
<description><![CDATA[Automatically lower cases entire <code>String</code>. See <a href="https://showcase.omnifaces.org/converters/ToLowerCaseConverter">ToLowerCaseConverter</a> showcase.]]></description>
<tag-name>toLowerCaseConverter</tag-name>
<converter>
<converter-id>omnifaces.ToLowerCaseConverter</converter-id>
</converter>
</tag>

<tag>
<description><![CDATA[Automatically upper cases entire <code>String</code>. See <a href="https://showcase.omnifaces.org/converters/ToUpperCaseConverter">ToUpperCaseConverter</a> showcase.]]></description>
<tag-name>toUpperCaseConverter</tag-name>
<converter>
<converter-id>omnifaces.ToUpperCaseConverter</converter-id>
</converter>
</tag>

<tag>
<description><![CDATA[Automatically trims entire <code>String</code>. See <a href="https://showcase.omnifaces.org/converters/TrimConverter">TrimConverter</a> showcase.]]></description>
<tag-name>trimConverter</tag-name>
<converter>
<converter-id>omnifaces.TrimConverter</converter-id>
</converter>
</tag>

</facelet-taglib>

0 comments on commit f27f7d4

Please sign in to comment.