cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a value to a dynamically created node/attribute?

Former Member
0 Kudos

Hi,

I dynamically created attributes using the following method,

IWDNodeInfo cbOptions = wdContext.getNodeInfo().addChild("cbOpt"+count, null, true, true, false, false, false, true, null, null, null);

cbOptions.addAttribute("opt"+critEle.getQuest_Critid(), "ddic:com.sap.dictionary.string");

How do i assign a value to it now, since the node/attribute cannot be accessed via wdcontext?

On a side note, it seems really troublesome if i need to use a checkbox grp(s) dynamically. I actually need to dynamically create a seperate node + attribute for each checkbox grp i have. Is there any better way to do this?

Thanx in advance

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Ok, found the answer to the first part of the question but the second part still stands

Former Member
0 Kudos

What exactly is the problem? A CheckBoxGroup gets its individual checkboxes at runtime from the elements of its data source node. Why do you need to create context entities at runtime, what is the scenario?

Armin

Former Member
0 Kudos

My page is suppose to have many multiple choice questions on it. however, the exact number of questions and the choices for each question is known only at run time.

Lets say i am suppose to have 3 questions. Each with 3,4,5 options respectively. That will mean i have to dynamically create 3 seperate nodes with a single attribute. and with 3,4,5 elements in each node respectively correct?

Former Member
0 Kudos

the problem is to bind text for checkbox grps i have to use

checkboxb.bindTexts("NodeA.NodeB.Attribute");

Lets say that i want to bind each check box grp to a different NodeB element in NodeA. How do i do that?

checkboxb.bindTexts("NodeA(3).NodeB.Attribute"); does not work obviously 😛

Former Member
0 Kudos

another problem... i will need a action for each checkbox grp. so if i have unknown number of checkbox grps, i need to dynamically create actions as well? how do i do this....?

Former Member
0 Kudos

Hi,

For Questions you can have One node with one attribute.

Populate the attribute with Questions.

arun_srinivasan
Contributor
0 Kudos

Hi

Steps:

1) Create the action click is done statically (you cannot create action dyanmically)

2) binding the action click to checkbox dynamically

code

public static void wdDoModifyView(IPrivateDynamicProgrammingView wdThis, IPrivateDynamicProgrammingView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

{

//@@begin wdDoModifyView

if(firstTime){

IWDTransparentContainer con=(IWDTransparentContainer)view.getElement("RootUIElementContainer");

IWDCheckBox checkBox=(IWDCheckBox)view.createElement(IWDCheckBox.class,"ck");

IWDAction act=wdThis.wdCreateAction(IPrivateDynamicProgrammingView.WDActionEventHandler.CLICK,"");

checkBox.setOnToggle(act);

con.addChild(checkBox);

}

//@@end

}

Thanks and Regards,

Arun

Former Member
0 Kudos

Thx Arun for the detailed reply. I actually have done all that. My problem is with a unknown amount of checkboxGroup each needing its own action ==> i need a unknown amount of actions at design time. Anyways i found the solution to my problem.. got to use parameter mapping on a generic action... silly me