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 2025/01/14 13:51:32 UTC

(myfaces-tobago) branch main updated: demo: validateLongRange (#5908)

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/main by this push:
     new f46aa296b2 demo: validateLongRange (#5908)
f46aa296b2 is described below

commit f46aa296b2aaef93b267e4a591b96accf8214373
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Tue Jan 14 14:51:26 2025 +0100

    demo: validateLongRange (#5908)
---
 .../tobago/example/demo/ValidationController.java  | 10 ++++++++
 .../170-validation/00/Content_Validation.xhtml     | 30 ++++++++++++++++------
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ValidationController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ValidationController.java
index f960e7ab28..2fd749ca6d 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ValidationController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ValidationController.java
@@ -32,7 +32,9 @@ import java.io.Serializable;
 @RequestScoped
 @Named
 public class ValidationController implements Serializable {
+
   private String letter;
+  private Double floating;
 
   public String getLetter() {
     return letter;
@@ -42,6 +44,14 @@ public class ValidationController implements Serializable {
     this.letter = letter;
   }
 
+  public Double getFloating() {
+    return floating;
+  }
+
+  public void setFloating(Double floating) {
+    this.floating = floating;
+  }
+
   public void customValidator(final FacesContext facesContext, final UIComponent component, final Object value)
       throws ValidatorException {
     if (value == null) {
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/170-validation/00/Content_Validation.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/170-validation/00/Content_Validation.xhtml
index 679a8dd9cf..1de6efc514 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/170-validation/00/Content_Validation.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/170-validation/00/Content_Validation.xhtml
@@ -35,7 +35,7 @@
 
   <tc:section label="Required">
     <p>A simple way of validation is the <code>required</code> attribute in some input components.
-      The text area must not empty if the submit button is pressed. Otherwise a error message is displayed.</p>
+      The text area must not empty if the submit button is pressed. Otherwise, an error message is displayed.</p>
     <demo-highlight language="markup">&lt;tc:textarea label="Text Area" required="true"/></demo-highlight>
     <tc:form id="required">
       <tc:textarea id="textarea" label="Text Area" required="true"/>
@@ -59,21 +59,35 @@
     </tc:form>
   </tc:section>
 
-  <tc:section label="Validate Range">
-    <p>The range of a number can be validated via <code class="language-markup">&lt;f:validateLongRange/></code>
-      or - for floating point numbers - <code class="language-markup">&lt;f:validateDoubleRange/></code>.
-      In the following input field numbers from 3 to 77 can be added.</p>
+  <tc:section label="Validate Long Range">
+    <p>The range of an integer number can be validated via <code class="language-markup">&lt;f:validateLongRange/></code>.
+      In the following input field numbers from 3 to 77,777 can be added.</p>
     <demo-highlight language="markup">&lt;tc:in label="Number" markup="number">
-  &lt;f:validateLongRange minimum="3" maximum="77"/>
+  &lt;f:validateLongRange minimum="3" maximum="77777"/>
 &lt;/tc:in></demo-highlight>
     <tc:form id="validateRange">
-      <tc:in id="in_vr" label="Number" markup="number">
-        <f:validateLongRange minimum="3" maximum="77"/>
+      <tc:in id="in_vr" label="Integer" markup="number">
+        <f:validateLongRange minimum="3" maximum="77777"/>
       </tc:in>
       <tc:button id="submit_vr" label="Submit"/>
     </tc:form>
   </tc:section>
 
+  <tc:section label="Validate Double Range">
+    <p>The range of a floating point number can be validated via <code class="language-markup">&lt;f:validateDoubleRange/></code>.
+      In the following input field numbers from 0.01 to 999.99 can be added.</p>
+    <demo-highlight language="markup">&lt;tc:in label="Number" markup="number">
+  &lt;f:validateLongRange minimum="0.01" maximum="999.99"/>
+&lt;/tc:in></demo-highlight>
+    <tc:form id="validateDoubleRange">
+      <tc:in id="in_vdr" label="Floating Point" markup="number" value="#{validationController.floating}">
+        <f:validateDoubleRange minimum="0.01" maximum="999.99" />
+        <f:convertNumber maxFractionDigits="2"/>
+      </tc:in>
+      <tc:button id="submit_vdr" label="Submit"/>
+    </tc:form>
+  </tc:section>
+
   <tc:section label="Regex Validation">
     <p>A value can be validated against a regex patter via the
       <code class="language-markup">&lt;f:validateRegex/></code> tag.</p>