The following comes from the Tomcat 3.3.x faq file, which I assume
would apply in your situation:


Q. I have a bean with a property whose second letter is capitalized.
   Why won't my JSP page that uses this bean compile?

A. This may not happen often, but can be difficult to determine why.
   The reason is found in the Java Beans specification, where in section
   "8.8 Capitalization of inferred names" it states:

       Thus when we extract a property or event name from the middle of an
       existing Java name, we normally convert the first character to lower
       case. However to support the occasional use of all upper-case names,
       we check if the first two characters of the name are both upper case
       and if so leave it alone.

   This means that if you have a bean with a setter method of "setXLoc",
   then the inferred property is "XLoc", not "xLoc".  If you used this
   bean in a JSP page and you tried to use "xLoc" as the property, it
   would not compile. Using "XLoc" as the property would succeed.

   If you insist on using "xLoc" on the JSP page, you can make this possible
   by creating a BeanInfo class for the bean.  The following is an example
   of such a BeanInfo class for a simple bean called Coordinate.  It
   explicitly defines the properties of the bean to be "xLoc" and "yLoc".

   import java.beans.*;
   public class CoordinateBeanInfo extends SimpleBeanInfo
   {
      private final static Class beanClass = Coordinate.class;

      public PropertyDescriptor[] getPropertyDescriptors()
      {
         try {
            PropertyDescriptor xLocDesc =
               new PropertyDescriptor("xLoc",beanClass,"getXLoc","setXLoc");
            PropertyDescriptor yLocDesc =
               new PropertyDescriptor("yLoc",beanClass,"getYLoc","setYLoc");

            PropertyDescriptor [] pdv = { xLocDesc, yLocDesc };
            return pdv; 
         } catch (IntrospectionException e) {
            throw new Error(e.toString());
         }
      }
   }


HTH.

Cheers,
Larry


> -----Original Message-----
> From: Ravi Mutyala [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, May 25, 2004 8:02 AM
> To: Tomcat Users List
> Subject: Re: Error using taglibs - unable to find setter
> 
> 
> M.Hockings wrote:
> 
> > Is the settter for dType  setdType(String value) or setDType(String 
> > value)?  I think that it will need to be the latter.
> >
> > Mike
> 
> Mike,
> 
> the setter for dType is this.
> 
> public void setDType(String dType) {
>    this.dType = dType;
>  }
> 
> >
> > Ravi Mutyala wrote:
> >
> >> 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(Defaul
> tErrorHandler.java:94) 
> >>
> >>     at
> >> 
> org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispa
> tcher.java:428) 
> >>
> >>     at
> >> 
> org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispa
> tcher.java:186) 
> >>
> >>     at
> >> 
> org.apache.jasper.compiler.Generator$GenerateVisitor.generateS
> etters(Generator.java:1753) 
> >>
> >>     at
> >> 
> org.apache.jasper.compiler.Generator$GenerateVisitor.generateC
> ustomStart(Generator.java:1356) 
> >>
> >>     at
> >> 
> org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Gen
> erator.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,','"+thousandSeparat
> or+"'"+decimalSeparator+"'," 
> >>
> >> + decPlaces + ",true" +
> >>          ")";
> >>    }
> >>
> >>    if (dType.equals("D_Forex")) {           decPlaces =
> >> FormatConverter.FormatConverterMngr.getDecimalPlaces(2);
> >>      fCall = "this.value=
> >> 
> validateNumberForStrutsElement(this.value,','"+thousandSeparat
> or+"'"+decimalSeparator+"'," 
> >>
> >> + decPlaces + ",true" +
> >>          ")";
> >>    }
> >>
> >>    if (dType.equals("D_Quantity")) {           decPlaces =
> >> FormatConverter.FormatConverterMngr.getDecimalPlaces(3);
> >>      fCall = "this.value=
> >> 
> validateNumberForStrutsElement(this.value,','"+thousandSeparat
> or+"'"+decimalSeparator+"'," 
> >>
> >> + decPlaces + ",true" +
> >>          ")";
> >>    }
> >>
> >>    if (dType.equals("D_Percentage")) {           decPlaces =
> >> FormatConverter.FormatConverterMngr.getDecimalPlaces(4);
> >>      fCall = "this.value=
> >> 
> validateNumberForStrutsElement(this.value,','"+thousandSeparat
> or+"'"+decimalSeparator+"'," 
> >>
> >> + decPlaces + ",true" +
> >>          ")";
> >>    }
> >>
> >>    if (dType.equals("D_Value")) {           decPlaces =
> >> FormatConverter.FormatConverterMngr.getDecimalPlaces(5);
> >>      fCall = "this.value=
> >> 
> validateNumberForStrutsElement(this.value,','"+thousandSeparat
> or+"'"+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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to