com.interface21.web.servlet.tags
Class BindStatus

java.lang.Object
  |
  +--com.interface21.web.servlet.tags.BindStatus

public class BindStatus
extends java.lang.Object

Simple adapter to expose status of a field or object. Set as a variable by the bind tag. Intended for use by JSP and JSTL expressions, and to allow for tag cooperation.

Obviously, object status representations do not have an expression and a value but only error codes and messages. For simplicity's sake and to be able to use the same tag, the same status class is used for both scenarios.

Author:
Rod Johnson, Juergen Hoeller

Constructor Summary
protected BindStatus(java.lang.String expression, java.lang.Object value, java.lang.String[] errorCodes, java.lang.String[] errorMessages)
          Create a new BindStatus instance, representing a field or object status.
 
Method Summary
 java.lang.String getDisplayValue()
          Return a suitable display value for the field, i.e. empty string instead of a null value.
 java.lang.String getErrorCode()
          Return the first error codes for the field or object, if any.
 java.lang.String[] getErrorCodes()
          Return the error codes for the field or object, if any.
 java.lang.String getErrorMessage()
          Return the first error message for the field or object, if any.
 java.lang.String[] getErrorMessages()
          Return the resolved error messages for the field or object, if any.
 java.lang.String getErrorMessagesAsString(java.lang.String delimiter)
          Return an error message string, concatenating all messages separated by the given delimiter.
 java.lang.String getExpression()
          Return a bind expression that can be used in HTML forms as input name for the respective field.
 java.lang.Object getValue()
          Return the current value of the field, either the property value or a rejected update.
 boolean isError()
          Return if this status represents a field or object error.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BindStatus

protected BindStatus(java.lang.String expression,
                     java.lang.Object value,
                     java.lang.String[] errorCodes,
                     java.lang.String[] errorMessages)
Create a new BindStatus instance, representing a field or object status.
Parameters:
expression - expression suitable for HTML input name
value - current field value
errorCodes - error codes for the field or object
errorMessages - resolved error messages for the field or object
Method Detail

getExpression

public java.lang.String getExpression()
Return a bind expression that can be used in HTML forms as input name for the respective field.

Returns a bind path appropriate for resubmission, e.g. "address.street". Note that the complete bind path as required by the bind tag is "customer.address.street", if bound to a "customer" bean.


getValue

public java.lang.Object getValue()
Return the current value of the field, either the property value or a rejected update.

getDisplayValue

public java.lang.String getDisplayValue()
Return a suitable display value for the field, i.e. empty string instead of a null value.

isError

public boolean isError()
Return if this status represents a field or object error.

getErrorCodes

public java.lang.String[] getErrorCodes()
Return the error codes for the field or object, if any. Returns an empty array instead of null if none.

getErrorCode

public java.lang.String getErrorCode()
Return the first error codes for the field or object, if any.

getErrorMessages

public java.lang.String[] getErrorMessages()
Return the resolved error messages for the field or object, if any. Returns an empty array instead of null if none.

getErrorMessage

public java.lang.String getErrorMessage()
Return the first error message for the field or object, if any.

getErrorMessagesAsString

public java.lang.String getErrorMessagesAsString(java.lang.String delimiter)
Return an error message string, concatenating all messages separated by the given delimiter.
Parameters:
delimiter - separator string, e.g. ", " or "
"
Returns:
the error message string

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Rod Johnson and Spring contributors 2001-2003.