on 07-02-2007 2:12 PM
Hi all,
i have a radiobutton column and name column in my table.
if i select this radiobutton i have to display the name on the screen.
i mapped the radiobutton selectedkey to one attribute which is of type boolean.
and i created one action and assigned it to radio button's onaction.
but if i click on the radiobutton ,it is giving java.lang.nullpointer exception.
could you please tell the solution for this.
thanks in advance.
Hi,
What have you mapped to the KeyToSelect property of the radiobutton ?
Whenever you use radiobutton in a table,
1. bind the property KeyToSelect to a node attribute.
2. bind the property selecteKey to a attribute of same type as KeyToSelect.
i.e the attribute type of KeyToSelect and selectedKey should be same.
3. the attribute that is mapped to selectedKey should be either directly under Context or under the node with cardinality 1..1.
The Value Attribute attached to selected Key Property holds one instance at a time and the Key to select is used to hold different Values for each radio button. so on select of radio button u will have the value the KeyToSelect value in selected Key Value Attribute.
In your case do as explained below
map the "name" attribute under your table node to KeyToSelect property of the RadioButton.
Create a attribute (selected) of same type as "name" directly under the context or under the node with cardinality 1..1 and map this attribute to the "selectedKey" property of the radiobutton.
Create a action and map it to the onSelect event of the radiobutton.
In the action
// if the value attribute mapped to selectedKey attribute is directly under the Context
wdComponentAPI.getMessageManager.reportSuccess("Name : "+wdContext.currentContextElement.getSelected());
OR
// if the value attribute mapped to selectedKey attribute is under the node with cardinality 1..1
wdComponentAPI.getMessageManager.reportSuccess("Name : "+wdContext.current<node>Element.getSelected());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shriram,
Thanks for the useful reply,but my requirement is now changed .I did as for your solution but i am able to select only one record at a time but now my requirement is ,i should be able to select multiple records and i have to pass these selected records to the table in the other view.
Thanks in advance.
Hi,
In that case you cannot use radiobutton.because in RadioButton only one radiobutton can be checked.
For a table to allow multiple selection the "selection" property of the table node should be set to 0..n cardinality. After settign this property you can select multiple record using CTRL tab.
You can also use checkbox instead of radiobutton to show multiple selection.
but then the table node property "selection" has to be set to 0..n.
First view context
TableNodeA (cardinality 0..n/1..n,selection 0..n)
---Name
Map the First view context to second view context through Component controller.
Dispaly View context
TableNodeB
---Name
Once you have selected the records and fired plug to the display view
In the Inbound plug of Display View
wdContext.nodeTableNodeB.invalidate();
for(int i=0;i<wdContext.nodeTableNodeA>().size();i++)
{
if(wdContext.nodeTableNodeA().isMultiselected(i))
{
// create element in the node of Display View
IPrivateDisplayView.ITableNodeBElement elem = wdContext.nodeTableNodeB().createCElement();
wdContext.nodeTableNodeB().addElement(elem);
// add the selected row values to the node of DisplayView elem.setName(wdContext.nodeTableNodeA().getTableNodeAElementAt(i).getName());
}
}
Note: The above code is without checkbox usage
If you want to use checkbox then go through the thread.It discusses the use of radiobuton (for single selection) and checkbox (multi selection) concept and also displaying the selected records in the second view
Hi Shriram,
In your solution you said the following code
wdContext.nodeTableNodeB.invalidate();
for(int i=0;i<wdContext.nodeTableNodeA>().size();i++)
{
if(wdContext.nodeTableNodeA().isMultiselected(i))
{
...
}
but in the second line of code you used the node of the first view.
but we are writing this code in the inplug method of the detailsview,is it right?
then how do you get the reference to the context node of the first view i.e. TableNodeA in this case
Hi,
Map your first view context to component controller and from their map it to the display view context.
But if your table node is mapped from Component controller to the First view context then map the same node to the context of the display view.
So now the display view will have two table nodes.
One Node of the Display view table and One node of the First view table.
Maybe you better use the built-in selection capabilities of the table instead of fiddling around with radio buttons or check boxes. Just change the selection-property of the data source node to switch between single and multiselection.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hai,
let
ur context
|
Group
|-name
|-xx
-selectedkey(String)
ui property of radio button : keytoselect=Group.name
selectedKey=selectedkey.
when binding data to table
for(int i=0;i<size;i++){
IprivateXXView.Igroupelement ele=wdContext.createGroupElement();
ele.setName(//getName);
ele.setXx(//getXX);
wdContext.nodegroup().addelement(ele);
}
get the selected name=
wdContext.currentcontextelement().getSelectedKey();// displays name
Regards,
Naga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi bharath..
I think u are trying to use the method which could not be initialized.. So only u can get tht exception.Pls chech tht one...
URs GS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bharath..
The key string u r using in the project should not be null while u r selecting the text. I think u r doing the same thing. So tht u r getting tht exception. And for more details check this link..
<a href="http://help.sap.com/saphelp_nw04/helpdata/en/77/e8cf153ebb2e468324ee8acd525fe2/content.htm">Radio Button Specification</a>
URs GS
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.