Class ErrorsTool


  • public class ErrorsTool
    extends ActionMessagesTool

    View tool to work with the Struts error messages.

     Template example(s):
       #if( $errors.exist() )
         <div class="errors">
         #foreach( $e in $errors.all )
           $e <br>
         #end
         </div>
       #end
    
     Toolbox configuration:
     <tool>
       <key>errors</key>
       <scope>request</scope>
       <class>org.apache.velocity.tools.struts.ErrorsTool</class>
     </tool>
     

    This tool should only be used in the request scope.

    Since VelocityTools 1.1, ErrorsTool extends ActionMessagesTool.

    Since:
    VelocityTools 1.0
    Version:
    $Id: ErrorsTool.java 479724 2006-11-27 18:49:37Z nbubna $
    Author:
    Gabe Sidler, Nathan Bubna
    • Constructor Detail

      • ErrorsTool

        public ErrorsTool()
    • Method Detail

      • init

        public void init​(java.lang.Object obj)
        Initializes this tool.
        Overrides:
        init in class ActionMessagesTool
        Parameters:
        obj - the current ViewContext
        Throws:
        java.lang.IllegalArgumentException - if the param is not a ViewContext
      • getMsgs

        public java.lang.String getMsgs()

        Renders the queued error messages as a list. This method expects the message keys errors.header and errors.footer in the message resources. The value of the former is rendered before the list of error messages and the value of the latter is rendered after the error messages.

        Returns:
        The formatted error messages. If no error messages are queued, an empty string is returned.
      • getMsgs

        public java.lang.String getMsgs​(java.lang.String property)

        Renders the queued error messages of a particual category as a list. This method expects the message keys errors.header and errors.footer in the message resources. The value of the former is rendered before the list of error messages and the value of the latter is rendered after the error messages.

        Parameters:
        property - the category of errors to render
        Returns:
        The formatted error messages. If no error messages are queued, an empty string is returned.
      • getMsgs

        public java.lang.String getMsgs​(java.lang.String property,
                                        java.lang.String bundle)

        Renders the queued error messages of a particual category as a list. This method expects the message keys errors.header and errors.footer in the message resources. The value of the former is rendered before the list of error messages and the value of the latter is rendered after the error messages.

        Parameters:
        property - the category of errors to render
        bundle - the message resource bundle to use
        Returns:
        The formatted error messages. If no error messages are queued, an empty string is returned.
        Since:
        VelocityTools 1.1