on 03-23-2006 3:15 PM
I have followed the following tutorial, to create the TreeByNestingTableColumn:
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/tutorial on creating a tree structure in a table - 27.htm
Everything works fine, however, how can I trigger an event to the controller, when te user selects a row in the table.
I need to fire the event, and let the controller know the ID of the selected row.
Any Ideas on this?
Hi Harm,
Isn`t it described in Valery`s blog? /people/valery.silaev/blog/2005/06/20/master-of-columns-part-ii
Code from blog`s example which returns selected node elemenent
private IPrivateTreeTableCV.IEntriesElement currentEntry()
{
try
{
IWDNodeElement el;
for
(
el = wdContext.nodeEntries().getTreeSelection();
!( el == null || el instanceof IPrivateTreeTableCV.IEntriesElement);
el = el.node().getParentElement()
);
return (IPrivateTreeTableCV.IEntriesElement)el;
}
catch (final WDContextException ex)
{
return null;
}
}
And to fire event when user selectes a row you need to define onLeadSelect event by table.
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your quick reply.
However it did not work.
I do not have a getTreeSelection() method. I guess this is because I'm using a TreeByNestingTableColumn and not a Tree.
I tried the following:
private IPrivateResultView.IBomTableElement currentEntry()
{
int leadSelection = wdContext.nodeBomTable().getLeadSelection();
return (IPrivateResultView.IBomTableElement) wdContext.nodeBomTable().getElementAt(leadSelection);
}
But, this code always returns 0.
Any suggestions?
Hi Harm,
The id what you need is part of the element in the recusive node.
If so you have to do the following.
Create a method With parameter element.
Connect that method to onLeadSelect.
use the following code inside the method.
{
String iD = element.getId();
wdThis.controller.methodname(id);
}
Regards
Ayyapparaj
I tried what you said:
public void onActionSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.asml.tpd.app.wdp.IPrivateResultView.IBomTableElement selectedElement )
{
//@@begin onActionSelect(ServerEvent)
String parent = selectedElement.getID();
}
However, when onActionSelect is called (I debugged this),
selectedElement is null. Therefore a NPE arrises on selectedElement.getID();
What is going wrong here?
Can you please help?
Hi Harm,
I have just downloaded and imported tutorial project to my NWDS and this piece of code works:
private IPrivateTreeTableView.ICatalogEntriesElement currentEntry()
{
try
{
IWDNodeElement el;
for
(
el = wdContext.nodeCatalogEntries().getTreeSelection();
!( el == null || el instanceof IPrivateTreeTableView.ICatalogEntriesElement);
el = el.node().getParentElement()
);
return (IPrivateTreeTableView.ICatalogEntriesElement)el;
}
catch (final WDContextException ex)
{
return null;
}
}
Don`t really understand why you don`t like it.
Best regards, Maksim Rashchynski.
Maksim,
I sincerely appreciate your effort.
However, I cannot get your code to compile. I tried the following:
//@@begin javadoc:onActionSelect(ServerEvent)
/** Declared validating event handler. */
//@@end
public void onActionSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.asml.tpd.app.wdp.IPrivateResultView.IBomTableElement selectedElement )
{
//@@begin onActionSelect(ServerEvent)
try
{
IWDNodeElement el;
for
(
el = wdContext.nodeBomTable().getTreeSelection();
!( el == null || el instanceof IPrivateTreeTableView.ICatalogEntriesElement);
el = el.node().getParentElement()
);
return (IPrivateTreeTableView.ICatalogEntriesElement)el;
}
catch (final WDContextException ex)
{
return null;
}
}
NWDS reports: The method getTreeSelection() is undefined for the type IPrivateResultView.IBomTableNode ResultView.java TestWebservice/gen_wdp/packages/com/asml/tpd/app line 302
Any suggestions?
Hi Harm,
Seems like SP11`s version of Node implementation really doesnt have getTreeSelection (in spite of setTreeSelection is there). So, you can try following code:
final IPrivateTreeTableView.ICatalogEntriesElement getRecursiveLeadSelection(
IPrivateTreeTableView.ICatalogEntriesNode __node )
{
int leadSelection = __node.getLeadSelection();
if( leadSelection!=IWDNode.LEAD_SELECTION ) {
IPrivateTreeTableView.ICatalogEntriesElement element = getRecursiveLeadSelection( __node.nodeChildCatalogEntries( leadSelection ) );
if(element==null) {
return __node.currentCatalogEntriesElement();
} else {
return element;
}
} else {
return null;
}
}
Best regards, Maksim Rashchynksi.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.