aspose file tools*
The moose likes Servlets and the fly likes Different(Efficient) way of handling big file of getters and setters(javaBean) in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Different(Efficient) way of handling big file of getters and setters(javaBean) in java" Watch "Different(Efficient) way of handling big file of getters and setters(javaBean) in java" New topic
Author

Different(Efficient) way of handling big file of getters and setters(javaBean) in java

rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
Hi everybody

Ist stage : i have a form(jsp) having big table say(30*20) of fields , where i am asking user to enter those fields.

II nd Stage : i am fetching those data in a servlet and setting those data through javabean function in bean object.

Problem: The problem is to set these fields i need to call every bean function one by one .Obviously it will take very long.
and if table is larger it will take even more.

So is there any efficient way of using bean function or how to create and use bean functions so that we can get and set values of field effficiently .



my form is something like this(say)..

Country Population language Primeminister president ....... ......... .............

India

USA

UK

Russia

China

....


....


......


the form order could vary in future
means i may increase or decrease countries .

Currently i am having only one java bean class

where i have variables like indiaPopulation, indiaLanguage ....
and functions like int getIndiaPopulation() , String getIndiaLanguage(), void setIndiaPopulation(int indiaPopulation) ,
void setIndiaLanguage(String indiaLanguage ) .................

please help

ragards
thanks
Dawn Charangat
Ranch Hand

Joined: Apr 26, 2007
Posts: 249
use struts.... and attach an ActionForm to this form in JSP. All the data will be automatically populated.
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
is there any way without struts.

and it's not only a question of population of datas but also of after fetching how easily i can set the data(fields) and get those values whenever required through bean
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Get rid of country-specific getters and add a getter getName(), then collect the data in a List<Country> and use JSTL c:forEach to iterate over it and display the table.
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
hi can you please show by an example...as i am new to it.
i also need to store the data in a database .....and later fetch from the database.....so will simply putting the values in arayy and displaying in tables ,solve my purpose.

rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
i also need to set the values i am fetching from screen as setters...how can whole thing happen.
can you show bay an example.
regards
thanks
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
hi
what is the way to define getters and setters for a table values.
can any one suugest an answer through an example.
since the table is very big ..what is the efficient way...say may be using Array or an Array list or something else?/
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Create a bean class which represents one row (one Country).
Then create/collect multiple instances of that bean together in a List.
In JSP you can use c:forEach to iterate over that List.
 
 
subject: Different(Efficient) way of handling big file of getters and setters(javaBean) in java