Skip to content

Commit

Permalink
[FIXED JENKINS-11513] Add f:number for <input type="number />
Browse files Browse the repository at this point in the history
- Based on textbox.jelly
-- Attributes removed: autoCompleteField, autoCompleteDelimChar
  • Loading branch information
ohtake authored and kohsuke committed Nov 7, 2011
1 parent 92496f9 commit fd7b09c
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions core/src/main/resources/lib/form/number.jelly
@@ -0,0 +1,78 @@
<!--
The MIT License
Copyright (c) 2004-2011, Sun Microsystems, Inc., Kohsuke Kawaguchi, Yahoo! Inc., Andrew Bayer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:f="/lib/form">
<st:documentation>
Generates an input field <tt>&lt;input type="number" ... /></tt> to be
used inside &lt;f:entry/>

<st:attribute name="field">
Used for databinding. TBD.
</st:attribute>
<st:attribute name="name">
This becomes @name of the &lt;input> tag.
If @field is specified, this value is inferred from it.
</st:attribute>
<st:attribute name="value">
The initial value of the field. This becomes the @value of the &lt;input> tag.
If @field is specified, the current property from the "instance" object
will be set as the initial value automatically,
which is the recommended approach.
</st:attribute>
<st:attribute name="default">
The default value of the text box, in case both @value is and 'instance[field]' is null.
</st:attribute>
<!-- Tomcat doesn't like us using the attribute called 'class' -->
<st:attribute name="clazz">
Additional CSS class(es) to add (such as client-side validation clazz="required",
"number" or "positive-number"; these may be combined, as clazz="required number").
</st:attribute>
<st:attribute name="checkMessage">
Override the default error message when client-side validation fails,
as with clazz="required", etc.
</st:attribute>
<st:attribute name="checkUrl">
If specified, the value entered in this input field will be checked (via AJAX)
against this URL, and errors will be rendered under the text field.

If @field is specified, this will be inferred automatically,
which is the recommended approach.
</st:attribute>
</st:documentation>
<f:prepareDatabinding />

<!-- mostly pass-through all the attributes -->
<!--
Do not add 'number' class name by default.
INPUT.number (defined in hudson-behavior.js) is a class for integers.
On the other hand, HTML5 <input> permits floating-point numbers.
-->
<m:input xmlns:m="jelly:hudson.util.jelly.MorphTagLibrary"
class="setting-input ${attrs.checkUrl!=null?'validated':''} ${attrs.clazz}"
name="${attrs.name ?: '_.'+attrs.field}"
value="${attrs.value ?: instance[attrs.field] ?: attrs.default}"
type="number"
ATTRIBUTES="${attrs}" EXCEPT="field clazz" />
</j:jelly>

0 comments on commit fd7b09c

Please sign in to comment.