You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by tesla <fa...@hotmail.com> on 2010/03/10 03:08:48 UTC
basic struts application
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>
--
View this message in context: http://old.nabble.com/basic-struts-application-tp27844692p27844692.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: basic struts application
Posted by tesla <fa...@hotmail.com>.
thanks for reply
i saw this example in the website struts tutorial and there is no code in
action mappings ?
İ can't understand what am i write to the action mappings?
Paweł Wielgus wrote:
>
> Hi,
> in action-mappings there is no result defined for your action,
> is it on purpose?
>
> Best greetings,
> Paweł Wielgus.
>
> 2010/3/10 tesla <fa...@hotmail.com>:
>>
>> 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>
>> --
>> View this message in context:
>> http://old.nabble.com/basic-struts-application-tp27844692p27844692.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://old.nabble.com/basic-struts-application-tp27844692p27856795.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: basic struts application
Posted by Saeed Iqbal <sa...@gmail.com>.
Check startsoft on google code.
On 3/10/10, Paweł Wielgus <po...@gmail.com> wrote:
> Hi,
> in action-mappings there is no result defined for your action,
> is it on purpose?
>
> Best greetings,
> Paweł Wielgus.
>
> 2010/3/10 tesla <fa...@hotmail.com>:
>>
>> 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>
>> --
>> View this message in context:
>> http://old.nabble.com/basic-struts-application-tp27844692p27844692.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
Saeed Iqbal
Independant Consultant
J2EE - Application Architect / Developer
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: basic struts application
Posted by Paweł Wielgus <po...@gmail.com>.
Hi,
in action-mappings there is no result defined for your action,
is it on purpose?
Best greetings,
Paweł Wielgus.
2010/3/10 tesla <fa...@hotmail.com>:
>
> 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>
> --
> View this message in context: http://old.nabble.com/basic-struts-application-tp27844692p27844692.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org