cancel
Showing results for 
Search instead for 
Did you mean: 

How to keep isChangedbyClient flag set between roundtrips?

Former Member
0 Kudos

Hi Brothers,

I am implementing a function that is supposed to put all changes made in a table into a node. I wrote the following code, which unfortunately provides only the changes I made since the last roundtrip (press of "Validate" Button that causes the function to be executed).

The reason is that the isChangedByClient flag seems to be reset between roundtrips...

Is there a way to avoid this, that is to keep the isChangedByClient set and thus remember all changes??

  public void onActionValidateChangesCustomer(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionValidateChangesCustomer(ServerEvent)
	  
	  // remove all elements from node
	  wdContext.nodeChangedCustomerRows().invalidate();
	  
	  // iterate over all rows of customer table
	  for( int i=0; i < wdContext.nodeE_Customer().size(); i++ ){
		  		  
		  // check weather a row has changed
		  IE_CustomerElement e = wdContext.nodeE_Customer().getE_CustomerElementAt(i);
		  if (e.isChangedByClient()){
			// copy the changed row to the ChangedCustomerRow node
			  WDCopyService.copyCorresponding(wdContext.nodeE_Customer().getE_CustomerElementAt(i), 
					  wdContext.currentChangedCustomerRowsElement());
			  
				  wdContext.nodeChangedCustomerRows().addElement(new __Bic__Mrbkunde());
				  // move from current to new one
				  wdContext.nodeChangedCustomerRows().moveNext();
		  }
		  
		  wdContext.nodeE_Customer().moveNext();
	  }
	  
	  // trigger the RFC
	  wdThis.wdGetInfoObjectCustController().executeZ_Customer_Front_Controller();
	  
	  // reset changed flag
	  //wdContext.wdGetAPI().resetChangedByClient();
	  

    //@@end
  }

I appreciate helpfull posts.

Thanks, Johannes

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

According to Javadoc its must be keep until a reset call:

"Returns true if the changedByClient has been set for this element. This flag will be set by the framework when an update from the client arrives. It remains true until you reset all flags in the complete context via IWDContext.resetChangedByClient().

Since this flag is kept per element, but each attribute may actually live in a different element, Web Dynpro always marks both the mapped element and the origin element marked if an attribute is changed. This has the consequence that IWDContext.resetChangedByClient() must always be called from the context in which you will look for client changes.

Returns:

true if the changedByClient has been set for this element or false otherwise."

Maybe you can try a workaround, trying to set the changed newly using the method change.

if (e.isChangedByClient()){
			// copy the changed row to the ChangedCustomerRow node
			  WDCopyService.copyCorresponding(wdContext.nodeE_Customer().getE_CustomerElementAt(i), 
					  wdContext.currentChangedCustomerRowsElement());
			  
				  wdContext.nodeChangedCustomerRows().addElement(new __Bic__Mrbkunde());
				  // Here set the changed to whole element
                                 e.changed(null); 
                                 // move from current to new one
                                 
				  wdContext.nodeChangedCustomerRows().moveNext();
		  }

Maybe you will need to combine isChangedByClient and isChange

Best regards

Former Member
0 Kudos
e.changed(null);

didn't work (null pointer, obviously...)

but

e.isChanged();

finally resolved this issue...

Thanks, Buddy

Former Member
0 Kudos

Hi,

I think it is a bug because javadoc says that a parameter null set all attribute as change.

https://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/progmodel/api/IWDNodeElement.htm...

But the important is that the problem was solved.

Best regargs