Skip to Content
author's profile photo
Former Member

Radio Button Group problem

Hi all,

I've got a radio button group on a component and am trying to tell which one is selected in the java.

My JSP page has the following code :

<hbj:radioButtonGroup

id="radio"

columnCount="2"

selection="One">

<hbj:radioButton

id="csv"

text="CSV File"

key="One"

tooltip="Download data as a CSV file"/>

<hbj:radioButton

id="cxml"

text="cXML Files"

key="Two"

tooltip="Download data as cXML files"/>

</hbj:radioButtonGroup>

<hbj:button

id="Down"

text="Next"

onClick="choose">

</hbj:button>

I've tried to access them via the java code in the onChoose event triggered by the button.

public void onChoose(Event event) {

RadioButton cxmlRadio = (RadioButton) this.getComponentByName("cxml");

}

But this line gives a null pointer error :

Caused by: java.lang.reflect.InvocationTargetException: java.lang.NullPointerException

at com.atosorigin.component.ecNewPurchaseComponent$newPurchaseDynPage.onChoose(ecNewPurchaseComponent.java:628)

at java.lang.reflect.Method.invoke(Native Method)

at com.sapportals.htmlb.page.DynPage.doProcessCurrentEvent(DynPage.java:172)

Anyone got any ideas ? Is it because it is running in the onChoose event and this has a restricted view on the jsp page?

Cheers

Rich

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Posted on Aug 12, 2004 at 08:44 AM

    Hi Richard,

    you want to know which button is selected within the group, so do not ask the button, ask the group 😊

    <i>RadioButtonGroup radioGroup = (RadioButtonGroup) this.getComponentByName("radio");

    String selectedButton = radioGroup.getSelection();</i>

    Hope this helps

    Detlev

    Add comment
    10|10000 characters needed characters exceeded