cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve path of Tree

Former Member
0 Kudos

I want to capture the path i've navigated through a tree UI element to the selected level of the tree.

So consider this. I have a tree control that houses an organizational structure. I expand region and see a list of sites. I select a certain site and see a list of offices. I then expand an office and see a list of Managers. I choose a certain manager and at that point i would like to know the path i took to get there. So i would want to know which region,site, and office that i selected.

Any ideas?

julian

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Try this

//selectedElement as the "path"

//FolderContent as tree node

//Text as the text property of TreeNodeType

String path="";

//Immediate parent

if(selectedElement.node()!=wdContext.nodeFolderContent() && selectedElement.node().getParentElement()!=null){

path=pathselectedElement.node().getParentElement().getAttributeValue("Text")"->";

//parent

if(selectedElement.node().getParentElement().node()!=wdContext.nodeFolderContent() && selectedElement.node().getParentElement().node().getParentElement()!=null){

path=selectedElement.node().getParentElement().node().getParentElement().getAttributeAsText("Text")"->"path;

}

}

path=path+selectedElement.getText();

wdComponentAPI.getMessageManager().reportSuccess(path);

Kind Regards

Mukesh

Answers (1)

Answers (1)

Former Member
0 Kudos

Assuming the following context structure:

Regions (node, card=0:N)
+ Sites (node, card=0:N, singleton=false)
  + Offices (node, card=0:N, singleton=false)
    + Managers (node, card=0:N, singleton=false)

Assign an action "ManagerSelected" to the "onAction" event of the TreeNodeType/TreeItemType representing the manager nodes.

Add an action parameter "manager" of type IPrivate<View>.IManagersElement.

Map parameter "nodeElement" of "onAction"-event to action-parameter "manager".

Then you will get the IManagersElement instance as a parameter of the action handler:

void onActionManagerSelected(..., IManagersElement manager)
{
  /* get office of selected manager */
  IOfficesElement office = (IOfficesElement) manager.node().getParentElement();
  /* get site */
  ISitesElement site = (ISitesElement) office.node().getParentElement();
  /* get region */
  IRegionsElement region = (IRegionsElement) site.node().getParentElement();
}

Armin

Former Member
0 Kudos

Thanks guys.

Armin your example was very helpful and I think i'm pretty close to getting that to work.

Julian

Former Member
0 Kudos

What is missing?

Armin

Former Member
0 Kudos

Just my lack of Web Dynpro knowledge. This is my first project using Web Dynpro and the Web AS. I've been through the SAP Web Dynpro course but do not come from a java background. I come from a M$ background. Currently I'm still trying to get some of the server pieces put together. Namely the IGS component as it's not starting properly on my Web AS. I'm also awaiting SAP BW access so that I can begin coding RFC wrappers for calls to the BW backend. I will actually not be creating the RFC wrappers but I will need to setup the models in web Dynpro to hit these RFC's. Without access currently I have no data coming back so your sample code which makes perfect sense cannot be implemented yet. I do thank you for the sample as I think even with my limited knowlede it really points me in the right direction. Currently trying to get the IGS component working as i have a local install of the Web AS running. (NWDS 6.40)

Julian

Former Member
0 Kudos

I see.

If you have no backend functionality yet, you can simulate the model by a custom controller with a suitable context structure. Simply hardcode some data to populate the context and you can already test large parts of your UI without backend.

For all other problems you are currently fighting with: you know where to ask

Armin

Former Member
0 Kudos

Again a great idea in regards to the custom controller to simulate the data from the tree structure. I will try to set this up. In regards to IGS i finally went back to the downloads section and got the stand alone version of IGS which has the setup.exe everyone in the forums seem to point to. I will try this method of installa and probably will have that up and running today.

Thanks Again Armin!

julian