on 03-17-2009 4:42 AM
Hi,
I have two view in a view set.
In one sceen i have the table and in the other i have form to edit it or delete. In that table i have only one row ,
If i try to delete that value i am getting this error.
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
What might be the problem. I have a context value attribute which will hold the value of the lead selection value in table. I have written this code in the wdModifyview();
if(firstTime)
{wdThis.Excecutemodel();}
else
{wdThis.Excecutemodel();
if((wdContext.currentContextElement().getLeadselct())<0)
wdContext.currentContextElement().setLeadselct(-1);
if((wdContext.currentContextElement().getLeadselct())>=(wdContext.nodeCityElement().size()))
wdContext.nodeCityElement().setLeadSelection(0);
else
wdContext.nodeCityElement().setLeadSelection(wdContext.currentContextElement().getLeadselct());}
Regards,
H.V.Swathi
Hi Swathi,
I think you are getting the error while deleting the table record.
Please try and use following code. I hope this will work.
Step 1: Correct this line of code.
// Take this line of code outside the firstTime loop. Since in both condition anyways you are executing the model.
wdThis.Excecutemodel();
Step 2: Delete the table record. I am assuming that the node binded with the table is "City"
int size = wdContext.nodeCity().size();
if(size>0){
int index = 0; // This means you are deleting the first record (This is as per your requirement).
// You can set whatever value of index you want to delete. This index can be calculated by some logic.
// OR if you exactly know which record needs to be deleted then you can set that value to index.
wdContext.nodeCity().removeElementAt(index);
}
Step 3: Set leadSelection
if(wdContext.nodeCity().size()>0){
wdContext.nodeCity().setLeadSelection(0);
}
else{
wdContext.nodeCity().setLeadSelection(-1);
}
I hope this work. however I wanted to know one more thing. I am still not clear why have you taken a context attribute which stores a leadSelection?
Thanks and Regards
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if(wdContext.nodeCityElement().size()<=0)
{
wdContext.nodeCityElement().setLeadSelection(-1);
}else{
if ((wdContext.currentContextElement().getLeadselct())>= (wdContext.nodeCityElement().size()))
wdContext.nodeCityElement().setLeadSelection(0);
else {
wdContext.nodeCityElement().setLeadSelection(wdContext.currentContextElement().getLeadselct());
}
}
i have written this code to solve the error.
Edited by: H.V Swathi on Mar 17, 2009 7:12 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
*In that table i have only one row ,
If i try to delete that value i am getting this error.
*
In your delete action you are deleting the Element in nodeCityElement right?
So you had only one Element and you are deleting it, So now when it comes to wdDoModify
you are not having any element in your node and u have written
wdContext.nodeCityElement().setLeadSelection()
I think it is because of this you are getting the error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.