on 08-17-2006 8:03 PM
Hello,
I have a strange problem. I have two tables, one with data, one w/o. When selecting an element from Table 1, I click a button and it removes it from table one and adds it to table 2, essentially sending it to the other table.
The problem I have is whenever I select the last element in Table 1, it moves ALL elements over to Table 2, and vice versa. I've checked my coding and don't see any errors.
Is this a code error or is this a known/unknown SAP bug?
Here's my code for the button:
//@@begin addPrograms()
int nodeSize = wdContext.nodeVnAvailablePrograms().size();
for(int i=nodeSize-1; i>=0; i--)
{
if (wdContext.nodeVnAvailablePrograms().isMultiSelected(i) || wdContext.nodeVnAvailablePrograms().getLeadSelection() == i)
{
wdThis.addProgram(wdContext.nodeVnAvailablePrograms().getVnAvailableProgramsElementAt(i),wdContext.nodeVnAvailablePrograms(),wdContext.nodeVnSelectedPrograms());
wdContext.nodeVnAvailablePrograms().removeElement(wdContext.nodeVnAvailablePrograms().getElementAt(i));
}
}
//@@end
The cardinality for both nodes are 0..n
Hung,
The problem seems to be in method addProgram.
Could you post source of this method?
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply Valery.
Here is the addProgram snipet.
//@@begin addProgram()
IWDNodeElement element = destNode.createElement();
try
{
element.setAttributeValue("Description",nodeElement.getAttributeAsText("Description"));
element.setAttributeValue("Responsible_No",nodeElement.getAttributeAsText("Responsible_No"));
element.setAttributeValue("Wbs_Element",nodeElement.getAttributeAsText("Wbs_Element"));
destNode.addElement(element);
}
catch(Exception ex)
{
wdComponentAPI.getMessageManager().reportMessage(IMessageReportsApp.ERROR_HANDLER, new Object[] {"ReportsApp","addProgram","",ex.getMessage()},false);
}
//@@end
Hung,
As I can see you are using only 2 parameters in addProgram method: source element and destination node.
However, you pass 3 parameters to addProgram: one element and two nodes, wdContext.nodeVnAvailablePrograms(),wdContext.nodeVnSelectedPrograms()).
Are you sure you are not confusing nodes when pass them to addProgram?
Valery Silaev
EPAM Systems
Hung,
I bet I catched this bug -- it is misunderstanding between you and WD
Try this:
int nodeSize = wdContext.nodeVnAvailablePrograms().size();
int lead = wdContext.nodeVnAvailablePrograms().getLeadSelection();
for(int i=nodeSize-1; i>=0; i--)
{
if (wdContext.nodeVnAvailablePrograms().isMultiSelected(i) || lead == i)
{
wdThis.addProgram(
wdContext.nodeVnAvailablePrograms().getVnAvailableProgramsElementAt(i),
wdContext.nodeVnAvailablePrograms(),
wdContext.nodeVnSelectedPrograms()
);
wdContext.nodeVnAvailablePrograms().removeElement(
wdContext.nodeVnAvailablePrograms().getElementAt(i)
);
}
}
It seems that after you are deleting lead selected element WD select next one available. Or previous one if lead was latest element. Namely second option causes all elements to be removed
Valery Silaev
EPAM Systems
Message was edited by: Valery Silaev
bump post. any thoughts?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
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.