cancel
Showing results for 
Search instead for 
Did you mean: 

refresh the table

Former Member
0 Kudos

Hi experts,

My requirement is delete the files from the KM itself.I have stored the list of files under the Km in particular folder(path)

I have a following code.

I have table with checkbox and delete button. when ever select the check box(single selection or muliple selection). the file should be deleted from the KM. but does not remove from the table. how can i remove the selected item from the table and how can i refresh the table. please help me its very urgent..

my table structure is

node_accelerator

Acc_check---boolean

Acc_file---string

try {

for (int i = 0; i < wdContext.nodeTable_accelarator().size(); i++) {

if (wdContext.nodeTable_accelarator().getTable_accelaratorElementAt(i).getAcc_check()) {

String a =

wdContext.nodeTable_accelarator().getTable_accelaratorElementAt(i).getAcc_file();

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

com.sap.security.api.IUser sapUser =

wdClientUser.getSAPUser();

//create an ep5 user from the retrieved user

IUser ep5User =

WPUMFactory.getUserFactory().getEP5User(sapUser);

ResourceContext resourseContext2 =

new ResourceContext(ep5User);

RID pathRID2 =

RID.getRID(

"/documents/SAPse/Projects/Implementaion/Accelarator/"+ a+ "/");

IResourceFactory resourseFactory2 =

ResourceFactory.getInstance();

IResource collection2 =

resourseFactory2.getResource(

pathRID2,

resourseContext2);

collection2.delete();

}

}

} catch (Exception e) {

wdComponentAPI.getMessageManager().reportSuccess("error in delete");

}

Regards,

P.Manivannan.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi experts,

My requirement is delete the files from the KM itself.I have stored the list of files under the Km in particular folder(path)

I have a following code.

I have table with checkbox and delete button. when ever select the check box(single selection or muliple selection). the file should be deleted from the KM. but does not remove from the table. how can i remove the selected item from the table and how can i refresh the table. please help me its very urgent..

my table structure is

node_accelerator

Acc_check---boolean

Acc_file---string

try {

for (int i = 0; i < wdContext.nodeTable_accelarator().size(); i++) {

if (wdContext.nodeTable_accelarator().getTable_accelaratorElementAt(i).getAcc_check()) {

String a =

wdContext.nodeTable_accelarator().getTable_accelaratorElementAt(i).getAcc_file();

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

com.sap.security.api.IUser sapUser =

wdClientUser.getSAPUser();

//create an ep5 user from the retrieved user

IUser ep5User =

WPUMFactory.getUserFactory().getEP5User(sapUser);

ResourceContext resourseContext2 =

new ResourceContext(ep5User);

RID pathRID2 =

RID.getRID(

"/documents/SAPse/Projects/Implementaion/Accelarator/"+ a+ "/");

IResourceFactory resourseFactory2 =

ResourceFactory.getInstance();

IResource collection2 =

resourseFactory2.getResource(

pathRID2,

resourseContext2);

collection2.delete();

}

}

} catch (Exception e) {

wdComponentAPI.getMessageManager().reportSuccess("error in delete");

}

Regards,

P.Manivannan.

Former Member
0 Kudos

Hi P.Manivannan,

Everytime u delete anything, invalidate ur table datasource node & fetch the data again for the table.

regards

Sumit

Former Member
0 Kudos

Hi Sumit,

If i used invalidate() function in my code all the files are removed from the table(not in KM, front end only). how to resolve this...

Regards,

P.Manivannan

Former Member
0 Kudos

Hi manivannan,

I think i told u to "fetch the data again for the table" after invalidate :-). Or u can do one more thing. in ur table node get the lead selected element . Then remove that element from the context . wdContext.node<table node>.removeElementAt(lead Selection). in this case no need to use invalidate.

regards

Sumit

Former Member
0 Kudos

Hi Sumit,

Thanks for ur valuable reply

If i use removeelement single selection is working but multiple selection is not working.....(in front end only.. working fine in back end)what can i do

Regards,

P.Manivannan.

Former Member
0 Kudos

Hi manivannan,

For multiple selection u need to do this

1. chane the selectionMode property of the table to multi.

2. implement this code

int leadSelect = wdContext.node<ur node>().getLeadSelection();

int NodeSize = wdContext.node<ur node>().size();

for(int i=0;i<wdContext.node<ur node>().size();i++)

{

if(wdContext.node<ur node>()..isMultiSelected(i) || leadSelect == i)

{

wdContext.node<ur node>()..removeElement(i);

}

}

