tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ravi Mutyala <ravi.muty...@gawab.com>
Subject Error using taglibs - unable to find setter
Date Tue, 25 May 2004 04:50:06 GMT
Hi,

I created a tag which extends from the html:text tag.

I'm using tomcat 4.1.30.
when I use this tag, I get the following error. 
-------------------------------------------------
org.apache.jasper.JasperException:
/win_002_PMT_Manage_Cstmr_Prtfl.jsp(70,26) Unable to find setter
method for attribute: dType
	at
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:94)
	at
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:428)
	at
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:186)
	at
org.apache.jasper.compiler.Generator$GenerateVisitor.generateSetters(Generator.java:1753)
	at
org.apache.jasper.compiler.Generator$GenerateVisitor.generateCustomStart(Generator.java:1356)
	at
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1179)
	at
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:707)
--------------------------------


The line in the jsp uses the tag that i created. the tag has the
setter method for  dType.

The same taglib is working in the application that is presently
deployed in weblogic. We are trying to migrate the same to
tomcat  and I am getting the above error.

Any clues?

Thanks in advance
/
Ravi.

tag code:

tag code.

------------------------------------
package com.mycompany.presentation.taglib.html;

import org.apache.struts.taglib.html.TextTag;
import java.lang.reflect.Method;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyContent;
import org.apache.struts.util.ResponseUtils;
import org.apache.struts.Globals;
import java.util.Iterator;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.util.RequestUtils;
import com.mycompany.presentation.constants.*;
import FormatConverter.*;
import javax.servlet.http.HttpSession;
import com.mycompany.utility.domainvalidations.*;
import org.apache.taglibs.display.ColumnTag;
import java.util.*;
import javax.servlet.http.HttpServletRequest;


public class wmText
    extends org.apache.struts.taglib.html.TextTag implements
