cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic UIElement Generation at Runtime

andre_becker
Employee
Employee
0 Kudos

Hi everybody,

My problem is, that I want to create a number of elements at runtime. The number depends on the records in the database. So when I got 30 records in my database. I want to create 30 elements. So far, so good.

The connection through the WebServices works very well.

Now I got my problems with display the elements. I want to use the tray element.

Now my Code looks like this:


//... much code before! :-)

//here you get the number of affected rows
length = req.getResponse().getResultAsArray().length;
    
    
//dynamically create trays, after the number of selected rows
for (int i = 0; i < length; i++) 
{
IWDTransparentContainer transparent = (IWDTransparentContainer) view.createElement(IWDTransparentContainer.class, "TC."+i);
IWDTray tray = (IWDTray) view.createElement(IWDTray.class, "tray."+i);

//I don't want any more options at the moment ;-)
tray.setEnabled(true);
tray.setExpanded(false);
		
transparent.addChild(textView);
transparent.addChild(tray);
}

So but nothing is shown on the screen.

Now there exists the method setVisible(), I think this is the key to solve my problem. But this method expects a WDVisibility parameter and I don't know what I must type in.

I tried it with com.sap.ide.webdynpro.uielemtdefinitions.Visibility, it doesn't work.

Then I created a context attribute with this type!

doesn't work, too.

My you can help me?

Kind Regards,

Andre

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

for (int i = 0; i < length; i++)

{

<b>IWDTransparentContainer container = (IWDTransparentContainer)view.getElement("RootUIElementContainer");</b>

IWDTransparentContainer transparent = (IWDTransparentContainer) view.createElement(IWDTransparentContainer.class, "TC."+i);

IWDTray tray = (IWDTray) view.createElement(IWDTray.class, "tray."+i);

//I don't want any more options at the moment

tray.setEnabled(true);

tray.setExpanded(false);

transparent.addChild(textView);

transparent.addChild(tray);

<b>container.addChild(transparent);</b>

}

Hope it helps,

Regards,

Nagarajan.

Message was edited by: Nagarajan Kumarappan

Answers (3)

Answers (3)

andre_becker
Employee
Employee
0 Kudos

Now it works. ;-D

Thanks for your help, Maksim & Nagarajan!

Kind regards & thanks a lot!

Andre

Former Member
0 Kudos

WARNING: Never use "." inside UI element IDs!

This will definitely cause errors!

To create unique IDs automatically, simply pass NULL to IWDView.createElement(Class, String) as described in the Javadoc.

Armin

Former Member
0 Kudos

Hi Armin,

You are Right ,I faced lot of porblems using ids.

Best Suggestion is to use null , in place of ids.

regards,

Naga Raju.

andre_becker
Employee
Employee
0 Kudos

And how can I add the IWDTransparentContainer to the standard RootUIContainer?

Thanks for help!

Kind regards,

Andre

edit:

Ohh, we postet at the same time

Message was edited by: Andre Becker

former_member182372
Active Contributor
0 Kudos
((IWDTransparentContainer)view.getRootElement()).addChild(transparent);
former_member182372
Active Contributor
0 Kudos

Hi Andre,

Did you add <i>transparent</i> to RootUIElementContainer?

Best regards, Maksim Rashchynski.