cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic webdynpro

Former Member
0 Kudos

Hi All

I would like to create some GUI component dynamically via webdynpro java.

I have a context node (regular node u2013 not dynamic) which its elements attribute represent the requested GUI component. How can I run by for loop on this node and create and bind new GUI component (for example IWDTextEdit) dynamically? Should I create other dynamic node or can I use existing not dynamic node?

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Yoni,

Welcome to SDN. If I understood your requirement correctly. You have one node.You want to create UI elements dynamically and bind them with your node/table values. You can try like this

in wdDoModifyView write this code:

if(firstTime)
	{
IWDTransparentContainer root = (IWDTransparentContainer) view.getElement("RootUIElementContainer");
for (int i = 0; i < wdContext.node<yournode>().size(); i++) {
// Creating Text View	
IWDTextView tView = (IWDTextView)view.createElement(IWDTextView.class, "TextView"+i);
tView.setText((String) wdContext.node<yournode>().get<yournode>ElementAt(i).get<yourAttribute>());
root.addChild(tView);	
			
// Creating Text Edit
IWDTextEdit tEdit = (IWDTextEdit)view.createElement(IWDTextEdit.class, "TextEdit"+i);
tEdit.setValue((String) wdContext.node<yournode>().get<yournode>ElementAt(i).get<yourAttribute>());
root.addChild(tEdit);
	}
}

Regards,

Siva

Former Member
0 Kudos

Thank you for your response.

In this case the node attributes are not bound to GUI components.

For sample if I change the value of TextEdit which you created in sample

code it is not influence on the context attribute.

Is any way to bound the attibutes to the GUI components ?

Regars

Yoni

vmadhuvarshi_
Contributor
0 Kudos

Yoni,

You can create View as well as Context of a Web Dynpro application dynamically. Binding UI elements with context at runtime is also easily possible. The basic process for dynamic UI generation is given below.

1. Obtain a reference to RootUIElementContainer.

IWDTransparentContainer container = (IWDTransparentContainer)view.getRootElement() 

2. Assign the desired layout Manager to RootUIElementContainer if entire view is being created dynamically. I've assigned RowLayout.

container.createLayout(IWDRowLayout.class) 

3. Create desired UI element/s.

IWDTextView textView = (IWDTextView)view.createElement(IWDTextView.class, "SomeText") 

4. Set UI elemnts's properties and add to RootUIElementContainer.

textView.setText("Text here");
         textView.setDesign(WDTextViewDesign.HEADER2);
         container.addChild(textView);

Please follow [this tutorial|https://www.sdn.sap.com/irj/sdn/nw-wdjava?rid=/webcontent/uuid/503f22f6-b978-2a10-bf97-ddc21267e752#34] to learn the process of UI generation in detail.

These links may be helpful as well.

1. [Dynamic UI Generation|http://help.sap.com/saphelp_nw04/helpdata/en/4f/07cf3dd28b5610e10000000a114084/frameset.htm].

2. [Dynamic UI Generation in Web Dynpro for Java|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/WDJava/Dynamic%2bUI%2bGeneration]

3. [Dynamic User Interface Generation in Web Dynpro for Java - Use and Implementation|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/7765]

Hope this helps.

Vishwas.

Former Member
0 Kudos

For editable UI elements you have of course to bind the edited properties.

Example:


Context:
- value (string)

wdDoModifyView(...)
{
  if ( UI needs to be updated )
  {
    IWDTransparentContainer dynamicArea = (IWDTransparentContainer) view.getElement("id_of_area");
    dynamicArea.destroyAllChildren();
    IWDTextEdit edit = (IWDTextEdit) view.createElement(IWDTextEdit.class, "textEdit");
    IWDAttributeInfo valueAttr = wdContext.getNodeInfo().getAttribute(IContextElement.VALUE);
    edit.bindValue(valueAttr);
    dynamicArea.addChild(edit);
    /* details about layout and layout data omitted */
  }
}

Armin

Answers (0)