cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the value of a context created dynamically ?

Former Member
0 Kudos

Hello,

I've created a checkbox dynamically like this:

IWDCheckBox box = (IWDCheckBox) view.createElement(IWDCheckBox.class, null);

box.setText("Roy");

wdContext.getNodeInfo().addAttribute(new String("Praticipant1"),"com.sap.dictionary.boolean");

box.bindChecked(wdContext.getNodeInfo().getAttribute("Praticipant1"));

I would like, later in the code to see if this checkbox is checked. How do I get the value off the context that I've created above?

Regards,

Roy

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos
Boolean checked = (Boolean) wdContext.currentContextElement().getAttributeValue("Praticipant1");

Armin

Former Member
0 Kudos

That simple ha? Thank you very much Armin.

Former Member
0 Kudos

Yes, and as a matter of style, I would write

IWDAttributeInfo attrib = wdContext.getNodeInfo().addAttribute("Participant1", "ddic:com.sap.dictionary.boolean");
box.bindChecked(attrib);

instead of your original code:

wdContext.getNodeInfo().addAttribute(new String("Praticipant1"),"com.sap.dictionary.boolean");
box.bindChecked(wdContext.getNodeInfo().getAttribute("Praticipant1"));

Armin

Former Member
0 Kudos

What is the difference between your code an mine?

Former Member
0 Kudos

Roy,

1. String a = "ABC" uses string from constant pool directly, String a = new String("ABC") create an object as a copy to string from constant pool. Do you need an extra object for garbage collector to play with. I guess no

2. In Armin's code you create and save reference to newly create attribute info in one step, in your example you first create it (and ignore result), then lookup it right afterwards. More instructions to execute, something that should be (easily) avoided.

3. Having ddic: prefix in this case is optional, while default is ddic:. On other hand, if you create type as Java type, prefix java: is mandatory, i.e. java:java.util.List.

Valery Silaev

EPAM Systems

http://www.NetWeaverTeam.com

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo,

it is good style to add the type-prefix in all cases. The Web Dynpro Runtime tries to match the retrieved type name with types of different name-spaces. To avoid naming conflicts which can possibley occur the prefix should allways be specified.

- <b>"ddic:"</b> - dictionary simple types

- <b>"java:"</b> - java native types

- <b>"external:"</b> - dictionary types in logical Adaptive RFC model dictionaries

Regards, Bertram

Former Member
0 Kudos

Thank you Valery and Bertram for the clear explanation!