cancel
Showing results for 
Search instead for 
Did you mean: 

Radio Button View Item Element - Mobile 7.1 Handheld

Former Member
0 Kudos

Hi friends,

I have a problem creating a UI element at runtime and assigning it an action with parameter. If you check the API for RadioButtonViewItem you'll see that the method setOnSelect receives an integer param (the id for the action), how can I pass an attribute for this action ID?.

If I create an action without parameters the application works fine but If i create an action with parameters the application fails. How can I pass a parameter value to the action?

The code:

-


//assigning the action called: SelectRB to the radioButtonViewItem.

radioButtonViewItem.setOnSelect(this.onActionSelectRB);

//The action code:

public void onActionSelectRB (Event wdEvent, int elementNumber) {

//@@begin onActionSelectRB(ServerEvent)

String id = wdContext.nodeRadioButton().currentRadioButtonElement().getElementId_0();

wdContext.nodeRadioButton().currentRadioButtonElement().setValue(String.valueOf(elementNumber));

System.out.println(elementNumber);

//@@end

}

-


Regards,

David Faustini

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello David,

Can you please post the error trace which you get when you create the action with parameters

Regards

Priya

Former Member
0 Kudos

Hi Prya,

The error take place when I press the radio button.

The error trace is:

-


java.lang.NullPointerException

at com.cts.test.polar_hh.survey_suite.comp.RB_View.invokeEventHandler(RB_View.java:193)

at com.sap.tc.mobile.wdlite.progmodel.core.AbstractViewElement.doHandleEvent(AbstractViewElement.java:207)

at com.sap.tc.mobile.wdlite.renderer.api.UIElement.doHandleEvent(UIElement.java:399)

at com.sap.tc.mobile.wdlite.renderer.api.UIFieldCheckBox.doHandleEvent(UIFieldCheckBox.java:97)

at com.sap.tc.mobile.wdlite.renderer.swt.SWTCheckBox.handleEvent(SWTCheckBox.java:53)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)

at com.sap.tc.mobile.wdlite.renderer.swt.container.WorkingArea.refresh(WorkingArea.java:175)

at com.sap.tc.mobile.wdlite.renderer.api.RenderingManager.refresh(RenderingManager.java:233)

at com.sap.tc.mobile.wdlite.progmodel.core.Application.refresh(Application.java:250)

at com.sap.tc.mobile.wdlite.progmodel.core.Application.navigate(Application.java:503)

at com.sap.tc.mobile.wdlite.progmodel.core.Application.enter(Application.java:243)

at com.sap.tc.mobile.wdlite.progmodel.core.Application.setCurrent(Application.java:119)

at com.sap.tc.mobile.wdlite.progmodel.core.Application.launch(Application.java:143)

at com.sap.tc.mobile.wdlite.progmodel.core.Application.launch(Application.java:175)

at com.sap.tc.mobile.wdlite.progmodel.core.WDLite.launchApplication(WDLite.java:387)

at com.sap.tc.mobile.wdlite.framework.Start.runOnContext(Start.java:585)

at com.sap.tc.mobile.wdlite.framework.Start.startApplication(Start.java:609)

at com.sap.tc.mobile.wdlite.framework.Start.startContainer(Start.java:646)

at com.sap.tc.mobile.cfs.framework.spi.FrameworkManager.startContainer(FrameworkManager.java:259)

at com.sap.tc.mobile.cfs.init.FrameworkInitializer.init(FrameworkInitializer.java:230)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:592)

at com.sap.tc.mobile.cfs.startup.pda.Startup.main(Unknown Source)

-


The code with number lines (check tha it is not a custome code, it's a NWDS automated code.)

192: case 6353598:

193: onActionSelectRB(event , ((Integer)params.get("elementNumber")).intValue());

194: break;

Try on yours NWDS, create an action with a parameter and assign that to the Radio Button Element

Best Regards,

David Faustini

Former Member
0 Kudos

Hi David,

I am not sure what are you trying to achieve? Can you pls clarify.

The method setOnSelect() expect methodID as the parameter.This methodid is the method which should be called when the radio button is selected.The methodid is not available at design time.It gets generated during build and is availalbe during runtime only.

Hence, it's not recommended to hardcode the methodid (after identifying it by doing a generation once) in the code.

If you let me know the purpose maybe I can help you then.

Best Regards,

Amit

Former Member
0 Kudos

Hi Amit,

My problem is that i don't know how yo know radio button selected? On webdynpro for handheld there is not radio button group so I need to simulate this with traditional radio button, in this case it's only permitted one radio button selected at time. So I need to know what is the option selected and turn on (unselect )off all the other options.

Best Regards,

David Faustini

Former Member
0 Kudos

Hi David,

Unfortunately, Radiobutton grouping is not available.

There is indirect way of achieving the same.

Bind All the radio button to different context node attributes of type boolean for eg

RD1 -> Attr1

RD2 - > Attr2

RD3 - > Attr3

In the onAction event handler of each of these radio button, set the attribute for other two radiobutton to false.

For eg onActionRD1

{

attr2 = false;

attr3= false;

}

This way the other two radio button will get unselected.

Moreover, the methodID is available in the view controller class file for each radio button.You should see a code snippet like this

public static int onActionRD1 = 14304423;

public static int onActionRD2 = 21195148;

So you can pass these static int to the setonSelect() method of the Radiobutton dynamically.Even if the method no gets changed the static int would remain the same so you can safely use it.

Make sure that you map the method and the radio button correctly otherwise you will get undesirable results

Not sure but I think Radio button grouping is there in 7.11 release which is not yet released to the market.

I hope this helps.

Best Regards,

Amit

Former Member
0 Kudos

Hi Amit,

There is not another way to implement dynamically a radio group? Your option is valid for us, but we hope that there is another way to get something useful from the event.

Regards,

David Faustini

Former Member
0 Kudos

Hi David,

Unfortunately, I dont think there is any other way.RadioButton grouping is not available and there is no direct UnSelect API available on radio button so I think this is the only way.

With the workaround suggested above, I believe it's one time effort but achieves the purpose.

Best Regards,

Amit

Answers (0)