1
votes

I have the following requirement in an xpages application:

I have a radio button group with two options. I have a combobox whose values ​​will be calculated from the option chosen in the radio button group. The options will be calculated from the partial refresh of the combobox associated with the onChange event of the radio button.

My problem is that I could not get the value selected on the radio button to mount the combobox options. As I'm doing the assembly through SSJS I have to get the value selected on the radio button also in SSJS. Is there any component / method on xpages that I can get the selected value from?

I know that via RPC component or jquery coould get via CSJS the selected value, but I was only wanting to use SSJS.

Grateful

Knut,

I made an example based on your suggestion, according to the code below, but it did not work. Because?

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:radioGroup id="radioGroup2">
    <xp:selectItem itemLabel="a"></xp:selectItem>
    <xp:selectItem itemLabel="b"></xp:selectItem>
    <xp:selectItem itemLabel="c"></xp:selectItem>
    <xp:eventHandler
        event="onclick"
        submit="true"
        refreshMode="partial" refreshId="computedField2" execMode="partial"   execId="radioGroup2">
    </xp:eventHandler></xp:radioGroup>
<xp:text
    escape="true"
    id="computedField2"
    value="#{javascript:getComponent('radioGroup2').getValue()}">
</xp:text><xp:br></xp:br><xp:br></xp:br>
</xp:view>
2

2 Answers

3
votes

Use

getComponent('radioGroup1').getValue()

Replace "radioGroup1" with your radio button group's id.

Here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view
    xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:radioGroup
        id="radioGroup1"
        value="#{viewScope.radio}">
        <xp:selectItem itemLabel="a" />
        <xp:selectItem itemLabel="b" />
        <xp:eventHandler
            event="onclick"
            submit="true"
            refreshMode="partial"
            refreshId="checkBoxGroup1" execMode="partial" execId="radioGroup1">
        </xp:eventHandler>
    </xp:radioGroup>
    <xp:br></xp:br>
    <xp:checkBoxGroup
        id="checkBoxGroup1"
        value="#{viewScope.check}">
        <xp:selectItems>
            <xp:this.value><![CDATA[#{javascript:
                if (!getComponent('radioGroup1').getValue()) {
                    return [];
                }
                if (getComponent('radioGroup1').getValue() == 'a') {
                    return ['A1', 'A2'];
                }
                return ['B1', 'B2'];
            }]]></xp:this.value>
        </xp:selectItems>
    </xp:checkBoxGroup>
</xp:view>

Instead of getComponent('radioGroup1').getValue()you could use viewScope.radio as radio's value gets stored in view scope variable in this example.

0
votes

I've done similiar by either using a getComponent("RadioButtonGroup1").getValue() in the computed values for the combobox. Or you could use this:

this.getParent().getValue()

in the onChange to populate a scoped variable that you base your combobox with.