cancel
Showing results for 
Search instead for 
Did you mean: 

binding drop down by key to integer

PradeepBondla
Active Contributor
0 Kudos

Hi all,

I have one doubt, Can I map the drop down by key to a integer type attribute?

In the properties of drop down by key I mapped "selected Key" property to a "int" type value attribute, and its giving following error....

java.lang.IllegalArgumentException: Cannot format given Object as a Number

at java.text.NumberFormat.format(NumberFormat.java:219)

at java.text.Format.format(Format.java:133)

at com.sap.dictionary.runtime.DdTypeNumber.format(DdTypeNumber.java:48)

at com.sap.dictionary.runtime.DdSimpleType.toString(DdSimpleType.java:335)

at com.sap.tc.webdynpro.progmodel.context.ModifiableSimpleType.toString(ModifiableSimpleType.java:936)

Could any one explain me the problem.

Note: same is working if I map it to a "string" type attribute.

my dropdown by key code is

if(wdContext.nodePstatus_out().size()!=0)
	{
		IWDAttributeInfo pStatAttInfo=wdContext.nodePstatus_out().getNodeInfo().getAttribute("Zad_Counter");
		ISimpleTypeModifiable pStatSMT= pStatAttInfo.getModifiableSimpleType();
		IModifiableSimpleValueSet pStatSimpValSet= pStatSMT.getSVServices().getModifiableSimpleValueSet();
		pStatSimpValSet.clear();
		//pStatSimpValSet.put(null,null);
		if(wdContext.nodePstatus_out().size()>0)
		{
		  for(int pCount=0; pCount<wdContext.nodePstatus_out().size();pCount++)
		  {
			pStatSimpValSet.put(Integer.toString(wdContext.nodePstatus_out().getPstatus_outElementAt(pCount).getZad_Counter()),wdContext.nodePstatus_out().getPstatus_outElementAt(pCount).getZad_Char_Text());
		  }
	    }
	}

Here "zad_Counter" is the integer type value attribute.

regards,

Pradeep

Accepted Solutions (1)

Accepted Solutions (1)

former_member182294
Active Contributor
0 Kudos

Hi Pradeep,

As you are using integer as type, you should pass <b>Integer</b> object as key. Try the following:

pStatSimpValSet.put(<b>new Integer</b>(wdContext.nodePstatus_out().getPstatus_outElementAt(pCount).getZad_Counter()), wdContext.nodePstatus_out().getPstatus_outElementAt(pCount).getZad_Char_Text());

Regards

Abhilash

PradeepBondla
Active Contributor
0 Kudos

Hi Abhilash,

your solution sounds cool, let me try and give rewards

PradeepBondla
Active Contributor
0 Kudos

Hi Abilash,

My problem is solved. But one small thing left out...

Actually on click of "clear all" button, I am clearing the drop down by keys. previously there was all string type attributes mapped to drop down by keys, so what I did is...

wdcontext.currentNODE.setXXX(" ");

with above line I cleared all the dropdowns previously.

But now, I mapped drop down to Integer type, so I can not use above line to print empty space (to clear). What I need to do to clear the drop down by key.

Thanks n regards

Pradeep

former_member182294
Active Contributor
0 Kudos

Hi Pradeep,

Sorry for the late reply, I was busy with other work.

While populating the SimpleModifiableValueSet add a blank value.

valueSet.put(new Integer(0)," ");

Then on action of clear

wdcontext.currentNODE.setXXX(0);

Regards

Abhilash

monalisa_biswal
Contributor
0 Kudos

Use

wdContext.current<Node>Element().set<attribute>(null);

Answers (1)

Answers (1)

former_member197348
Active Contributor
0 Kudos

Hi Pradeep,

We can not use integer type to map to key/index of drop down. you need to type cast to string like <integer>+"".

regards

Siva

PradeepBondla
Active Contributor
0 Kudos

Dear siva,

Its giving same error... previously I did not mapped the key to integer in "put" method, I did Integer.toString(<int>).

If I do as you said, still its giving same error.

former_member197348
Active Contributor
0 Kudos

Hi Pradeep,

I mean you can not use <int> type because put accepts (Object,String) but you can use (String, String). I think you are getting problem because it is not going into loop. Before loop do as the following

put(" ", "Select any value");

// Don't use put(null,null); it will cause same probelm

Hope it will resolve your problem.

regards,

Siva