Cloneable {
  protected String dType;
  protected String functionCall;
  protected String mandatory;
  protected String name = Globals.ERROR_KEY; 
  protected Iterator iter;
  
  protected String mode;
   
DisplaySingleton ds  = DisplaySingleton.getInstance();
	String dateInputFormat = ds.getDateInputFormat();
	char separator = dateInputFormat.charAt(2);
  String decimalSeparator = ds.getDecimalSeparator();
  String thousandSeparator = ds.getThousandsSeparator();
  
  Class clz;

  public wmText() {
    super();
  }

  public String getDType() {
    return (this.dType);
  }

  public void setDType(String dType) {
    this.dType = dType;
  }

  public void setMandatory(String mandatory)
  {
    this.mandatory = mandatory;
  }

  public String getMandatory()
  {
    return (this.mandatory);
  }

  public String getMaxSize(String dType) {
    String getSize = "getSize";
    Integer intObj = null;
    dType = "com.mycompany.domainvalidations." + dType;
    try {      
      clz = Class.forName(dType);
      Method method = clz.getMethod(getSize, null);     
      intObj = (Integer) method.invoke(null, null);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return intObj.toString();
  }

  public String getFunctionCall() {

    return (this.functionCall);

  }

  public void setFunctionCall(String functionCall) {

    this.functionCall = functionCall;

  }

  public String resolveFunctionCall(String dType) {
    String fCall = "";
    int decPlaces = 0;	
    if (dType.equals("D_Price")) {      
      decPlaces =
FormatConverter.FormatConverterMngr.getDecimalPlaces(1);
      fCall = "this.value=
validateNumberForStrutsElement(this.value,','"+thousandSeparator+"'"+decimalSeparator+"',"
+ decPlaces + ",true" +
          ")";
    }

    if (dType.equals("D_Forex")) {      
      decPlaces =
FormatConverter.FormatConverterMngr.getDecimalPlaces(2);
      fCall = "this.value=
validateNumberForStrutsElement(this.value,','"+thousandSeparator+"'"+decimalSeparator+"',"
+ decPlaces + ",true" +
          ")";
    }

    if (dType.equals("D_Quantity")) {      
      decPlaces =
FormatConverter.FormatConverterMngr.getDecimalPlaces(3);
      fCall = "this.value=
validateNumberForStrutsElement(this.value,','"+thousandSeparator+"'"+decimalSeparator+"',"
+ decPlaces + ",true" +
          ")";
    }

    if (dType.equals("D_Percentage")) {      
      decPlaces =
FormatConverter.FormatConverterMngr.getDecimalPlaces(4);
      fCall = "this.value=
validateNumberForStrutsElement(this.value,','"+thousandSeparator+"'"+decimalSeparator+"',"
+ decPlaces + ",true" +
          ")";
    }

    if (dType.equals("D_Value")) {      
      decPlaces =
FormatConverter.FormatConverterMngr.getDecimalPlaces(5);
      fCall = "this.value=
validateNumberForStrutsElement(this.value,','"+thousandSeparator+"'"+decimalSeparator+"',"
+ decPlaces + ",true" +
          ")";
    }
    
    if (dType.equals("d_date")) {      
      fCall = "tabDate(this,'" +dateInputFormat+"','" +separator
+"')";
    }

    return fCall;
  }

  public int doStartTag() throws JspException {
//// changes for mode
  HttpServletRequest request =(HttpServletRequest)
pageContext.getRequest();
this.setStyle("color:#000000");
//// changes end   
  String changeEvent = this.getOnchange();
        if(changeEvent!=null && !changeEvent.equals(""))
         changeEvent = ";"+changeEvent;

    this.mandatory= this.getMandatory();
    if(this.getStyleClass()==null)  
    this.setStyleClass(PresentationConstants.getTEXT_STYLE());
    
    String outString="";
    if(mandatory!=null && mandatory.equals("yes"))
    {
      outString="<img src='images/mandatory.gif'>";
    }
    else
    {
     outString = "";
    }

    this.dType = this.getDType();
    this.setMaxlength(this.getMaxSize(dType));        
   if(changeEvent!=null && !changeEvent.equals(""))
    {
    this.setOnchange(resolveFunctionCall(dType)+changeEvent);
    }
    else
    {
    if(!resolveFunctionCall(dType).equals("") &&
resolveFunctionCall(dType)!=null)
      this.setOnchange(resolveFunctionCall(dType));
    }
    
    //// Added by Parag for mode changes
    
    Vector modes = new Vector();
    String requestMode = null;

		
    requestMode =(String) request.getAttribute("MODE");
    System.out.println("Request mode in getAttribute is "
+requestMode);
    
    try
    {
    if(requestMode==null)
    {
	requestMode = (String)request.getParameter("MODE");
    }
    
    System.out.println("MODE IS " +requestMode);
    
    if(requestMode!=null && requestMode.equals("WM_VIEW"))
    {
	   System.out.println("Inside just view");
	    this.setReadonly(true);
	    this.setStyle("color:#848284");
    }
    else
    {
	mode = this.getMode();

    if(mode!=null && !mode.equals(""))
    {
	StringTokenizer	st = new StringTokenizer(mode,",");
	while (st.hasMoreTokens())
	{
      	   modes.addElement(new String(st.nextToken().trim()));
	}
    }
    
		
    if(modes!=null && modes.contains(requestMode))
    {
	    this.setReadonly(true);
	    this.setStyle("color:#848284");
    }
    }
    }
    catch(Exception e)
    {
	    System.out.println("Inside error in wmText");
	    e.printStackTrace();
    }
    //// Changes end


	    
    Object parent = this.getParent();     
    if(!(parent instanceof ColumnTag) && getProperty()!=null)
    {
      ResponseUtils.write(pageContext, outString);
      super.doStartTag();
    } 
    return (EVAL_BODY_TAG);

  }

  public int doEndTag() throws JspException {

    String outString="";
    ActionErrors errors = null;

    try {
            errors = RequestUtils.getActionErrors(pageContext,
name);
        } catch (JspException e) {
            RequestUtils.saveException(pageContext, e);
            throw e;
        }
     if(!errors.isEmpty())
     {
        String temp = this.getProperty();
       /* int i = errors.size(temp);
        if(i>=1)
        {          
          outString="<img src='images/error.gif'>";
        }
	*/
     }
     ResponseUtils.write(pageContext, outString);

     Object parent = this.getParent();	 
      
      if((parent instanceof ColumnTag)) {         
        wmText copy = this;
        try {
           setHtml( toHtml() );
           copy = (wmText)this.clone();
        } catch( CloneNotSupportedException e ) {} // shouldn't
happen...
        catch(Exception e) { }
        ((ColumnTag)parent).setWmText(copy );            
      }
      return (EVAL_PAGE);

    }


         private String toHtml() throws JspException{
      
            StringBuffer results = new StringBuffer("<input
type=\"");
            results.append(type);
            results.append("\" name=\"");
            // * @since Struts 1.1
            if (indexed)
                prepareIndex(results, name);
            results.append(property);
            results.append("\"");
            if (accesskey != null) {
                results.append(" accesskey=\"");
                results.append(accesskey);
                results.append("\"");
            }
            if (accept != null) {
                results.append(" accept=\"");
                results.append(accept);
                results.append("\"");
            }
            if (maxlength != null) {
                results.append(" maxlength=\"");
                results.append(maxlength);
                results.append("\"");
            }
            if (cols != null) {
                results.append(" size=\"");
                results.append(cols);
                results.append("\"");
            }
            if (tabindex != null) {
                results.append(" tabindex=\"");
                results.append(tabindex);
                results.append("\"");
            }
            results.append(" value=\"");
            if (value != null) {
               results.append(value);
            } 
            results.append("\"");
            results.append(prepareEventHandlers());
            results.append(prepareStyles());
            results.append(getElementClose());
            
            return results.toString();
        }


      /* sets the html of image for the Table tag
      * @name setHtml       
      */
      private void setHtml(String html)
      {
             this.html = html;    
      }

      /* serves the html of image for the Table tag
       * @name getHtml
       * @return String   -- having the html form of the image
element
       */
      public String getHtml()
      {
        return this.html;
      }


       /**
     * @name setObjectValue
     * set the object value from Column Tag
     * @param  Object   value from  form bean  
     */
      public void setObjectValue(Object value){
        this.value = value;
      }

      public void release() {

        super.release();
        dType = null;
        functionCall = null;
        iter =null;

      }


   // value from form bean
      private Object value;
      private String html;

      /** Changes for MODE
      */

      public void setMode(String sMode)
      {
	      this.mode = sMode;
      }

      public String getMode()
      {
	      return this.mode;
      }
      
}
-------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message