[Opensource] Solution fix for TranistionTag

Kris Thompson kris.thompson at seurat.com
Fri Jul 12 08:54:24 PDT 2002


I am trying to create the following input string with the TransitionTag;

<input type="button" class="goButton" value="Sign-in">

Problem is that the TransitionTag does not have a method for passing in 
in the class value.... but now it does!  Attached is the update 
TransitionTag and the the snipit of the expresso.tld file change need to 
make this happen.  

Could someone please add this to CVS?

Thanks

Kris Thompson


Expresso.tld (snipit)

<tag>

        <name>TransitionTag</name>

        <tagclass>com.jcorporate.expresso.ext.taglib.TransitionTag</tagclass>

        <bodycontent>empty</bodycontent>

        <info>A tag to display an Expresso Transition Button</info>

        <attribute>

            <name>name</name>

            <required>true</required>

            <rtexprvalue>true</rtexprvalue>

        </attribute>

        <attribute>

            <name>value</name>

            <required>false</required>

            <rtexprvalue>true</rtexprvalue>

        </attribute>

        <attribute>

            <name>classvalue</name>

            <required>false</required>

            <rtexprvalue>true</rtexprvalue>

        </attribute>

        <attribute>

            <name>response</name>

            <required>false</required>

            <rtexprvalue>true</rtexprvalue>

        </attribute>

    </tag>

TransitionTag.java (complete)

package com.jcorporate.expresso.ext.taglib;

/**

 * ActionTag.java

 *

 * Copyright 2001 Jcorporate Ltd.

 */

import javax.servlet.jsp.tagext.*;

import javax.servlet.jsp.*;

import java.io.IOException;

import com.jcorporate.expresso.core.controller.*;

/**

 * Title:        ActionTag

 * Description:  The ActionTag renders an Expresso Action item in HTML

 *               as a submit button.

 * Company:      PlatinumSolutions

 * Date Created: 02/09/2001

 *

 * @version     $Revision: 1.1.1.1 $      $Date: 2002/06/13 21:04:00 $

 * @author      Adam Rossi

 */

public class TransitionTag extends ExpressoTagSupport {

    private Transition oneTransition = null;

    private java.lang.String name = null;

    private java.lang.String value = null;

    private java.lang.String classValue = null;

    private java.lang.String nameToUse = null;

    private java.lang.String valueToUse = null;

    private java.lang.String classValueToUse = null;

    /**

     *

     */

    public TransitionTag() {

        super();

    } /* TransitionTag() */

    /**

     * Standard doEndTag.

     *

     * @throws  javax.servlet.jsp.JspTagException

     * @return  int

     */

    public int doEndTag() throws javax.servlet.jsp.JspTagException {

        nameToUse = name;

        valueToUse = value;

        classValueToUse = classValue;

        getControllerResponse();

        try {

            Tag container = getContainer();

            if (container == null) {

                oneTransition = ctlrResp.getTransition(name);

            } else {

                if (container instanceof ElementIterator) {

                    oneTransition = (Transition) ((ElementIterator)container).getElement();

                    nameToUse = oneTransition.getName();

                } else if (container instanceof BlockTag) {

                    oneTransition = (Transition) ((BlockTag)container).getBlock().getContent(getName());

                } else {

                    throw new JspTagException("TransitionTag: cannot handle container tag" + container.getClass().getName());

                }

            }

            JspWriter writer = pageContext.getOut();

            if (oneTransition != null) {

                if (valueToUse == null || "".equals(valueToUse)) {

                    //we need a value for the botton label. Lets try to get it

                    //from the Transition:

                    valueToUse = oneTransition.getLabel();

                }

                if (valueToUse == null || "".equals(valueToUse)) {

                    //give it a default value

                    valueToUse = "Click";

                }

                //Add the hidden form field that contains the encoded button params

                //Also, add a hidden form field with the "cmd=button" pair.

                //This does not hurt to duplicate...

                writer.println(oneTransition.getHTMLParamString());

                writer.println(

                    "<INPUT TYPE=\"submit\" NAME=\"button_"

                        + oneTransition.getName()

                        + "\" VALUE=\""

                        + valueToUse

                        + "\" CLASS=\""

                        + classValueToUse

                        + "\" >");

                writer.println("<INPUT TYPE=\"hidden\" NAME=\"cmd\" VALUE=\"button\" >");

            } else {

                writer.println("The Transition Button Could Not Be Displayed");

            }

        } catch (Exception e) {

            e.printStackTrace(System.err);

            throw new JspTagException("ActionTag: " + e.getMessage());

        }

        return EVAL_PAGE;

    } /* doEndTag() */

    /**

     * Do nothing until end tag.

     *

     * @return  int

     * @throws  javax.servlet.jsp.JspTagException The exception description.

     */

    public int doStartTag() throws javax.servlet.jsp.JspTagException {

        return SKIP_BODY;

    } /* doStartTag() */

    /**

     * Setter method for Name.

     *

     * @return java.lang.String

     */

    public java.lang.String getName() {

        return nameToUse;

    } /* getName() */

    /**

     * Insert the method's description here.

     * Creation date: (12/29/2000 %r)

     *

     * @return java.lang.String

     */

    public java.lang.String getValue() {

        return valueToUse;

    } /* getValue() */

    

    

    /**

     * Get the class value, used for buttons

     * Creation date: (07/12/02)

     *

     * @return java.lang.String

     */

    public java.lang.String getClassValue() {

        return classValueToUse;

    } /* getClassValue() */

    /**

     * Insert the method's description here.

     * Creation date: (12/29/2000 %r)

     *

     * @param   newName java.lang.String

     */

    public void setName(java.lang.String newName) {

        name = newName;

    } /* setName(java.lang.String) */

    /**

     * Insert the method's description here.

     * Creation date: (12/29/2000 %r)

     *

     * @param newValue java.lang.String

     */

    public void setValue(java.lang.String newValue) {

        value = newValue;

    } /* setValue(java.lang.String) */

    

    /**

     * Used for setting the class value for buttons

     * Creation date: (12/29/2000 %r)

     *

     * @param newValue java.lang.String

     */

    public void setClassValue(java.lang.String newClassValue) {

        classValue = newClassValue;

    } /* setClassValue(java.lang.String) */

    

} /* TransitionTag */

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20020712/914a0d7c/attachment-0002.htm


More information about the Opensource mailing list