Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 // Copyright 2006, 2008 The Apache Software Foundation
 // Licensed 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
 // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.tapestry5;
Translates between client-side and server-side values. Client-side values are always strings.

public interface Translator<T>
Returns a unique name for the translator. This is used to identify the translator by name, but is also used when locating override messages for the translator.

unique name for the translator
    String getName();

Converts a server-side value to a client-side string. This allows for formatting of the value in a way appropriate to the end user. The output client value should be parsable by parseClient(org.apache.tapestry5.Field,java.lang.String,java.lang.String).

value the server side value (which will not be null)
client-side value to present to the user
    String toClient(T value);

Returns the type of the server-side value.

a type
    Class<T> getType();

Returns the message key, within the validation messages, normally used by this validator. This is used to provide the formatted message to parseClient(org.apache.tapestry5.Field,java.lang.String,java.lang.String) or render(org.apache.tapestry5.Field,java.lang.String,org.apache.tapestry5.MarkupWriter,

    String getMessageKey();

Converts a submitted request value into an appropriate server side value.

field for which a value is being parsed
clientValue to convert to a server value; this will not be null, but may be blank
message formatted validation message, either from validation messages, or from an override
equivalent server-side value (possibly null)
ValidationException if the value can not be parsed
    T parseClient(Field fieldString clientValueString messagethrows ValidationException;

Hook used by components to allow the validator to contribute additional attributes or (more often) client-side JavaScript (via the,java.lang.String,java.lang.String,java.lang.Object)).

field the field which is currently being rendered
message formatted validation message, either from validation messages, or from an override
writer markup writer, allowing additional attributes to be written into the active element
formSupport used to add JavaScript
    void render(Field fieldString messageMarkupWriter writer,
                FormSupport formSupport);
New to GrepCode? Check out our FAQ X