• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to store the vector values in bean

 
Mary Wallace
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1190
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1190
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mary Wallace
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic