cancel
Showing results for 
Search instead for 
Did you mean: 

How to refresh The Dynamic ui element of WdoModifyView

former_member305573
Participant
0 Kudos

Hi All

I have a requirement in which i have to refresh the Dynamic Uielement.

Let Me explain The scenario.

I have developed one screen where some Link to action is created dynamically. I have written the Code for that In WdoModifyView. So first time when Screen is loading then it is working fine. But Now in the same screen i have to Perform some Action On the Button. Where that all that value should get refreshed and new set of data should come into the link to action. Kindly See my code Below

if(firstTime) 
    { 
IWDTransparentContainer transContNNOrgUnit = (IWDTransparentContainer)view.getElement("transContNNOrgUnit"); 
IWDTransparentContainer transContNNTotalRec = (IWDTransparentContainer)view.getElement("transContNNTotalRec"); 
IWDTransparentContainer transContNNNoRec = (IWDTransparentContainer)view.getElement("transContNNNoRec"); 
//nursing container 
IWDTransparentContainer transContNOrgUnit = (IWDTransparentContainer)view.getElement("transContNOrgUnit"); 
IWDTransparentContainer transContNTotalRec = (IWDTransparentContainer)view.getElement("transContNTotalRec"); 
IWDTransparentContainer transContNNoRec = (IWDTransparentContainer)view.getElement("transContNNoRec"); 
//self recomendation container 
IWDTransparentContainer transContSOrgUnit = (IWDTransparentContainer)view.getElement("transContSOrgUnit"); 
IWDTransparentContainer transContSTotalRec = (IWDTransparentContainer)view.getElement("transContSTotalRec"); 
IWDTransparentContainer transContSNoRec = (IWDTransparentContainer)view.getElement("transContSNoRec"); 
//reading the data from the organization unit 
IPublicPromo.IOrg_UnitNode orgUnitRFCNode = wdThis.wdGetPromoController().wdGetContext().nodeOrg_Unit(); 
IPublicPromo.IOrg_UnitElement orgUnitRFCElement = null; 

IPublicCustSupervisor.IOrg_UnitSpOrgNode orgUnitRFC_SPNode = wdThis.wdGetCustSupervisorController().wdGetContext().nodeOrg_UnitSpOrg(); 
IPublicCustSupervisor.IOrg_UnitSpOrgElement orgUnitRFC_SPElement = null; 


IWDLinkToAction linkToAction = null; 
IWDTextView textView = null; 
IWDTextView textView1 = null; 
IWDAction genericEventAction = null; 
WDActionEventHandler actHandler = null; 

IWDGridData gridData1 = null; 
IWDGridData gridData2 = null; 


if(application.equalsIgnoreCase(Constants.ApplSup)){ 


for(int i = 0 ; i < orgUnitRFC_SPNode.size(); i++) 
{ 
orgUnitRFC_SPElement = orgUnitRFC_SPNode.getOrg_UnitSpOrgElementAt(i); 

if(orgUnitRFC_SPElement.getType().equalsIgnoreCase(Constants.NNURRecommend_Mode)) 
{ 
linkToAction = (IWDLinkToAction)view.createElement(IWDLinkToAction.class,"linkToNNAction" + orgUnitRFC_SPElement.getOrgeh()); 
linkToAction.setText(orgUnitRFC_SPElement.getStext()); 
linkToAction.mappingOfOnAction().addParameter("orgUnit",orgUnitRFC_SPElement.getOrgeh()); 
//setting the action to the Link to action created 
actHandler = WDActionEventHandler.PROMOTION_N_NUR; 
genericEventAction = wdThis.wdCreateAction(actHandler,"PromotionNNur"); 
transContNNOrgUnit.addChild(linkToAction); 
//getting the total number of recommendations 
textView = (IWDTextView)view.createElement(IWDTextView.class,"txtViewNNTotal" + orgUnitRFC_SPElement.getOrgeh()); 
textView.setText(String.valueOf(orgUnitRFC_SPElement.getTotal())); 
transContNNTotalRec.addChild(textView); 

gridData2 = (IWDGridData)textView.createLayoutData(IWDGridData.class); 
gridData2.setHAlign(WDCellHAlign.CENTER); 
gridData2.setColSpan(1); 

//getting the no recommended 
textView1 = (IWDTextView)view.createElement(IWDTextView.class,"txtViewNNNoRec" + orgUnitRFC_SPElement.getOrgeh()); 
textView1.setText(String.valueOf(orgUnitRFC_SPElement.getNo_Rec())); 
transContNNNoRec.addChild(textView1); 

gridData1 = (IWDGridData)textView1.createLayoutData(IWDGridData.class); 
gridData1.setHAlign(WDCellHAlign.CENTER); 
gridData1.setColSpan(1);

}

This code is working fine for First time . When I am commenting the First time so that when ever screen render it will call the method. Then i am getting Below Eroor.

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "linkToNNAction50000076" of type com.sap.tc.webdynpro.clientserver.uielib.standard.impl.LinkToAction

Kindly Help me with your suggestion . How to achieve the Solution.

Thanx in Advance.

Prashant Krishen.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Prashant,

Then i am getting Below Eroor.

com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: View: Cannot add element with duplicate ID "linkToNNAction50000076" of type com.sap.tc.webdynpro.clientserver.uielib.standard.impl.LinkToAction

Well as per basic of WdModify() calling, wil call every time any action will take place. If you comment the first time logic you will get above error because you are trying to create

again new UI with the existing name.

You have to use first time logic for creating the UI and now question is how to refresh the UI.?

Try to work on the if/else logic. In else re-populate the UI, the way you have done in the if block.

Hope this may help you.

Deepak!!!

former_member305573
Participant
0 Kudos

Dear Shyam and Deepak

I tried in Else also. But Duplicate ID error still there. If i am not creating the UI element and trying to write the code in Else condition than i am getting Null pointer error. Because the UI element not created again Dynamically.

My main concern is just to refresh the current Link to action node. so that the fresh data should come there in the screen.

Prashant.

Former Member
0 Kudos

Hi Prasanth,

Please dont try to create the element again in the else part. Create the element in the If part. Then access it in the else part using the GetElement() method. This wont throw any exception.

Please paste your code here if possible.

Regards,

Shyam.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Prasanth,

Write your code in the else part.

ie,

if(firsttime)

{

}

else

{

//write your code here

}

Also, in the else part dont use the createelement() method. It will throw an error since the element is already there. Instead, use the getelement() method.

Please let me know the result.

Thanks and Regards,

Shyam.

Edited by: Shyam Gopal on Jul 24, 2010 11:41 AM