cancel
Showing results for 
Search instead for 
Did you mean: 

Binding Collection of Objects to display them in DropDownBy.. Control

Former Member
0 Kudos

Hi All,

I have a collection of String Objects And I want to display all these values in a DropDownByKey or Index Control.

I know how to bind a collection to a model node attribute.

As i don't have such a Model node in the context, i am thinking of binding the collection to a value node attribute.

But Binding a collection of String(or some objects) to a value node" attribute is not like like binding the same to a model node" Attribute.

Every Time i bind the collection by

wdContext.nodeFilter().bind(colFilters);// this works if it were a model node

, i get the follwing error.

"you must bind NodeElements to a value node"

i know this thing

IPrivate<ViewName>.I<ValueNode> nod = wdContext.node<Node>();

IPrivate<ViewName>.I<ValueNode>Element ele = null;

ele = nod.create<Node>Element();

and then using set method with ele to set each attribute individually, but this doesn't help me in my scenario

I don't know how to proceed, plz help urgently

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vilish,

The method AnilKumar gave is to be used with DropDownByIndex. There you bind the 'texts' property to an attribute inside a node. Then you can use the code that AnilKumar gave to populate the node.

The method Noufal gave is for DropDownByKey. In this, you have to create a simple type in your Local Dictionary, create an attribute of that type. Then bind the 'selectedKey' of the drop down to this attribute. Then Use the code that Noufal gave to dynamically populate the dropdown.

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Just a mild correction.

If you are using dropdown byKey you do not require a simpleType(not mandatory) in case you are populating it through code. Just a String type value attribute would suffice.

You cna populate the dropdown with the key that I have furnished above.

Former Member
0 Kudos

Thanks all,

Each and Every Response was very helpful.

<b>@Anilkumar,Nibu</b> Using DropDownByIndex, i am able to see the results fine.

<b>@Naufal, Bharathwaj</b>Your help too striking

yes Bharathwaj, i mentioned a wrong value initially but taking Correct value attribute, code is working with no probs But there is nothing inside the DropDownByKey Control though "a" contains the correct value My Code is

IWDAttributeInfo info1 =

wdContext.nodeFilter().getNodeInfo().getAttribute("filterVal");

ISimpleTypeModifiable smtp = info1.getModifiableSimpleType();

IModifiableSimpleValueSet msv =

smtp.getSVServices().getModifiableSimpleValueSet();

Iterator it = colFilters.iterator();

while (it.hasNext()) {

String a = it.next().toString();

msv.put(a,a);

}

it runs but DropDownByKey is empty.Though SelectedKey property points to "filter.filterVal".

<b>@Bharathwaj, NAufal.</b> Just let me know why thereafter i'll close the thread.

Rgds,

Vilish

Former Member
0 Kudos

Hi,

Since its inside the node i think there is no instance f the node available..

Go to cardinality property of the node and set it as 1..1

This will make a instance available for u .. without creating it

or u might be writing it in the wrong place.. where are u writing the code..

Regards

Bharathwaj

Message was edited by: Bharathwaj R

Former Member
0 Kudos

Gr8

Unbeliable you are so fast and furious.

well it's working. But i didn't understand this

"Since its inside the node i think there is no instance f the node available..

Go to cardinality property of the node and set it as 1..1

"

i always have problem with this thing called Cardinality.

Plz put some more light here. Why it worked just changing cardinality (ealiar it was 0..n).

Rgds,

Vilish

Former Member
0 Kudos

Hi

Cardinality corresponds to the minimum and maximum number of node elements it contains.

When its 0..n it means initial state.. no node elements for data storage will be available..

If its 1..1 there is one which is already created.

In the first case,we have to manually write wdContext.node<name>.create<nodename>Element();

and add it to that node..

Regards

Bharathwaj

Message was edited by: Bharathwaj R

Former Member
0 Kudos

Hi Vilish

In Simple Cardinality defines number of records a node can hold at any point of time.

Regards

NagaKishore

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

If u are trying to bind a collection to a value node attribute... what is the type of the value node attribute ..

Is it a java collection object.If yes ,then it should work..?

Assuming this does not work..you can still solve it by using SVS services..

This gets a attribute.. modifies it to a simple type...(something like typecasting.. but the base type will be a normal java type... the terminology i use might not be correct..but i hope u get the point ! )

So it gets a simple type of this attribute.. so you can populate the simple type

Info1 is giving a null pointer exception because the attribute might not be available

In this code <name> is the name of the attrubute in the node <nodename>

IwdAttributeInfo info=wdContext.node<ndoename>().getNodeInfo().getAtrribute(<name>);

ISImpleTYpeModifiable smtp=info.getModifiableSImpleTYpe();

IModifiableSimpleValueSet msv=smtp.getSVServices().getModifiableSimpleValueSet();
iterate the collectin.. get the iterator and 
change these lines as 
String a = it.next().toString()
msv.put(a,a);

Regards

Bharathwaj

Message was edited by: Bharathwaj R...Code added

Former Member
0 Kudos

Hi ,

You can do the following.

Iterate through the collection

{

IPrivate<ViewName>.I<ValueNode>Element ele = nod.create<Node>Element();

ele.setName(it.next().toString());

wdContext.node().addElement(ele);

}

Regards, Anilkumar

Former Member
0 Kudos

if you need to populate the dropDownKey then

IwdAttributeInfo info=wdContext.node<ndoename>().getNodeInfo().getAtrribute(<name>);

ISImpleTYpeModifiable smtp=info.getModifiableSImpleTYpe();

