on 06-06-2005 2:29 PM
Hello!
Maybe sombebody could help me out with following problem: I' m creating a survey with Web Dynpro and have therefore to do some dynamic ui- & context creation.
My problem is the following: I' ve dynamically generated an context node & added some elements, which I now have to display as checkboxes.
How do I create the binding between the checkboxes & the context-structure? It seems easy with radiobuttons where there's one field receiving the selected value, but I could'nt use bindChecked()-method on one boolean-column of my 0:n-structure as there's an exception thrown saying "could'nt find child node ...".
Any help is more than appreciated!
Hi
In wdDoModifyView
u can say
IWDTransparentContainer rootContainer =
(IWDTransparentContainer)view.getElement("RootUIElementContainer");
IWDCheckBox check = (IWDCheckBox)view.createElement(IWDCheckBox.class,"Check"+k);
//Here "check"+k k represents a unique value every time u create so that u wont get a duplicate instance
check.setChecked(false);
rootContainer.addChild(check);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much - I' ve come so far, but should now save the results of the user-input which - as far as I've understood the matter - is done by binding the checkbox to a context attribute.
I now have a "inner table" in the context, but it seems that I can't bind the checked-property to one column of that "table".
Hi,
I created a value node vnTest and added value attribute dynamically of type boolean and then binded the value attribute to teh checkBox
wdContext.nodeVnTest().getNodeInfo().addAttribute("vaBoolean","ddic:com.sap.dictionary.boolean");
IWDCheckBox checkBox = (IWDCheckBox)view.createElement(IWDCheckBox.class,"Check1");
checkBox.bindChecked(wdContext.nodeVnTest().getNodeInfo().getAttribute("vaBoolean"));
test.addChild(checkBox);
/Set the value of value attribute true or false/
Boolean test1 = new Boolean(true);
wdContext.nodeVnTest().getCurrentElement().setAttributeValue("vaBoolean",test1);
Regards,
Sowjanya.
Hi Christian,
I have to deal with surveys as well and had the same problem a couple of days ago. As a workaround I just created a new context attribute for each checkbox. For saving the results you can loop over every dynamically created attribute and therefore save the user input in an easy way.
else if (questionType.equals("Check Box")) {
for (int j=0; j < wdContext.nodeAnswerOptions().size(); j++) {
//name of check box consists of QuestionNr + 'Check Box' + CheckBoxNr (both+1 to equal displayed question nr)
IWDCheckBox checkBox = (IWDCheckBox)view.createElement(IWDCheckBox.class, "Q" + (i+1) + "Check Box" + (j+1));
checkBox.setText(wdContext.nodeAnswerOptions().getAnswerOptionsElementAt(j).getAnswer());
try {
IWDNodeInfo nodeInfo = wdContext.getNodeInfo();
nodeInfo.addAttribute("Q" + (i+1) + "Checked" + (j+1), "ddic:com.sap.dictionary.boolean");
}
catch (ContextException e) {
}
checkBox.bindChecked("Q" + (i+1) + "Checked" + (j+1));
questionGroup.addChild(checkBox);
}
}
As I mentioned before it's only a workaround and probably not the best solution. If you find a better way, please let me know.
Are you dealing with IWDDropDown elements as well? If so you could have a look at this thread.
Cheers,
Tom
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.