cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic context typing an atttribute

Former Member
0 Kudos

Hi,

I have an attribute for whose type I need to decide dynamically in runtime.

I have defined two simple types x and y in local dictionary with some predefined enumeration.

I have an attribute x bound to a dropdown by key (selected key).

Why the application I need to show either x or y in the dropdown on some condition.

Can anyone tell me the code for this if this is possible

Ashok

Accepted Solutions (0)

Answers (1)

Answers (1)

gill367
Active Contributor
0 Kudos

Hi Ashok,

try the foolowing code

public void onActionfill(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionfill(ServerEvent)
    String str = wdContext.currentContextElement().getX();
    if(str.equalsIgnoreCase("1"))
    {
		IModifiableSimpleValueSet svs = wdContext.getNodeInfo().getAttribute("value").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
		IModifiableSimpleValueSet svs1 = wdContext.getNodeInfo().getAttribute("firsttype").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
		svs.clear();
		 for(int i = 0 ; i < svs1.size(); i++)
        {
        	svs.put(svs1.getKey(i),svs1.getText(i));
        }
	  
    	
    }
    else
    {
		IModifiableSimpleValueSet svs = wdContext.getNodeInfo().getAttribute("value").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
		IModifiableSimpleValueSet svs2 = wdContext.getNodeInfo().getAttribute("secondtype").getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
		 svs.clear();
		for(int i = 0 ; i < svs2.size(); i++)
			   {
				   svs.put(svs2.getKey(i),svs2.getText(i));
			   }  
    }
    //@@end
  }

there are three simple types present firsttype ,secondtype and value.

value is the type assigned to the particular context variable bound to the dropdownbykey

now on some condition you can assign the either of the two types to the value simpletype and it will be filled in the dropdown.

Thanks,

Sarbjeet Singh.