struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saeed Iqbal <saee...@gmail.com>
Subject Re: basic struts application
Date Wed, 10 Mar 2010 16:28:50 GMT
Check startsoft on google code.

On 3/10/10, Paweł Wielgus <poulwiel@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 <fatihdurdu@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


Mime
View raw message