[ https://issues.apache.org/struts/browse/STR-3157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44293#action_44293 ] Wendy Smoak commented on STR-3157: ---------------------------------- Please ask questions about your project on the user list rather than in the issue tracker. You can find subscription info here: struts.apache.org/mail-lists.html > Problem - No getter method found > --------------------------------- > > Key: STR-3157 > URL: https://issues.apache.org/struts/browse/STR-3157 > Project: Struts 1 > Issue Type: Bug > Environment: Windows - Oracle db, MyEclipse, Tomcat > Reporter: R Diaz > Priority: Blocker > > Hi Everyone, > I'm new working with Struts and also got this "No getter method for property error." Sorry to post the code, but I'm hoping that someone > could tell me what I'm doing wrong. I haven't been able to figure this out and it's not like what was previously mentioned. > The code is as follows: > -- Book.java: > package com.mycompany; > public class Book implements java.io.Serializable { > private static final long serialVersionUID = 1L; > private long id; > private String title; > private String author; > private char available; > public Book() {} > public Book(long id, String title, String author, char available) { > this.id = id; > this.title = title; > this.author = author; > this.available = available; > } > public long getId() { > return id; > } > public void setId(long id) { > this.id = id; > } > public String getTitle() { > return title; > } > public void setTitle(String title) { > this.title = title; > } > public String getAuthor() { > return author; > } > public void setAuthor(String author) { > this.author = author; > } > public char getAvailable() { > return available; > } > public void setAvailable(char available) { > this.available = available; > } > } > ============================================================ > -- BookListForm.java > package com.mycompany.struts.form; > import java.util.ArrayList; > import java.util.Collection; > import javax.servlet.http.HttpServletRequest; > import org.apache.struts.action.ActionForm; > import org.apache.struts.action.ActionMapping; > /** > * MyEclipse Struts > * Creation date: 06-24-2008 > * > * XDoclet definition: > * @struts.form name="bookListForm" > */ > public class BookListForm extends ActionForm { > private Collection books; > /** > * @return the books > */ > public Collection getBooks() { > return books; > } > /** > * @param books the books to set > */ > public void setBooks(Collection books) { > this.books = books; > } > public void reset(ActionMapping mapping, HttpServletRequest request) { > books = new ArrayList(); > } > } > ============================================================ > -- BookListAction.java > package com.mycompany.struts.action; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > import org.apache.struts.action.Action; > import org.apache.struts.action.ActionForm; > import org.apache.struts.action.ActionForward; > import org.apache.struts.action.ActionMapping; > import com.mycompany.form.BookListForm; > import com.mycompany.hibernate.*; > import org.hibernate.SessionFactory; > import org.hibernate.Session; > import java.util.Collection; > /** > * MyEclipse Struts > * Creation date: 06-24-2008 > * > * XDoclet definition: > * @struts.action path="/bookList" name="bookListForm" input="/jsp/bookList.jsp" scope="request" validate="true" > */ > public class BookListAction extends Action { > public ActionForward execute(ActionMapping mapping, ActionForm form, > HttpServletRequest request, HttpServletResponse > response) { > BookListForm bookListForm = (BookListForm) form; > SessionFactory factory = null; > Session session = null; > Collection books = null; > try { > factory = HibernateUtil.getSessionFactory(); > session = (Session) factory.openSession(); > books = session.createQuery("select id, title, author, available from Book t ").list(); > bookListForm.setBooks(books); > } finally { > session.close(); > } > return mapping.findForward("showList"); > } > } > ============================================================ > -- bookList.jsp > <%@ page language="java" pageEncoding="ISO-8859-1"%> > <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%> > <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%> > <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %> > > > Show book list > > > > > <%-- set the header --%> > > > > > > > > <%-- check if book exists and display message or iterate over books --%> > > > > > > > > > <%-- print out the book information --%> > > > > <%-- print out the edit and delete link for each book --%> > > > > > > <%-- print out the add link --%> > > > > <%-- end interate --%> > >
AuthorBook nameAvailable
No books available
> paramProperty="id" paramId="id">Edit paramProperty="id" paramId="id">Delete
Add a new book >
> > > ============================================================ > Sorry for posting the code. Thanks in advance for any help. > Best regards, > Rudi -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.