struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "R Diaz (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STR-3157) Problem - No getter method found
Date Thu, 26 Jun 2008 02:20:06 GMT

    [ https://issues.apache.org/struts/browse/STR-3157?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44294#action_44294
] 

R Diaz commented on STR-3157:
-----------------------------

Hi Wendy, 

  Thank you. Sorry about that. 

  Have a nice day. 

Thanks, 

Rudi 





      


> 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" %>
> <html>
> <head>
> <title>Show book list</title>
> </head>
> <body>
> <table border="1">
> <tbody>
> <%-- set the header --%>
> <tr>
> <td>Author</td>
> <td>Book name</td>
> <td>Available</td>
> <td> </td>
> <td> </td>
> </tr>
> <%-- check if book exists and display message or iterate over books --%>
> <logic:empty name="bookListForm" property="books">
> <tr>
> <td colspan="5">No books available</td>
> </tr>
> </logic:empty>
> <logic:notEmpty name="bookListForm" property="books">
> <logic:iterate name="bookListForm" property="books" id="book">
> <tr>
> <%-- print out the book information --%>
> <td><bean:write name="book" property="author" /></td>
> <td><bean:write name="book" property="title" /></td>
> <td><html:checkbox disabled="true" name="book" property="available" />
> </td>
> <%-- print out the edit and delete link for each book --%>
> <td><html:link action="bookEdit.do?do=editBook" paramName="book"
> paramProperty="id" paramId="id">Edit</html:link></td>
> <td><html:link action="bookEdit.do?do=deleteBook" paramName="book"
> paramProperty="id" paramId="id">Delete</html:link></td>
> </tr>
> </logic:iterate>
> </logic:notEmpty>
> <%-- print out the add link --%>
> <tr>
> <td colspan="5"><html:link action="bookEdit.do?do=addBook">Add a new book</html:link>
> </td>
> </tr>
> <%-- end interate --%>
> </tbody>
> </table>
> </body>
> </html>
> ============================================================
> 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.


Mime
View raw message