Lukasz Lenart created WW-5811:
---------------------------------

             Summary: Derive HTML5 min/max constraints for temporal controls 
from DateRangeFieldValidator
                 Key: WW-5811
                 URL: https://issues.apache.org/jira/browse/WW-5811
             Project: Struts 2
          Issue Type: Improvement
          Components: Core Tags
            Reporter: Lukasz Lenart


h2. Problem

HTML5 constraint derivation ({{struts.ui.html5.constraints}}) maps range 
validators to {{min}}/{{max}} only for {{number}} and {{range}} controls. 
{{HtmlControlType.supportsRange()}} already includes the temporal controls 
({{date}}, {{month}}, {{week}}, {{time}}, {{datetime-local}}), but 
{{StrutsHtmlConstraintProvider}} deliberately skips them, because their 
{{min}}/{{max}} values need per-control ISO formatting. As a result, 
{{DateRangeFieldValidator}} emits nothing.

This affects {{textfield type="date"}} (and the other temporal types) today, 
and {{datetextfield}} once WW-5778 makes it a {{date}} control in the html5 
theme.

h2. Proposal

In {{StrutsHtmlConstraintProvider}}, map {{DateRangeFieldValidator}} min/max to 
{{min}}/{{max}} for temporal controls, formatted per control:
* {{date}} → {{yyyy-MM-dd}}
* {{month}} → {{yyyy-MM}}
* {{week}} → {{YYYY-'W'ww}} (ISO week-based year)
* {{time}} → {{HH:mm}} (or {{HH:mm:ss}})
* {{datetime-local}} → {{yyyy-MM-dd'T'HH:mm}}

Requirements:
* Format the bounds the same way the server compares them, so the browser never 
rejects a value the server accepts (time zone and truncation for 
{{java.util.Date}} bounds)
* Skip the attribute for controls/value types that cannot be represented 
exactly, as the numeric path does for fractional {{min}}
* Tests for each temporal control and the tag reference updated

Related: WW-5778 (datetextfield in the html5 theme), WW-5810 (java.time support 
in datetextfield)



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to