Results 1 to 7 of 7
Thread: How to delete the records
- 10-27-2008, 01:55 PM #1
Member
- Join Date
- Oct 2008
- Posts
- 4
- Rep Power
- 0
How to delete the records
Hi Everybody,
i am facing some problem in java.please solve this problem.
i have to button in my jsp. one is add and another one is delete.
while adding the records i am add the those records into the arraylist that name is temp.
Now i am not able to delete those records. how to do this.
This is my code of my servlet program
------------------------------------------------------------
temp=(ArrayList)session.getAttribute("repairvalues ");
//This addLeaseId is checkbox name
String param[]=req.getParameterValues("addLeaseId");
if(param!=null)
{
for(int i=0;i<=param.length;i++)
{ int k = Integer.parseInt(param[i]);
for(int j=0;j<=temp.size();j++)
{
if(k==j)
{
temp.remove(j);
session.setAttribute("repairvalues", temp);
}
}
}
}
I want to be delete the records what ever we selected those records want to be delete.
- 10-29-2008, 02:01 AM #2
Senior Member
- Join Date
- May 2008
- Location
- Makati, Philippines
- Posts
- 234
- Rep Power
- 6
can you post a sample of the checkbox please. (the one in html code) or can you just describe me the content of the addLeastId.
let me give you a idea on how i did it.
in my JSP, i made java generates this HTML codes for me ^_^
Imagine they are all in a Table.
<input type="checkbox" name="check" value="0">. . .other data here
<input type="checkbox" name="check" value="1">. . .other data here
<input type="checkbox" name="check" value="2">. . .other data here
<input type="checkbox" name="check" value="3">. . .other data here
<input type="checkbox" name="check" value="4">. . .other data here
<input type="checkbox" name="check" value="5">. . .other data here
in my Servlet.
String getCheckBox[] = new String[1000];
getCheckBox = request.getParameterValues("check");
now for example the user checks the CheckBox 0,1,4
in my getCheckBox, it will contain this values.
getCheckBox[0] ---> 0
getCheckBox[1] ---> 1
getCheckBox[2] ---> 4
it will only get the values of the checked checkBox and i can now use these values and convert it to int types and use as a pointer in my arraylist. ^_^ it is a much simplier for me to do it that way.Mind only knows what lies near the heart, it alone sees the depth of the soul.
- 10-29-2008, 09:23 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 4
- Rep Power
- 0
HI,
First of all appriciate to you for giving the reply.What you saying is correct.some small changes in your code.I created the checkbox only one input tag. but this input tag is in for loop.So it is traveresing and print the how many we want. But i want to be delete the perticular record. Hoe to do this.Please give a code.Here addLeaseId is checkbox name.
I am explaining to you clearly.What my question is. i have a one bean class and one ArrayList. After setting the bean values i added the bean object to ArrayList object that is temp.Now i want to be delete the what ever we selected the record in jsp.
- 10-29-2008, 09:25 AM #4
Member
- Join Date
- Oct 2008
- Posts
- 4
- Rep Power
- 0
what we selected records those records are to be deleted in temp. then only we are displaying other temp values
- 11-07-2008, 12:27 PM #5
Member
- Join Date
- Nov 2008
- Posts
- 5
- Rep Power
- 0
If you are clicking on delete record pass the same arraylist with values and iterate it and check the value to be removed which is I supoose coming in request.Then use Arraylist.remove method to remove the selected and show it back on the screen.
If you still have the query let me know or you are not getting wht i am saying.
- 11-08-2008, 04:23 PM #6
Member
- Join Date
- Oct 2008
- Posts
- 4
- Rep Power
- 0
HI Vijay,
Thank you for giving a reply. what you are saying i was tried with iterator also. but i didnot get.If you know the code.Please send the working code.
- 11-09-2008, 01:16 PM #7
String[] directly from getParameterValues
Java Code:String getCheckBox[] = request.getParameterValues("check"); if((getCheckBox != null)&&(getCheckBox.length > 0)){processString(getCheckBox[index++]) while(index < getCheckBox.length);}Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Similar Threads
-
Export records to Excel from MySQL
By ansariazam in forum New To JavaReplies: 3Last Post: 08-06-2008, 01:14 PM -
JList and records, what to do to solve the problem
By willemjav in forum Java AppletsReplies: 10Last Post: 06-11-2008, 02:28 PM -
Getting number of records (JDBC 2.0)
By Java Tip in forum Java TipReplies: 0Last Post: 02-11-2008, 08:51 AM -
Number of updated records
By Java Tip in forum Java TipReplies: 0Last Post: 01-21-2008, 04:32 PM -
Query with 1 record vs. multiple records
By anderma8 in forum JDBCReplies: 5Last Post: 07-09-2007, 11:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks