cancel
Showing results for 
Search instead for 
Did you mean: 

get a UI instance at runtime

Former Member
0 Kudos

Hallo everyone,

i have a question about UI element instance at runtime: i have a table at design time (static), however its column must be mapped into 2 different context nodes according to the event at runtime. So... is it possible, that context mapping of UI element at runtime? How can i get the table instance at runtime so that i can write binding codes for it?

Thannk for Ur patience!

best regards!

Mao

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hello you all,

thanks so much for replying my question, your answer is very helpful for me. I would like to reward point on each of you, but it seems to be disable at this moment cause i have forgotten to setting something while i composed this question.

best regards!

Mao

former_member201361
Active Contributor
0 Kudos

hi,

yea we can create a table at runtime in the domodify () method .

see the code below:

if(firstTime){

IWDGroup theGroup = (IWDGroup)view.getElement("InputGroup");//id of the Group

IWDUIElement element = null;

IWDLabel label = view.createElement(IWDLabel.class);

label.setText("Count");//creating a label

IWDInputField input = view.createElement(IWDInputField.class,"inp");//creating a Input field

input.setLength(20);

input.bindValue("DynamicNode.input");//binding the inputfield to the context Attribute.

element = input;

IWDTable table = view.createElement(IWDTable.class);//creating a table

IWDTableColumn column = view.createElement(IWDTableColumn.class);//creating a column.

IWDLinkToAction linktoaction = (IWDLinkToAction) view.createElement(IWDLinkToAction.class);//adding a table cell editor (link to action).

IWDAction action = view.getAction("Action");//setting a action for the link to action .

//note here Action is the name of the action created for the linktoaction.

linktoaction.setOnAction(action);

linktoaction.bindText("test.test");//binding to the context Attribute

linktoaction.setEnabled(true);

linktoaction.setImageFirst(true);

linktoaction.setVisible(WDVisibility.VISIBLE);

column.setTableCellEditor(linktoaction);

IWDCaption caption = view.createElement(IWDCaption.class);//header for the table.

caption.setText("header");

column.setHeader(caption);

IWDNodeInfo node = wdContext.nodeTest().getNodeInfo();

table.bindDataSource(node);//binding the datasource property for the table.

table.setEnabled(true);

table.setFooterVisible(true);

table.setRowSelectable(true);

table.setVisibleRowCount(5);

table.setDisplayEmptyRows(true);

table.setSelectionMode(WDTableSelectionMode.AUTO);

table.addColumn(column);

theGroup.addChild(label);

theGroup.addChild(element);

theGroup.addChild(table);

}

hope this helps u

thanks and regards

fazal

Former Member
0 Kudos

Hi Mao, in WebDynpro Views exist a method called wdDoModifyView(), this method is executed by the framework in every request/response cycle, so with an "IF" condition (for example) you can build block of code for manipulate UI elements. To get an object's instance in this method, you must know the UIElement ID's.

For example, you can get the table instance, you can use the follow code:


wdDoModifyView(IPrivate<viewName> wdThis, IPrivate<viewName>.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime){
   if (wdContext.currentContextElement().get<contextBooleanAtribute>){ // This Attribute is modifiable in any other method of this view
      IWDTable table = (IWDTable)view.getElement(<id>);
      .........
      .........
      .........
   }
}

Then with the "table" object you can acces to the method bind() and change the node binding in runtime.

I hope this help you, in SDN exist a lot of information for the dynamic UI manipulation.

Regards,

Simon.

former_member197348
Active Contributor
0 Kudos

Hi Mao,

In wdDoModifyView()

you can get the instance of the table at runtime

IWDTable table = (IWDTable)view.getElement( "Table_Id"); // you can find in properties

you can use

table.XXX() methods.

if you want to do context mapping of UI element like InputField at runtime, do like this:

WDInputField input = (IWDInputField) view.getElement("id_element");

IWDAttributeInfo attr = wdContext.getNodeInfo().getAttribute(<name of the context attribute>);

input.bindValue(attr);

regards,

Siva