GeeCON Prague 2014*
The moose likes Servlets and the fly likes how to store the vector values in bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "how to store the vector values in bean" Watch "how to store the vector values in bean" New topic
Author

how to store the vector values in bean

Mary Wallace
Ranch Hand

Joined: Aug 25, 2003
Posts: 138
In my code, i need to store each row in a bean instead of displaying from servlet.
Here is the code:

I want to store each row in a bean , then display it. Hope I am clear.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1073
Hi Mary,
Maybe I misunderstand what you're trying to do, but why not just create a bean with a Vector object and have a "Set" method that stores each row from whatever class you would call it from.
Class RowBean
{
Vector vec;
public row getRow(int offsetToReturn)
{
// return this row from the Vector
}
}
Is this what you mean?
-- Mike
Mary Wallace
Ranch Hand

Joined: Aug 25, 2003
Posts: 138
You are getting there.
If its only one row , then no problem. In my case there can be many rows and each row contains 4 elements. So..
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1073
Why not just store an array of four elements in each Vector object (or an ArrayList, or whatever) for each row?
-- Mike
Eric Fletcher
Ranch Hand

Joined: Oct 26, 2000
Posts: 188
Hi Mary,
Like Mike, I'm not 100% sure what you are trying to do, but I think I'd create a class called Row as a bean, with setters and getters for the different elements of a "row". For example, if a row contained info about a person(i.e. first and last name, id number, and age) I'd do the following:

Then you populate the beans from a datasource, i.e. a database, then fill the vector with the beans, one after the other. Then you can loop through the vector using the getters to display the values. Keep in mind this will only work if the elements of your row are always going to be the same.
HTH,
E


My theory of evolution is that Darwin was adopted. - Steven Wright
Mary Wallace
Ranch Hand

Joined: Aug 25, 2003
Posts: 138
Okay I will explain more.
What I am doing is reading an excel file which users uploading and reading it. After reading it I dont want to save that DB, but want to display that to users so that they can make changes.


Hope I am clear now :
Moorthi Ramasamy
Greenhorn

Joined: Jan 02, 2004
Posts: 15
Mary,
Like others, I'm bit confused with your requirement. Let me clarify it first before posting the reply.
"User uploads the excel file and they want to read the content of the excel file in html-table format with 4 columns & unlimited rows"
If this is your requirement, I would suggest you to go with Eric's idea. Read the excel file and populate the content in the array of user defined datatype or java class.
Display it back to the user by iterating the datatype.
Hope this helps.
Thanks,
Moorthi.
Mary Wallace
Ranch Hand

Joined: Aug 25, 2003
Posts: 138
"User uploads the excel file and they want to read the content of the excel file in html-table format with 4 columns & unlimited rows"
One difference here
Unlimited rows and and 4 cells.

It will be like this.
emp id, emp last name, emp first_name , emp_wage
Right now I am displaying frm servlet(the servlet that reads the file) directly to the page. I need to store in a session bean and want to display in another page. But dont know how to.........

Originally posted by Moorthi Ramasamy:
Mary,
Like others, I'm bit confused with your requirement. Let me clarify it first before posting the reply.
"User uploads the excel file and they want to read the content of the excel file in html-table format with 4 columns & unlimited rows"
If this is your requirement, I would suggest you to go with Eric's idea. Read the excel file and populate the content in the array of user defined datatype or java class.
Display it back to the user by iterating the datatype.
Hope this helps.
Thanks,
Moorthi.
 
GeeCON Prague 2014
 
subject: how to store the vector values in bean