cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically recreating (!) context attributes and table columns

michael_voss2
Participant
0 Kudos

Hello everybody!

We are trying to build a WebDynpro view which shows a table with some GroupedColumns unknown at design time.

Creating these and the corresponding context attributes underneath a fixed node works well, but when we try to create new attributes and table columns in the next roundtrip (after destroying the previously created ones, of course), I get a

java.lang.NullPointerException while invoking the method com.sap.tc.webdynpro.progmodel.context.AttributeInfo.isNodeMapped() of a null object loaded from an Array (which itself was loaded from field com.sap.tc.webdynpro.progmodel.context.NodeInfo.attributes of an object) with an index loaded from local variable 'i'

when trying to establish the context mapping between the local node inside my view's context and the corresponding node in the component controller context using

localNode.getNodeInfo().setMapping(ccNode.getNodeInfo(), true);

basically from inside the wdDoModifyView() method. When I call that method, there are no attributes defined for the node. Since I create mapped attributes afterwards (localNode.getNodeInfo().addMappedAttribute(someName, someName)), the parent nodes have to be mapped before.

When I create the set of context attributes and columns first, this works fine, but on the second roundtrip, this fails. I need the context mapping to be able to filter the table contents.

Does anyone have any idea on that? I'd like to be able to do this inside a single roundtrip in a single view without having to navigate to another view that is being recreated every tiem.

Thanks in advance

Michael

Accepted Solutions (1)

Accepted Solutions (1)

michael_voss2
Participant
0 Kudos

O.k. finally managed to recreate the nodes: I had to destroy all table columns, then invalidate the local node and the mapped component controller node and finally remove all IWDAttributeInfos from all nodes (local data node, local filter node and component controller node) by iterating over the attribute infos provided by each nodes nodeInfo:

   IWDTable table = (IWDTable)view.getElement("Table_0");

  table.destroyAllGroupedColumns();

   IWDNode ccNode = wdThis.wdGetDiagnoseCompController().wdGetAPI().getContext().getRootNode().getChildNode("DynamicTableNode", IWDNode.LEAD_SELECTION);

   IWDNode localNode = wdContext.getChildNode("DynamicTableNode", IWDNode.LEAD_SELECTION);

   IWDNode filterNode = wdContext.getChildNode("DynamicFilterNode", IWDNode.LEAD_SELECTION);

  

   localNode.invalidate();

   ccNode.invalidate();

   Iterator<? extends IWDAttributeInfo> aIt = ccNode.getNodeInfo().iterateAttributes();

   while (aIt.hasNext()) {

   IWDAttributeInfo info = aIt.next();

   info.remove();

   };

  

   Iterator<? extends IWDAttributeInfo> bIt = localNode.getNodeInfo().iterateAttributes();

   while (bIt.hasNext()) {

   IWDAttributeInfo info = bIt.next();

   info.remove();

   };

   Iterator<? extends IWDAttributeInfo> fIt = filterNode.getNodeInfo().iterateAttributes();

   while (fIt.hasNext()) {

   IWDAttributeInfo info = fIt.next();

   info.remove();

   };

Answers (0)