Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

No getter method for property

843838Mar 7 2006 — edited Mar 7 2006
Hey all,
I have a struts application and a problem when viewing a form. All I am looking to do, is insert an object of user-defined type User into a database. Here is the code.
*******************************My JSP with the form**********
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html:form action="actions/insertuser">
      Username: <BR><html:text property="username"/><BR>
      First Name: <BR><html:text property="firstname"/><BR>
      Last Name: <BR><html:text property="lastname"/><BR>
      Phone: <BR><html:text property="phone"/><BR>
      Extension: <BR><html:text property="extension"/><BR>
      Fax: <BR><html:text property="fax"/><BR>
      Active: <BR><html:checkbox property="isactive"/><BR>
      <BR><html:submit value="Insert User" styleClass="mediumButton"/>
</html:form>

**********************************struts-config.xml****************

        <form-bean name="insertUserBean" type="mars.User"/>
.......
        <action path="/actions/insertuser" type="mars.InsertUser" name="insertUserBean" input="/pages/forms/frm_useradmin_insert.jsp" scope="request">
            <forward name="success" path="/pages/useradmin.jsp"/>
            <forward name="failure" path="/pages/useradmin.jsp"/>
        </action>

********************************User Object*********
public class User {
    public String   Username;
    public String   Password;
    public String   Firstname;
    public String   Lastname;
    public String   Phone;
    public String   Extension;
    public String   Fax;
    public boolean  IsActive;
........
    public boolean getIsActive(){
        return IsActive;
    }
    public void setIsActive(boolean IsActive){
        this.IsActive = IsActive;
    }
}
I'm new to struts, but my understanding is that when I declared the insertUserBean of type User in my struts-config.xml is that it would have all the getter and setter methods of that Object. The error that I get is when first loading the jsp, it tells me
javax.servlet.ServletException: No getter method for property: "isactive" of bean: "org.apache.struts.validator.BeanValidatorForm"
The form displays correctly WITHOUT using the isActive property. Could it be something with it being a boolean rather than a String? Here is my action class, however I dont think its even getting called, because the jsp fails to load.
public class InsertUser extends Action {
       
    /** Creates a new instance of InsertUser 
    public InsertUser() {
    }*/
    
    
    public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
    throws Exception {
        HttpSession session = request.getSession(true);
        
        
        DAOFactory myFactory = DAOFactory.getDAOFactory(3);
        UserDAO myUserDAO = myFactory.getUserDAO();
        User newUser = new User();
        
        boolean isactive = false;
        
        if (request.getParameter("isactive").equals("true")){
            isactive = true;
        }
        
            newUser.setUsername(request.getAttribute("Username").toString());
            newUser.setPassword(request.getAttribute("Password").toString());
            newUser.setFirstname(request.getAttribute("Firstname").toString());
            newUser.setLastname(request.getAttribute("Lastname").toString());
            newUser.setPhone(request.getAttribute("Phone").toString());
            newUser.setExtension(request.getAttribute("Extension").toString());
            newUser.setFax(request.getAttribute("Fax").toString());
            newUser.setIsActive(isactive);        
        
        return(mapping.findForward("success"));
        
    }
    
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 4 2006
Added on Mar 7 2006
6 comments
860 views