Howard
Howard

Reputation: 1503

onclick event of a radiobuttongroup does not fire after clearing sessionscope variables

Below is a simple Xpage with a radiobuttongroup that is bound to a sessionScope variable. The onclick event of the radio button group sets the computed field. There is an afterPageLoad event to initialize the session scope variable.

All works great. However, if I clear the session Scope variables (using the debug custom control) then the onclick event never fires. The user can click on the radio button all they want and the computed field never changes until the page is reloaded by pressing F5. Below is my page source. Any suggestions on how to get the onclick event to fire? This would be a big usability issue if the user let the session variables time out and then starting clicking on the radio button.

Howard

            <?xml version="1.0" encoding="UTF-8"?>
                <xp:view xmlns:xp="http://www.ibm.com/xsp/core">
                <xp:this.afterPageLoad><![CDATA[#{javascript:print("starting the afterPageLoad event");
                if (sessionScope.init != true|| sessionScope.radioData == null){
                //setup default values'
                print("initing the value");
                sessionScope.init = true;
                sessionScope.radioData = "Red";
                } 
            }]]></xp:this.afterPageLoad>
                <xp:radioGroup id="radioButtons" value="#{sessionScope.radioData}">
                    <xp:selectItem itemLabel="Red"></xp:selectItem>
                    <xp:selectItem itemLabel="Green"></xp:selectItem>
                    <xp:selectItem itemLabel="Blue"></xp:selectItem>
                    <xp:eventHandler event="onclick" submit="true"
                    refreshMode="partial" refreshId="computedField1">
                    <xp:this.action><![CDATA[#{javascript:print("starting onclick event");
                if (sessionScope.init != true){
                    print("reload the page");
                context.reloadPage();
                }
                var radioval = getComponent("radioButtons").getValue();
                getComponent("computedField1").setValue(radioval); }]]></xp:this.action>
                </xp:eventHandler></xp:radioGroup>
                <xp:text escape="true" id="computedField1"></xp:text></xp:view>

Upvotes: 1

Views: 1049

Answers (1)

Bill Hanson
Bill Hanson

Reputation: 91

I've seen this same behavior several times in my own xpage apps, and I've found that the problem happens only for partial page refreshes where the target refreshId is not large enough in scope to reload all of the data needed by the control. When I change the refreshId to the page's main div (or use full page refresh), then all works as expected.

I think that it's the call to location.reload in the client-side code which is actually fixing your issue. I'd be interested to learn if increasing the scope of refreshId also fixes the problem.

Upvotes: 0

Related Questions