Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding vector

 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I have a scenario like this:
1. AddValue, adds a new record to the database, and stores the object added, say data in a vector.
Now this vector I put in a request object for displaying in jsp.

2. DeleteValue, deletes a record from database.
Here, the record should be deleted from the database and the same page should be refreshed. Since the page checks for values in the vector, I am trying to remove the element from the vector, the record which is deleted.
But it doesnt remove it.

In my database class, I am doing a select statement first, then creating a data object, returning it, saying this is the object which is being deleted.

In my action class, I have the vector returned from the request scope.

I am trying to remove the object returned from the vector

vector.removeelement(data) // but it returns false. Why ?

any help appreciated.
 
Kevin Huang
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the java type (class) of your "data"?
You may need to implement its equals and hashCode methods.
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its an object,

public class data {
}

with different variables.
 
Kevin Huang
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do need to implement (override) equals and hashCode method then.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic