<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- We need a doctype to allow us to use special characters like
We use a "strict" DTD to make IE follow the alignment rules. -->
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd">
<body class="container">
<h3>Primitives Translators</h3>
Tapestry's built-in translators also translate primitive types, eg. byte, short, int, etc; but because primitives cannot be null:
<ul>
<li>the default output will be <em>0</em>.</li>
<li>the field will attract cursor focus.</li>
<li>you will be <em>required</em> to input a value.</li>
</ul>
<div class="eg">
<t:form class="form-horizontal" t:id="inputs">
<div class="form-group">
<t:label for="byteValue" class="col-sm-2"/>
<div class="col-sm-2">
<t:textfield t:id="byteValue"/>
</div>
<div class="col-sm-2">
<p class="form-control-static">${byteValue}</p>
</div>
</div>
<div class="form-group">
<t:label for="shortValue" class="col-sm-2"/>
<div class="col-sm-2">
<t:textfield t:id="shortValue"/>
</div>
<div class="col-sm-2">
<p class="form-control-static">${shortValue}</p>
</div>
</div>
<div class="form-group">
<t:label for="integerValue" class="col-sm-2"/>
<div class="col-sm-2">
<t:textfield t:id="integerValue"/>
</div>
<div class="col-sm-2">
<p class="form-control-static">${integerValue}</p>
</div>
</div>
<div class="form-group">
<t:label for="longValue" class="col-sm-2"/>
<div class="col-sm-2">
<t:textfield t:id="longValue"/>
</div>
<div class="col-sm-2">
<p class="form-control-static">${longValue}</p>
</div>
</div>
<div class="form-group">
<t:label for="floatValue" class="col-sm-2"/>
<div class="col-sm-2">
<t:textfield t:id="floatValue"/>
</div>
<div class="col-sm-2">
<p class="form-control-static">${floatValue}</p>
</div>
</div>
<div class="form-group">
<t:label for="doubleValue" class="col-sm-2"/>
<div class="col-sm-2">
<t:textfield t:id="doubleValue"/>
</div>
<div class="col-sm-2">
<p class="form-control-static">${doubleValue}</p>
</div>
</div>
<div class="form-group">
<div class="col-sm-2 col-sm-offset-2">
<t:submit/>
</div>
</div>
</t:form>
</div>
References:
<a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/Translator.html">Translator</a>,
<a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/internal/translator/package-summary.html">translator package</a>,
<a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/TextField.html">TextField</a>,
<a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/PasswordField.html">PasswordField</a>,
<a href="http://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/TextArea.html">TextArea</a>.
<br/><br/>
<t:pagelink page="Index">Home</t:pagelink><br/><br/>
<t:tabgroup>
<t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/input/PrimitivesTranslators.tml"/>
<t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/input/PrimitivesTranslators.java"/>
<t:sourcecodetab src="/web/src/main/resources/META-INF/assets/css/examples/plain.css"/>
</t:tabgroup>
</body>
</html>