Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How toadd com.sap.tc.webdynpro.programmodel.api.IWDNode returntype tomethod

Hi,

can u tell me how to create supply function???

i just gone through the PDF(Advanced Input Help - The Object Value Selector (OVS))

In that he created supplufunction and 4 methods

1)getOVSInputNode-com.sap.tc.webdynpro.programmodel.api.IWDNode

2)getOVSListener-com.sap.tc.webdynpro.programmodel.api.IWDOVSContextNotificationlistener

3)getOVSOutputtNode-com.sap.tc.webdynpro.programmodel.api.IWDNode

4)SwithchOVSListener-String

Can u plz tell me how to get these return types and how to create supply function just by clicking new in methods tab

Former Member
Former Member replied

Hi Padma

Follow These Steps of Implementing <i>Object Value Selector</i>

<u><b>Component Controller</b></u>

Create the Following Contexts in Component Controller

Node1(Name,Location)

Node2(Name,Age,Location)

Source(Name,Age,Location)

/*All are Type String*/

Add the Following Code in Component Controller

public void wdDoInit()
  {
    //@@begin wdDoInit()
    String name[] = {"Arun","Boopathi","Bala"};
    String age[] = {"24","22","24"};
    String location[] = {"Erode","Gobi","Gingee"};
    
    IPublicOVS_Model_Comp.ISourceElement ele;
    
    for(int i=0;i<name.length;i++)
    {
    	ele = wdContext.nodeSource().createSourceElement();
    	ele.setName(name<i>);
    	ele.setAge(age<i>);
    	ele.setLocation(location<i>);
    	wdContext.nodeSource().addElement(ele);
    	
    }
        
    //@@end
  }

<b>Create a inner Class called ovslist between the begin and others in the Component controller which is found at the end of the code. If you created somewhere the coding will be lost. After creating the class type app and pres ctrl space you will be shown the list of api's with apply input values, on querry and apply result</b>

//@@begin others
  public class ovslist implements IWDOVSContextNotificationListener
  {
  	
  	/* (non-Javadoc)
	 * @see com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener#applyInputValues(com.sap.tc.webdynpro.progmodel.api.IWDNodeElement, com.sap.tc.webdynpro.progmodel.api.IWDNodeElement)
	 */
	public void applyInputValues(IWDNodeElement applicationNodeElement,IWDNodeElement queryInputNodeElement)
	{
		// TODO Auto-generated method stub
		
		queryInputNodeElement.setAttributeValue("Name",applicationNodeElement.getAttributeAsText("Name"));
		queryInputNodeElement.setAttributeValue("Location",applicationNodeElement.getAttributeAsText("Location"));

	}
	
	/* (non-Javadoc)
	 * @see com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener#onQuery(com.sap.tc.webdynpro.progmodel.api.IWDNodeElement, com.sap.tc.webdynpro.progmodel.api.IWDNode)
	 */
	public void onQuery(IWDNodeElement queryInputNodeElement,IWDNode queryOutputNode)
	{
		// TODO Auto-generated method stub
		
		IPublicOVS_Model_Comp.INode1Element input = (IPublicOVS_Model_Comp.INode1Element)queryInputNodeElement;
		IPublicOVS_Model_Comp.INode2Node output = (IPublicOVS_Model_Comp.INode2Node)queryOutputNode;
		
		String str_name = queryInputNodeElement.getAttributeAsText("Name");
		String str_location = queryInputNodeElement.getAttributeAsText("Location");
		
		String name_str = " ";
		String location_str = " ";
		String age_str = " ";
		
		boolean one,two;
		
		for(int i=0;i<wdContext.nodeSource().size();i++)
		{
			one = two = true;
			name_str = wdContext.nodeSource().getSourceElementAt(i).getName();
			location_str = wdContext.nodeSource().getSourceElementAt(i).getLocation();
			age_str = wdContext.nodeSource().getSourceElementAt(i).getAge();
			
			if(str_name.length()!=0)
			{
				one = str_name.matches(name_str);
			}
			
			if(str_location.length()!=0)
			{
				two = str_location.matches(location_str);
			}
			
			if(one && two)
			{
				IPublicOVS_Model_Comp.INode2Element ele = output.createNode2Element();
				ele.setName(wdContext.nodeSource().getSourceElementAt(i).getName());
				ele.setAge(wdContext.nodeSource().getSourceElementAt(i).getAge());
				ele.setLocation(wdContext.nodeSource().getSourceElementAt(i).getLocation());
				wdContext.nodeNode2().addElement(ele);
			}
		}
	}
	
	/* (non-Javadoc)
	 * @see com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener#applyResult(com.sap.tc.webdynpro.progmodel.api.IWDNodeElement, com.sap.tc.webdynpro.progmodel.api.IWDNodeElement)
	 */
	public void applyResult(IWDNodeElement applicationNodeElement,IWDNodeElement queryOutputNodeElement)
	{
		// TODO Auto-generated method stub
		
		IPrivateOVS_Model_View.IView_DisplayElement disp = (IPrivateOVS_Model_View.IView_DisplayElement)applicationNodeElement;
		
		IPublicOVS_Model_Comp.INode2Element out = (IPublicOVS_Model_Comp.INode2Element)queryOutputNodeElement;
		
		disp.setAttributeValue("Name",out.getAttributeAsText("Name"));
		disp.setAttributeValue("Age",out.getAttributeAsText("Age"));
		disp.setAttributeValue("Location",out.getAttributeAsText("Location"));	

	}

  }
  
  //@@end
}

<b>Create a method ovslistener with the return type , while creating the method chosse return type in that select java native type and click browse,you will be showned a window Java Native Type Selection in that type IWDovscontextnotificationlistener and select that return type displayed click ok</b>.

public com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener ovs_listener( )
  {
    //@@begin ovs_listener()
    ovslist ovslist_obj = new ovslist();
    return ovslist_obj;
    //@@end
  }

***********************************************************************************************

<u><b>View Controller</b></u>

Create the Following Context

View_Display(Name,Age.Location) /* All are type String only */

Create the UI Elements for the Name age location

public void wdDoInit()
  {
    //@@begin wdDoInit()
    IWDAttributeInfo info[] = {wdContext.nodeView_Display().getNodeInfo().getAttribute("Name"),wdContext.nodeView_Display().getNodeInfo().getAttribute("Location")};
    IWDOVSContextNotificationListener obj = wdThis.wdGetOVS_Model_CompController().ovs_listener();
    WDValueServices.addOVSExtension(" ",info,wdThis.wdGetOVS_Model_CompController().wdGetContext().nodeNode1(),wdThis.wdGetOVS_Model_CompController().wdGetContext().nodeNode2(),obj);
    
    //@@end
  }

public static void wdDoModifyView(IPrivateOVS_Model_View wdThis, IPrivateOVS_Model_View.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
  {
    //@@begin wdDoModifyView
    
    IWDAttributeInfo name = wdThis.wdGetOVS_Model_CompController().wdGetContext().nodeNode1().getNodeInfo().getAttribute("Name");
    name.getModifiableSimpleType().setFieldLabel("Name");
    IWDAttributeInfo location =wdThis.wdGetOVS_Model_CompController().wdGetContext().nodeNode1().getNodeInfo().getAttribute("Location");
    location.getModifiableSimpleType().setFieldLabel("Location");
    
    //@@end
  }

<b>Let me know You Understand My Code or Not

Regards

Chandran</b>

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question