cancel
Showing results for 
Search instead for 
Did you mean: 

webdynpro populating dropdown values programmatically

Former Member
0 Kudos

Hi Friends,

I knwo how to populate dropdown using simple type, and providing valeus there.

How to do it programmatically to populate the dropdown values, instead of hardcoding the values?

Thanks

Nav

Accepted Solutions (0)

Answers (2)

Answers (2)

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

Check ythis working code in case of node with attribute.

Let the structure is

node1

|

|att1

Let the cardinality of the node is 1:1 or 1:n

IWDNode n=wdContext.getChildNode("node1",0);

IWDNodeInfo nf=n.getNodeInfo();

IWDAttributeInfo attributeInfo =nf.getAttribute("att1");

//wdComponentAPI.getMessageManager().reportSuccess("AttributeInfo:"+attributeInfo);

ISimpleTypeModifiable countryType = attributeInfo.getModifiableSimpleType();

IModifiableSimpleValueSet valueSet = countryType.getSVServices().getModifiableSimpleValueSet();

for (int i = 0; i < 40; i++)

{

valueSet.put("ID"i,"Customer"i);

}

Regards,

Vijayakhanna Raman

Former Member
0 Kudos

Hi Vijayakhanna,

I have to access node in hirarchy node1--has node node2 and node2 has element.

Can you please help me with that epice of code, how to access sub sub node? I mean node inside node

Former Member
0 Kudos

I am able to access the values in View controller context with

ISimpleTypeModifiable countryType1 = dataAttributeInfo1.getModifiableSimpleType();

but not with ,

IModifiableSimpleValueSet dropValueSet =

dataAttributeInfo.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();

why is it so?

is it that with Nodes, I need to access through iSimpleTypeModyfiable?

Former Member
0 Kudos

Nav,

If you have to access node metadata (like attribute types) then:


wdContext.node1().getNodeInfo()
  .getChild("node2")
    .getChild("node3");

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Nav,

Read one of my replies above: it is forbidden to modify type of mapped attribute. Just move your code from view controller to component controller, where original attribute defined.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Thanks a Lott Valery Silaev, I will try in this way and then I will close the thread.

vijayakhanna_raman
Active Contributor
0 Kudos

Hi,

Let the structure is

node1>node2>att2.

Set the property of node2 singleton to false and cardinality to 1:n.

Then the code is.

IWDAttributeInfo attributeInfo2=wdContext.nodeNode1().getChildNode("node2",0).getNodeInfo().getAttribute("att2");

ISimpleTypeModifiable countryType = attributeInfo2.getModifiableSimpleType();

IModifiableSimpleValueSet valueSet = countryType.getSVServices().getModifiableSimpleValueSet();

for (int i = 0; i < 40; i++)

{

valueSet.put("ID"i,"Customer"i);

}

Regards,

Vijayakhanna Raman

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Nav,

See this thread

Regards

Suresh

Former Member
0 Kudos

You can try using a DropDownByIndex. Then you could just manage the values programmatically via context elements.

http://help.sap.com/saphelp_nw04/helpdata/en/4a/8613e41629344194e4f40393740d51/content.htm

Former Member
0 Kudos

It's very interesting question: DropDownByIndex (DDI) vs DDK (DropDownByKey).

Here is how I usually choose between both:


if (I need not to have different values per row in table) {
  if (I do not alter valueset || valueset is from R3) {
    use DDK;
  }
  else if (I may alter valueset) /*Here I need to alter valueset*/ 
  {
    if (I'm creating dynamic UI controls) 
      use DDK; //it is simpler
    else // Design-time controls
      use DDI;
  }
  else {
    use DDI;
  }
}
else {
  use DDI;
}

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

Former Member
0 Kudos

Hi valery Silaev,

its very helpful answer!

Thanks!

Former Member
0 Kudos

Hi Suresh,

It is very helpful answer with code and I am able to access using the code given by you.

Thanks!

Former Member
0 Kudos

Thanks David!

Former Member
0 Kudos

When I am trying to access data Value set with node, I am getting error:-

com.sap.tc.webdynpro.progmodel.context.ContextException: MappedAttributeInfo(<>View.<>.<>.<popupname>): must not modify the datatype of a mapped attribute

Former Member
0 Kudos

Hi Suresh,

can you please help me to dynamically update the values in dropdownByKey for the valueAttribute in a node.

I am able to modify the same without a node, but when I access the node and value attribute of node I get error.

Former Member
0 Kudos

HI,

Have a look at the threads

Regards

Saravanan K

Former Member
0 Kudos

Nav,

Seems that you are modifying valueset of (mapped) attribute type in view controller. Just move your code to component controller, where attribute was originally defined.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com