on 07-11-2006 11:47 AM
Hi all,
I have different problems with adding radiobuttons in my table.
In my context I have:
-DynamicText (ValueNode)
--Persons (ValueNode)
---PersonsText (ValueAttribute)
-TableProperties (ValueNode)
--Selection (ValueNode)
---KeyToSelect (ValueAttribute)
--SelectedKey (ValueAttribute)
With binding I set the PersonsText in my table with a radioButton in every row.
I tried to set the selection with the following code:
int personsSize = wdContext.nodePersons().size();
ITablePropertiesElement table = wdContext.createTablePropertiesElement();
for (int i=0; i<personsSize; i++) {
ISelectionElement element = wdContext.nodeSelection().createSelectionElement();
element.setKeyToSelect(wdContext.nodePersons().getPersonsElementAt(i).getPersons());
wdContext.nodeSelection().addElement(element);
}
I try to get the selection with:
String key = wdContext.currentTablePropertiesElement().getSelectedKey();
IWDMessageManager mng = wdComponentAPI.getMessageManager();
mng.reportSuccess("selected is:" +key);
This returns null.
When I deploy and start the application also all the radiobuttons are selected.
I tried to set the propertie from the table "selectionMode" to single.
That doesn't help.
Can anyone help me with this problems please?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check if you have done this:
-Root
--TableProperties(cardinality=1..n,singleton=true)
---Selection(cardinality=0..1,singleton=false,supplyFunction=supplySelection)
-
KeyToSelect(String)
---PersonName(String)
---SelectedKey(String)
Now in your event handler for onSelect of radio button, use this:
for(int i = 0; i < wdContext.nodeTableProperties().size(); i++){
if(i != wdContext.nodeTableProperties().getLeadSelection()){
wdContext.nodeTableProperties().getElementAt(i).setAttributeValue("SelectedKey",null);
}
}
String key = wdContext.nodeTableProperties().currentTablePropertiesElement().getSelectedKey();
wdComponentAPI.getMessageManager().reportSuccess("Key is:" + key);
Actually this should have been done with cardinality, but this is a workaround. I'll try to fix this.
Regards,
Satyajit.
Hi,
Check if node bound to the RadioButton has 1...1 cardinality, singleton=false and initializeLeadSelection=true.
Also there is something missing in your code:
int personsSize = wdContext.nodePersons().size();
ITablePropertiesElement table = wdContext.createTablePropertiesElement();
for (int i=0; i<personsSize; i++) {
ISelectionElement element = wdContext.nodeSelection().createSelectionElement();
element.setKeyToSelect(wdContext.nodePersons().getPersonsElementAt(i).getPersons());
wdContext.nodeSelection().addElement(element);
}
//<b>This is missing I guess.</b>
wdContext.nodeTableProperties().addElement(table);
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satyajit,
When I set the cardinality to 1...1 I got the following exception:
com.sap.tc.webdynpro.progmodel.context.ContextException: Node(MyView.TableProperties.0.Selection): must not add elements to a Node of cardinality 0..1 or 1..1
For the missing code, see the explanation above.
Thnx in advance
Hi,
Yes all the properties are set like this.
I also tried something else, I changed the context:
Context
- Table (ValueNode)
-- KeyToSelect (ValueAttribute)
- SelectedKey (ValueAttribute)
I bind this properties to my RadioButton and changed the code to set the KeyToSelect in the valuenode Table.
Now my second problem (all the checkboxes selected in the beginning) is solved.
Now I want to read the SelectedKey in my code in the view.
How can I read the SelectedKey (straight under the context) now?
Hi,
Have a context that looks like this:
-RootNode
--TableProperties(node, cardinality=1..n,singleton=false)
---Selection(node,cardinality=1..n,singleton=false,supplyFunction=supplySelection)
-
KeyToSelect(String)
---SelectedKey(String)
---PersonName(String)
Bind TableProperties.Selection.KeyToSelect to the keyToSelect property of the radio button. And bind TableProperties.SelectedKey to the selectedKey property of the radio button.
The supply function supplySelection looks like:
IPrivateSDNCompView.ISelectionElement elem = node.createSelectionElement();
node.addElement(elem);
elem.setKeyToSelect("Key_" + parentElement.getPersonName());
Now in the event handler for the onSelect event of the radio button, write this code:
String key = wdContext.nodeTableProperties().currentTablePropertiesElement().getSelectedKey();
wdComponentAPI.getMessageManager().reportSuccess("Key is:" + key);
Regards,
Satyajit.
Hi Satyajit,
Thanks for your answer!
This works fine with the selected key, except that I can choose more than 1 options now in my Table.
Maybe because I couldn't use your example totally.
This is how I did it.
-Context
--DynamicText(node, cardinality=0..n, singleton=true)
---Persons(node, cardinality=0..n, singleton=false)
-
Selection(node, cardinality=0..n, singleton=false,supplyFunction=supplySelection)
-
KeyToSelect(String)
---PersonText(String)
---SelectedKey(String)
I couldn't set the singleton of the first item to false because its just below the context-root (you can't change that singleton property)
Do you know how I can change this so I can't select more than 1 option?
Thanks in advance!
Hi B.
i dont know if that is reason of your problom or only mistake in post but in your code:
nt personsSize = wdContext.nodePersons().size();
ITablePropertiesElement table = wdContext.createTablePropertiesElement();
wdContext.nodeTableProperties.addElement(table); //that is missing!!!!
for (int i=0; i<personsSize; i++) {
ISelectionElement element = wdContext.nodeSelection().createSelectionElement();
element.setKeyToSelect(wdContext.nodePersons().getPersonsElementAt(i).getPersons());
wdContext.nodeSelection().addElement(element);
}
an insert tableelement to table node is missing.
Regards
Bogdan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.