| <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| |
| --> |
| <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" |
| xmlns:f="http://java.sun.com/jsf/core" |
| xmlns:tr="http://myfaces.apache.org/trinidad" |
| xmlns:trdemo="http://myfaces.apache.org/trinidaddemo"> |
| <jsp:directive.page contentType="text/html;charset=utf-8"/> |
| <f:view> |
| <tr:document title="Client-side Converters and Validators"> |
| <tr:form usesUpload="true"> |
| <tr:panelPage> |
| <tr:messages/> |
| <f:facet name="navigationGlobal"> |
| <tr:navigationPane hint="buttons"> |
| <tr:commandNavigationItem text="Converters and Validators" |
| action="convertValidateDemos" |
| immediate="true"/> |
| </tr:navigationPane> |
| </f:facet> |
| <tr:panelHeader text="Client-side Converters and Validators"> |
| <tr:outputText styleClass="AFInstructionText" |
| value="In the following examples, converters and validators run on the client, avoiding a round trip."/> |
| <tr:spacer height="10"/> |
| <tr:panelHeader text="Client Converters"/> |
| <tr:panelFormLayout> |
| <tr:inputText value="#{clientValidation.integer}" |
| label="integer converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: 'a' or '11111111111'"/> |
| </f:facet> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.longValue}" |
| label="long converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: 'a' or '11111111111111111111'"/> |
| </f:facet> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.short}" |
| label="short converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: 'a' or '111111'"/> |
| </f:facet> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.byte}" |
| label="byte converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: 'a' or '1111'"/> |
| </f:facet> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.float}" |
| label="float converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: 'a' or 'cat'"/> |
| </f:facet> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.double}" |
| label="double converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: 'a' or 'cat'"/> |
| </f:facet> |
| </tr:inputText> |
| <!--tr:inputText value="#{clientValidation.double2}" |
| label="number converter"> |
| <f:facet name="help"> |
| <tr:outputText value="must have 2 decimal places, examples of unconvertable values: '1.1' or '1.111'"/> |
| </f:facet> |
| <f:convertNumber maxFractionDigits="2" minFractionDigits="2"/> |
| </tr:inputText--> |
| <tr:inputColor label="color converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: '9/05' or 'cat'"/> |
| </f:facet> |
| </tr:inputColor> |
| <tr:inputDate label="date converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: '#FFFF' or 'cat'"/> |
| </f:facet> |
| </tr:inputDate> |
| </tr:panelFormLayout> |
| <tr:panelHeader text="Client Validators"/> |
| <tr:spacer height="10"/> |
| <tr:panelFormLayout> |
| <tr:inputText value="#{clientValidation.long2}" |
| label="long range validator"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of values that will fail validation: '4' or '7'"/> |
| </f:facet> |
| <tr:validateLongRange minimum="5" maximum="6"/> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.double3}" |
| label="double range validator"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of values that will fail validation: '5.1' or '6.8'"/> |
| </f:facet> |
| <tr:validateDoubleRange minimum="5.2" maximum="6.7"/> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.regExpValue}" |
| label="reg exp validator"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of values that will fail validation: 1','2','4' all values other than '9'"/> |
| </f:facet> |
| <tr:validateRegExp pattern="[9]"/> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.lengthValue}" |
| label="length validator"> |
| <f:facet name="help"> |
| <tr:outputText value="values longer than 4 will fail, for example: '44444444' or 'Seven'"/> |
| </f:facet> |
| <tr:validateLength maximum="4"/> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.byteLengthValue}" |
| label="byte length validator"> |
| <f:facet name="help"> |
| <tr:outputText value="values longer than 4 bytes will fail, for example: '44444444' or 'Seven'"/> |
| </f:facet> |
| <tr:validateByteLength encoding="ISO-8859-1" maximum="4"/> |
| </tr:inputText> |
| <tr:inputText value="#{clientValidation.date}" |
| label="date range validator"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of values that will fail validation: any date which is not in 2007"/> |
| </f:facet> |
| <tr:validateDateTimeRange minimum="2007-01-01" |
| maximum="2007-12-31"/> |
| </tr:inputText> |
| <tr:inputDate id="mdf4" value="#{date.date1}" |
| label="min validation with minimum set to today (since midnight)" columns="50" required="true"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of values that will fail validation: any date earlier than today"/> |
| </f:facet> |
| <tr:convertDateTime pattern="yyyy-MM-dd hh:mm:ss a"/> |
| <tr:validateDateTimeRange minimum="#{date.todayFromMidnight}"/> |
| </tr:inputDate> |
| <tr:inputText id="mdf5" value="#{date.date2}" |
| label="date converter and a validator that sets a maximum date of tonight"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of values that will fail validation: any date later than tonight 11:59 PM"/> |
| </f:facet> |
| <tr:convertDateTime type="both"/> |
| <tr:validateDateTimeRange maximum="#{date.tonightNearMidnight}"/> |
| </tr:inputText> |
| </tr:panelFormLayout> |
| <tr:panelHeader text="Required"/> |
| <tr:spacer height="10"/> |
| <tr:panelFormLayout> |
| <tr:inputText required="true" label="required text"/> |
| <tr:selectOneRadio layout="vertical" label="required choice" required="true"> |
| <tr:selectItem value="true" label="Yes" /> |
| <tr:selectItem value="false" label="No" /> |
| </tr:selectOneRadio> |
| </tr:panelFormLayout> |
| <tr:panelHeader text="Example of 3rd party Converter and Validator"/> |
| <tr:spacer height="10"/> |
| <tr:panelFormLayout> |
| <tr:inputText value="#{clientValidation.ssn}" |
| label="ssn converter"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: 'a' or 'cat'"/> |
| </f:facet> |
| <trdemo:convertSSN/> |
| </tr:inputText> |
| <tr:inputText required="true" secret="true" |
| label="password validator"> |
| <f:facet name="help"> |
| <tr:outputText value="examples of unconvertable values: 'a' or 'cat'"/> |
| </f:facet> |
| <trdemo:validatePassword/> |
| </tr:inputText> |
| </tr:panelFormLayout> |
| </tr:panelHeader> |
| |
| <tr:panelButtonBar> |
| <tr:commandButton text="Submit"/> |
| </tr:panelButtonBar> |
| </tr:panelPage> |
| </tr:form> |
| </tr:document> |
| </f:view> |
| </jsp:root> |