Class FormBaseTag

    • Constructor Detail

      • FormBaseTag

        public FormBaseTag()
    • Method Detail

      • getIfName

        public String getIfName()
        Returns the ifName attribute.
        Specified by:
        getIfName in interface ConditionalTag
        Returns:
        the value of the ifName attribute
      • setIfName

        public void setIfName​(String s)
        Sets the value of the ifName attribute. This attribute is used by the mechanism for conditional execution. This method is called by jelly.
        Parameters:
        s - the attribute value
      • getUnlessName

        public String getUnlessName()
        Returns the unlessName attribute.
        Specified by:
        getUnlessName in interface ConditionalTag
        Returns:
        the value of the unlessName attribute
      • setUnlessName

        public void setUnlessName​(String s)
        Sets the value of the unlessName attribute. This attribute is used by the mechanism for conditional execution. This method is called by jelly.
        Parameters:
        s - the attribute value
      • doTag

        public void doTag​(org.apache.commons.jelly.XMLOutput output)
                   throws org.apache.commons.jelly.JellyTagException
        The main method of this tag class. This implementation checks if the tag can be executed (by calling canProcess(). If this is the case, control is passed to the process() method.
        Specified by:
        doTag in interface org.apache.commons.jelly.Tag
        Parameters:
        output - the output object (ignored because form builder tags do not produce any output)
        Throws:
        org.apache.commons.jelly.JellyTagException - if any exception occurs
      • getBuilderData

        public static ComponentBuilderData getBuilderData​(org.apache.commons.jelly.JellyContext context)
        Returns the current ComponentBuilderData object from the context.
        Parameters:
        context - the jelly context
        Returns:
        the builder data
      • canProcess

        public static boolean canProcess​(ConditionalTag tag)
        Tests if the specified conditional tag should be executed. This method determines based on the values of the ifName and unlessName attributes whether execution is allowed. If the ifName attribute is defined, execution is only allowed if the current builder's name exactly matches the attribute value. If the unlessName attribute is defined, then the tag is only executed if the current builder's name does not match the attribute's value. (If both attributes are defined, the ifName attribute takes precedence.)
        Parameters:
        tag - the tag
        Returns:
        a flag if the tag can be executed
      • getResourceText

        public static String getResourceText​(org.apache.commons.jelly.JellyContext context,
                                             Object resGrp,
                                             Object resId)
                                      throws FormBuilderRuntimeException
        Resolves the specified resource. This is a convenience method for builder components that support i11n.
        Parameters:
        context - the actual jelly context
        resGrp - the resource group
        resId - the resource ID
        Returns:
        the text of the resource
        Throws:
        FormBuilderRuntimeException - if the resource cannot be resolved
      • convertToClass

        public static Class<?> convertToClass​(Object clsObj)
                                       throws FormBuilderRuntimeException
        Helper method for converting attributes of type class. Jelly does not itself directly support class attributes, so this is handled by this helper method. The passed in object can either be directly of type class or it is interpreted as the name of a class. In the latter case the class name is resolved and the class object is returned.
        Parameters:
        clsObj - an object specifying a class
        Returns:
        the resolved class object
        Throws:
        FormBuilderRuntimeException - if the class cannot be resolved
      • convertToNumberWithUnit

        protected static NumberWithUnit convertToNumberWithUnit​(String s)
                                                         throws FormBuilderException
        Converts a string attribute into the corresponding number with unit. If this fails, an exception will be thrown.
        Parameters:
        s - the string
        Returns:
        the converted number (null if the string is undefined)
        Throws:
        FormBuilderException - if conversion fails
      • convertToNumberWithUnit

        protected static NumberWithUnit convertToNumberWithUnit​(String s,
                                                                NumberWithUnit defValue)
                                                         throws FormBuilderException
        Converts a string attribute into the corresponding NumberWithUnit returning the default value if the attribute has not been set. If the conversion fails, an exception is thrown.
        Parameters:
        s - the string to be converted
        defValue - the default value
        Returns:
        the converted number
        Throws:
        FormBuilderException - if conversion fails
      • canProcess

        protected boolean canProcess()
        Tests whether this tag should be executed. Evaluates the attributes for conditional execution.
        Returns:
        a flag if this tag should be executed
        See Also:
        canProcess(ConditionalTag)
      • findContainer

        public Composite findContainer()
        Tries to determine the container to which this component should be added. This implementation first looks for an enclosing <container> tag (i.e. a tag implementing the Composite interface. If this is found, the container object defined there is used (determined by the current ContainerSelector ). Otherwise the method assumes that the new component should be added to the top level container, which can be obtained from the builder data object.
        Returns:
        the container object
      • processBeforeBody

        protected void processBeforeBody()
                                  throws org.apache.commons.jelly.JellyTagException,
                                         FormBuilderException
        Performs processing of this tag before its body is evaluated. This can be necessary if some initialization has to be performed first which is required by nested tags. This method is automatically called by doTag(). This base implementation is left empty.
        Throws:
        org.apache.commons.jelly.JellyTagException - if a jelly specific error occurs
        FormBuilderException - if an error in the builder framework occurs
      • process

        protected abstract void process()
                                 throws org.apache.commons.jelly.JellyTagException,
                                        FormBuilderException
        Executes this tag. Here concrete sub classes must place their tag logic. This method is invoked by doTag() if execution is allowed.
        Throws:
        org.apache.commons.jelly.JellyTagException - if a jelly specific error occurs
        FormBuilderException - if an error in the builder framework occurs