cancel
Showing results for 
Search instead for 
Did you mean: 

Iterate through UI elements in a view

Former Member
0 Kudos

Hi,

I would like to iterate through the UI elements in a view, to read their 'id' values, and populate an arraylist. Could you please suggest how to accomplish this ?

Thanks !

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Armin,

I just did not want to use the table name but have my program find it.

The general idea is to have a program that finds the non-singletons in a wdContext, find the corresponding tables in views and compose a report out of that.

thanks

Walter

Former Member
0 Kudos

Hi Achim,

It is not trivial, but one gets a deep understanding of a view when doing it.

I would like to give you an example where I needed it: Say I want to produce a PDF. This PDF shall contain the data that go into a table UI element. Now these data are in the context, of course; but which columns I want to print are specified in the table UI element. Column headers, too. So I iterate and find the table that has the datasource I am interested in.

Why do I give you the example? - Because it is an example of a situation where I only want read-access to the view. And the fact that I can only get at the view inside doModifyView() makes my program more convoluted than necessary. I would like to read the view in other (WebDynpro Phase Model) phases as well.

greetings

Walter

Former Member
0 Kudos

Hello Walter,

(Armin, by the way),

what I described as non-trivial is iterating the <b>complete </b>UI tree in a <b>generic </b>way.

For your example of a table, it suffices to know the structure of the table: A table contains table columns, a table column contains a header, a table column contains a table cell editor etc.

Additionally, the column header texts etc. might also reside in configuration data outside of the view layout, so you don't need to traverse the view to get these.

A generic traversal of a view is in many (most?) cases not needed.

The idea in restricting access to the view layout to wdDoModifyView() is to propagate a programming style that decouples event handling (controller) from view access.

Armin

Former Member
0 Kudos

Hi,

If ur requirement is just to get the ID's Noufal 's solution should be sufficient.

IWDTransparentContainer t = (IWDTransparentContainer)view.getElement("RootUIElementContainer");

IWDUIElement a[] = t.getChildren();

for(int i =0;i<a.length;i++){

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(a<i>.getId());

IWDUIElement i1 = (IWDUIElement)view.getElement(a<i>.getId());

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess(""+i1.getClass());

}

If all the elements are created in design time you will know the element IDs and types. So further processing for manipulation of the UI properites will be easy.

But if elements are added dynamically you will be able to get their ID s and the class type. But i wonder if u will be able to proceed further.

Regards

Bharathwaj

Former Member
0 Kudos

Iterating over the children of a container will not suffice because the UI tree is not only spanned by this relation.

Armin

Former Member
0 Kudos

The IDs are stored in a map in the view but not accessible through an API.

It is possible to iterate through the UI tree generically but this is not trivial. How this can be done is described in Chris Whealy: Inside Web Dynpro for Java, pages 163-172.

Why do you need these IDs?

Armin

Former Member
0 Kudos

try container.getChildren.I think this will give u the complete array of UI Elements under that container.

Else try looping thru container.getchild(uiPosition) inside wdModify.