Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Seam UI JSF2 support 2.3.0.Final
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.seam.ui.validator
Class FormattedTextValidator

    java.lang.Object
      org.jboss.seam.ui.validator.FormattedTextValidator

All Implemented Interfaces:
  Serializable, EventListener, javax.faces.validator.Validator

    public class FormattedTextValidator

extends Object
implements javax.faces.validator.Validator, Serializable

Formatted Text validator Use as a JSF validator on an input control that allows entering Seam Text markup.

The Seam Text parser has a disabled default error handler, catch exceptions as appropriate if you display Seam Text (see http://www.doc.ic.ac.uk/lab/secondyear/Antlr/err.html) and call the static convenience method `FormattedTextValidator.getErrorMessage(originalText, recognitionException)` if you want to display or log a nice error message.

Uses an instance of `SeamTextParser` by default, override if you require validation with your customized instance of `SeamTextParser`.

Author:
  matthew.drees, Christian Bauer
See Also:
  Serialized Form

Field Summary

Fields inherited from interface javax.faces.validator.Validator
`NOT_IN_RANGE_MESSAGE_ID`

Constructor Summary
`FormattedTextValidator()`

Method Summary
`static String` | `getErrorLocation(String originalText, antlr.RecognitionException re, int charsBefore, int charsAfter)` Extracts the error from the `RecognitionException` and generates a location of the error by extracting the original text at the exceptions line and column.
`static String` | `getErrorMessage(String originalText, antlr.RecognitionException re)` Extracts the error from the `RecognitionException` and generates a message including the location of the error.
`String` | `getMismatchedTokenErrorMessage(String originalMessage, String location)` Override (e.g.
`String` | `getNoViableAltErrorMessage(String originalMessage, String location)` Override (e.g.
`int` | `getNumberOfCharsAfterErrorLocation()`
`int` | `getNumberOfCharsBeforeErrorLocation()`
`String` | `getParserErrorMessage(String originalText, antlr.RecognitionException re)`
`org.jboss.seam.text.SeamTextParser` | `getSeamTextParser(String text)` Override to instantiate a custom `SeamTextLexer` and `SeamTextParser`.
`String` | `getSemanticErrorMessage(String originalMessage)` Override (e.g.
`void` | `validate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, Object value)` Validate the given value as well-formed Seam Text.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### FormattedTextValidator

    public FormattedTextValidator()

Method Detail

### validate

    public void validate(javax.faces.context.FacesContext context,
                         javax.faces.component.UIComponent component,
                         Object value)
                  throws javax.faces.validator.ValidatorException

  Validate the given value as well-formed Seam Text. If there are parse errors, throw a ValidatorException including the first parse error.

  Specified by:
    `validate` in interface `javax.faces.validator.Validator`
  Throws:
    `javax.faces.validator.ValidatorException`

### getSeamTextParser

    public org.jboss.seam.text.SeamTextParser getSeamTextParser(String text)

  Override to instantiate a custom `SeamTextLexer` and `SeamTextParser`.

  Parameters:
    `text` - the raw markup text
  Returns:
    an instance of `SeamTextParser`

### getParserErrorMessage

    public String getParserErrorMessage(String originalText,
                                        antlr.RecognitionException re)

### getNumberOfCharsBeforeErrorLocation

    public int getNumberOfCharsBeforeErrorLocation()

### getNumberOfCharsAfterErrorLocation

    public int getNumberOfCharsAfterErrorLocation()

### getNoViableAltErrorMessage

    public String getNoViableAltErrorMessage(String originalMessage,
                                             String location)

  Override (e.g. for i18n) ANTLR parser error messages.

  Parameters:
    `originalMessage` - the ANTLR parser error message of the RecognitionException
    `location` - a snippet that indicates the location in the original markup, might be null
  Returns:
    a message that is thrown by this validator

### getMismatchedTokenErrorMessage

    public String getMismatchedTokenErrorMessage(String originalMessage,
                                                 String location)

  Override (e.g. for i18n) ANTLR parser error messages.

  Parameters:
    `originalMessage` - the ANTLR parser error message of the RecognitionException
    `location` - a snippet that indicates the location in the original markup, might be null
  Returns:
    a message that is thrown by this validator

### getSemanticErrorMessage

    public String getSemanticErrorMessage(String originalMessage)

  Override (e.g. for i18n) ANTLR parser error messages.

  Parameters:
    `originalMessage` - the ANTLR parser error message of the RecognitionException
  Returns:
    a message that is thrown by this validator

### getErrorLocation

    public static String getErrorLocation(String originalText,
                                          antlr.RecognitionException re,
                                          int charsBefore,
                                          int charsAfter)

  Extracts the error from the `RecognitionException` and generates a location of the error by extracting the original text at the exceptions line and column.

  Parameters:
    `originalText` - the original Seam Text markup as fed into the parser
    `re` - an ANTLR `RecognitionException` thrown by the parser
    `charsBefore` - characters before error location included in message
    `charsAfter` - characters after error location included in message
  Returns:
    an error message with some helpful context about where the error occured

### getErrorMessage

    public static String getErrorMessage(String originalText,
                                         antlr.RecognitionException re)

  Extracts the error from the `RecognitionException` and generates a message including the location of the error.

  Parameters:
    `originalText` - the original Seam Text markup as fed into the parser
    `re` - an ANTLR `RecognitionException` thrown by the parser
  Returns:
    an error message with some helpful context about where the error occured

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Seam UI JSF2 support 2.3.0.Final
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012 Seam Framework. All Rights Reserved.