IModifiableSimpleValueSet msv=smtp.getSVServices().getModifiableSimpleValueSet();

msv.put(it.next().toString(),it.next().toString());

Former Member
0 Kudos

Hi,

Well my problem isn't solved yet.

I am using a DropDownByKey Control.

@AnilKumar, when i use ur code, i get the following Exception

java.lang.NullPointerException

at com.sap.tc.webdynpro.clientserver.event.ValueHelpEventHandler$EVSHandler.handle(ValueHelpEventHandler.java:369)

at com.sap.tc.webdynpro.clientserver.event.ValueHelpEventHandler.handleServerEvent(ValueHelpEventHandler.java:116)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleServiceEvent(WindowPhaseModel.java:358)

at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:129)

at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:415)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:101)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:650)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.processRequest(ClientManager.java:155)

at com.sap.tc.webdynpro.clientserver.session.core.ApplicationHandle.doProcessing(ApplicationHandle.java:105)

at com.sap.tc.mobile.mwd.runtime.sal.MwdDispatcher.retrieveDataBlock(MwdDispatcher.java:173)

at com.sap.platin.base.protocol.direct.GuiDirectNetConnection.processDataToServer(GuiDirectNetConnection.java:458)

at com.sap.platin.base.protocol.direct.GuiDirectNetConnection.handleDataToServer(GuiDirectNetConnection.java:192)

at com.sap.platin.base.protocol.GuiMultiplexer.processDataToServer(GuiMultiplexer.java:210)

at com.sap.platin.base.protocol.GuiMultiplexer.handleDataToServer(GuiMultiplexer.java:300)

at com.sap.platin.wdp.protocol.xml.GuiWebDynproXmlToAutomationParser.forwardXmlData(GuiWebDynproXmlToAutomationParser.java:615)

at com.sap.platin.wdp.protocol.xml.GuiWebDynproXmlToAutomationParser.processEventList(GuiWebDynproXmlToAutomationParser.java:558)

at com.sap.platin.wdp.protocol.xml.GuiWebDynproXmlToAutomationParser.handleDataToServer(GuiWebDynproXmlToAutomationParser.java:149)

at com.sap.platin.base.protocol.GuiMultiplexer.processDataToServer(GuiMultiplexer.java:210)

at com.sap.platin.base.protocol.GuiMultiplexer.run(GuiMultiplexer.java:64)

at java.lang.Thread.run(Thread.java:534)

I think i am missing some component as exception is not pointing to any line in my code.

@Noufal, Well i didn't understsnd ur code what it's doing (plz explain). Nevertheless when i used it i got the following exception

An exception during Web Dynpro processing has occurred:

java.lang.NullPointerException

at com.sap.bll.test.comp.QueryExecution2.wdDoInit(QueryExecution2.java:151)

at com.sap.bll.test.comp.wdp.InternalQueryExecution2.wdDoInit(InternalQueryExecution2.java:228)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)

at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)

at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:388)

at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:200)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.getView(ViewManager.java:645)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.bindRoot(ViewManager.java:515)

at com.sap.tc.webdynpro.progmodel.view.ViewManager.init(ViewManager.java:180)

at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.doOpen(WebDynproWindow.java:292)

at com.sap.tc.webdynpro.clientserver.window.ApplicationWindow.open(ApplicationWindow.java:232)

at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:403)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.getApplicationHandle(AbstractClient.java:143)

at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.prepareTasks(AbstractClient.java:216)

at com.sap.tc.webdynpro.clientimpl.scxml.client.SmartClient.prepareTasks(SmartClient.java:487)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:647)

at com.sap.tc.webdynpro.clientserver.cal.ClientManager.parseRequest(ClientManager.java:144)

at com.sap.tc.webdynpro.clientserver.session.core.ApplicationHandle.parseRequest(ApplicationHandle.java:79)

at com.sap.tc.mobile.mwd.runtime.sal.MwdDispatcher.retrieveDataBlock(MwdDispatcher.java:230)

at com.sap.platin.base.protocol.direct.GuiDirectNetConnection.processDataToServer(GuiDirectNetConnection.java:458)

at com.sap.platin.base.protocol.direct.GuiDirectNetConnection.handleDataToServer(GuiDirectNetConnection.java:192)

at com.sap.platin.base.protocol.GuiMultiplexer.processDataToServer(GuiMultiplexer.java:210)

at com.sap.platin.base.protocol.GuiMultiplexer.handleDataToServer(GuiMultiplexer.java:300)

at com.sap.platin.wdp.protocol.xml.GuiWebDynproXmlToAutomationParser.forwardXmlData(GuiWebDynproXmlToAutomationParser.java:615)

at com.sap.platin.wdp.protocol.xml.GuiWebDynproXmlToAutomationParser.processEventList(GuiWebDynproXmlToAutomationParser.java:558)

at com.sap.platin.wdp.protocol.xml.GuiWebDynproXmlToAutomationParser.handleDataToServer(GuiWebDynproXmlToAutomationParser.java:149)

at com.sap.platin.base.protocol.GuiMultiplexer.processDataToServer(GuiMultiplexer.java:210)

at com.sap.platin.base.protocol.GuiMultiplexer.run(GuiMultiplexer.java:64)

at java.lang.Thread.run(Thread.java:534)

This is the line:151 (wdDoInit)

ISimpleTypeModifiable smtp=info1.getModifiableSimpleType();

Plz explain this behaviour

THanks

Rgds,

Vilish