Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

basic struts application

tesla

2010-03-09

Replies: Find Java Web Hosting

Author LoginPost Reply

from a few days i'm working on struts and i'm trying to develop an simple web
application.
i cant see the elements of my array(bookList) on jsp page when i run my
program it returns me an empty page where am i wrong please help me i'm
losing my mind for two days.


Book class

public class Book {
 
  private String name;
  private String description;
  private int price;
  private int id;

  public Book()
 {
   
 }
  public Book(String name)
  {
    this.name=name;
  }

  public ArrayList<Book> loadData()
  {
     ArrayList<Book> kitapListesi = new ArrayList<Book>();
     kitapListesi.add(new Book("calculus1"));
      kitapListesi.add(new Book("calculus2"));
     return kitapListesi;
  }

BookForm Class

public class BookForm extends org.apache.struts.action.ActionForm {
 
 private ArrayList<Book> bookList;

  private String name;

  private int number;

public ArrayList<Book> getBookList() {
    return bookList;
  }

public void setBookList(ArrayList<Book> bookList) {
    this.bookList = bookList;
  }

BookAction Class

public class BookAction extends org.apache.struts.action.Action {
 
  private final static String SUCCESS = "success";

  public ActionForward execute(ActionMapping mapping, ActionForm form,
       HttpServletRequest request, HttpServletResponse response)
       throws Exception {

    BookForm bookForm = (BookForm) form;
    Book book = new Book();
    bookForm.setBookList(book.loadData());
 

    return mapping.findForward(SUCCESS);
  }
}

struts_config.xml

<form-beans>
    <form-bean name="BookForm" type="paket.BookForm"/>
  </form-beans>

<action-mappings>
    <action input="/data" name="BookForm" path="/data" scope="request"
type="paket.BookAction"/>
  </action-mappings>

data.jsp

 <logic:present name="BookForm">
      <logic:iterate name="BookForm" property="bookList" id="book">
<tr>
<td><bean:write name="book" property="name" /></td>
</tr>
</logic:iterate>
</logic:present>
--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.