cancel
Showing results for 
Search instead for 
Did you mean: 

Setting dynamic context with actions

0 Kudos

Hey experts,

I have created a new WDJ application running on a SAP EP 7.4. Since our customer has quite special requirements on this one, I needed to use dynamic context and view creation, approx like this:

    IWDTable rfcTable = (IWDTable) view.createElement (IWDTable.class, new String ("rfcTableIdentifierFor" + destinationName));
    rfcTable = formatTable(rfcTable);
 
   
    //dynamic context creation
    IWDNodeInfo nodeInfo = wdContext.getNodeInfo().addChild("RFCDynamicFor" + destinationName, null, false, CMICardinality.MANY, CMICardinality.MANY, false, null);
 
    //Dynamically add attributes to the context node
    nodeInfo.addAttribute("system", "com.sap.dictionary.string"); //System
.........

    nodeInfo.addAttribute("firstVisible", "com.sap.dictionary.integer"); //first visible
    nodeInfo.addAttribute("popinKey", "com.sap.dictionary.string"); //popin key
    nodeInfo.addAttribute("popinStatus", "com.sap.dictionary.boolean"); //popin status
    nodeInfo.addAttribute("iconSource", "com.sap.dictionary.string"); //popin icon image source

    rfcTable.bindDataSource("RFCDynamicFor" + destinationName);
    rfcTable.bindFirstVisibleRow("RFCDynamicFor" + destinationName + ".firstVisible");

Im also creating some columns with binded content on my dynamic context, this all works well so far. In fact Im following Dynamic UI Generation - Web Dynpro Java - SCN Wiki on this task

So here comes the problem: my dynamic table has also a popin column:

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos
    //popin button column
    IWDTableColumn popinColumn = view.createElement(IWDTableColumn.class); 
    IWDCaption popinColumnHeader = view.createElement(IWDCaption.class);
    popinColumnHeader.setText("Zoom");
    popinColumn.setHeader(popinColumnHeader);
popinColumn.setHAlign(WDTableColumnHAlign.valueOf("center"));
popinColumn.setWidth("40px");
    IWDLinkToAction linkToAction = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, "LinkToAction" + destinationName);
    linkToAction.bindImageSource("RFCDynamicFor" + destinationName + ".iconSource");
    IWDAction popinToggleAction = view.getAction("onPopinToggle");
linkToAction.setOnAction( popinToggleAction );
linkToAction.mappingOfOnAction().addSourceMapping("nodeElement", "row");
popinColumn.setTableCellEditor(linkToAction);
rfcTable.addGroupedColumn(popinColumn);
0 Kudos

So popin toggle action is defined as follows:

  public void onActionOnPopinToggle(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, com.sap.tc.webdynpro.progmodel.api.IWDNodeElement row )

  {

    //@@begin onActionOnPopinToggle(ServerEvent)

   if(row.getAttributeAsText("popinStatus").equalsIgnoreCase("true")){

   row.setAttributeValue("popinKey", "");

   row.setAttributeValue("popinStatus", false);

   row.setAttributeValue("iconSource", "~Icon/Add");

   }

   if(row.getAttributeAsText("popinStatus").equalsIgnoreCase("false")){

   row.setAttributeValue("popinKey", "PopinId");

   row.setAttributeValue("popinStatus", true);

   row.setAttributeValue("iconSource", "~Icon/Remove");

   }

    //@@end

  }

As we can see Im using the generic class com.sap.tc.webdynpro.progmodel.api.IWDNodeElement row for parameter passing, since if you creating context dynamically you dont have classes like I<your>Node. At the same time SAP says you need always to create actions on design time, even you are using them dynamically, it cant work otherwise.

So, if Im debugging this action Im noticing the handler is running through it if Im klicking on my popin button as desired and is able to read / set properties, I have no exceptions while runtime and cant see any problems in the developer log. However, if Im klicking the button again and running a second time through the action handler, Im noticing my impression it is working properly is wrong, since setting attributes doesnt works at all. It means if Im klicking the button a second time popinStatus is still false, even it was set to true while first action execution.

Corresponding to this problem, popin of course dont work, so Im missing the expected runtime behaviour here. Do you guys have any ideas what is running wrong? Thank you very much in advance,

best regards