regards

Sumit

Former Member
0 Kudos

Hi P.Manivannan,

If ur problem is solved, close the thread.

regards

Sumit

Former Member
0 Kudos

Hi sumit,

1.still it's a problem now...again single selection only working. if i use selection mode is mult which cardinalty and selection is used. canu please tell me

2. if use selection mode is multi once select the checkbox(admin error is coming) please help me..

Regards,

P.Manivannan

Former Member
0 Kudos

HI P.Manivannan,

Why do u want to use checkbox for selecting rows in a table , when its alreasy available ?? Cardinality u can use 0.n.

What's the problem u r getting in multi selection?

regards

Sumit

Former Member
0 Kudos

Hi sumit,

I had done all. but its not working....only single selection only working...if i select mutiple selection after clicking the button all the files are removed from km itself. but not removed from front end table. suppose u select 4 values in a table.. the first selection of the row only reomived from the table. other rows are still present in the table.

Regards,

P.Manivannan.

Former Member
0 Kudos

Hi P.Manivannan,

Send the code u have written. It seems some problem in code ,while removing the elements from the context in the loop.

regards

Sumit

Former Member
0 Kudos

Hi sumit,

int leadSelect = wdContext.nodeTable_check().getLeadSelection();

int NodeSize = wdContext.nodeTable_check().size();

for(int i=0;i<wdContext.nodeTable_check().size();i++)

{

IPrivateChecklist.ITable_checkElement ele = wdContext.nodeTable_check().getTable_checkElementAt(i);

if(wdContext.nodeTable_check().isMultiSelected(i) & leadSelect == i)

{

wdContext.nodeTable_check().removeElement(ele);

}

}

Regards,

P.Manivannan.

Former Member
0 Kudos

Hi sumit,

Structure

table_check

-


checklist_check---boolean

-


checklist_file-----string

int leadSelect = wdContext.nodeTable_check().getLeadSelection();

int NodeSize = wdContext.nodeTable_check().size();

for(int i=0;i<wdContext.nodeTable_check().size();i++)

{

IPrivateChecklist.ITable_checkElement ele = wdContext.nodeTable_check().getTable_checkElementAt(i);

if(wdContext.nodeTable_check().isMultiSelected(i) & leadSelect == i)

{

wdContext.nodeTable_check().removeElement(ele);

}

}

Regards,

P.Manivannan

Former Member
0 Kudos

Hi Manivannan,

Instead of

if(wdContext.nodeTable_check().isMultiSelected(i) & leadSelect == i)

use

if(wdContext.nodeTable_check().isMultiSelected(i) || leadSelect == i)

regards

Sumit

Former Member
0 Kudos

Hi sumit,

I try the both & and || it not coming...

First i tried || its not coming.. then only i used &.....

still its not working.....what can i do?

Regards,

P.Manivannan.

Former Member
0 Kudos

Hi P.Manivannan,

Same code is working for me. can u check the size in the loop after removing the element?? how many times its executing the loop??

regards

Sumit

Former Member
0 Kudos

Hi Sumit,

I got a solution withoutusing removeElemet().

I create a seperate method for delete() for following code

wdContext.nodeTable().invalidate();

try

{

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

com.sap.security.api.IUser sapUser =

wdClientUser.getSAPUser();

//create an ep5 user from the retrieved user

IUser ep5User =

WPUMFactory.getUserFactory().getEP5User(sapUser);

ResourceContext resourseContext2 =

new ResourceContext(ep5User);

RID pathRID2 =

RID.getRID(

"/documents/SAPse/Projects/Implementaion/"

+ "/Templates/");

IResourceFactory resourseFactory2 =

ResourceFactory.getInstance();

ICollection collection2 =

(ICollection) resourseFactory2.getResource(pathRID2,resourseContext2);

ICollection collection11 = (ICollection) collection2;

for (IResourceListIterator itr =

collection11.getChildren().listIterator();

itr.hasNext();

) {

IResource res = (IResource) itr.next();

String name = res.getName();

// IPrivateRight.ITableElement contentElem = null;

contentElem =

wdContext.nodeTable().createTableElement();

contentElem.setFile(res.getDisplayName(true)); wdContext.nodeTable().addElement(contentElem);

}

}

catch(Exception e)

{

wdComponentAPI.getMessageManager().reportSuccess("error " +e);

}

NOTE: i used invalidate function in top of the table

I call the delete method in my button event...

Thanks For ur valuable replies

Regards,

P.Manivannan.