I plan to use dijit.form.radiobutton on a xpage. I try to find a solution without using the xpages-extlib.
If I add the dijit.form.radiobutton to the xpage, the value of the button is not saved.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="document1" formName="tstRadio"></xp:dominoDocument>
</xp:this.data>
<xp:this.resources>
<xp:dojoModule name="dijit.form.RadioButton"></xp:dojoModule>
</xp:this.resources>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<xp:saveDocument var="document1"></xp:saveDocument>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:radio text="Yes" id="radio1" groupName="radio" selectedValue="yes" value="#{document1.radio}" dojoType="dijit.form.RadioButton">
<xp:this.dojoAttributes>
<xp:dojoAttribute name="name" value="radio"></xp:dojoAttribute>
<xp:dojoAttribute name="value" value="yes"></xp:dojoAttribute>
</xp:this.dojoAttributes>
</xp:radio>
<xp:radio text="No" id="radio2" groupName="radio" selectedValue="no" value="#{document1.radio}" dojoType="dijit.form.RadioButton">
<xp:this.dojoAttributes>
<xp:dojoAttribute name="name" value="radio"></xp:dojoAttribute>
<xp:dojoAttribute name="value" value="no"></xp:dojoAttribute>
</xp:this.dojoAttributes>
</xp:radio>
</xp:view>
Without the dijit.form.radiobutton the value saved properly.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="document1" formName="tstRadio"></xp:dominoDocument>
</xp:this.data>
<xp:this.resources>
<xp:dojoModule name="dijit.form.RadioButton"></xp:dojoModule>
</xp:this.resources>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<xp:saveDocument var="document1"></xp:saveDocument>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:radio text="Yes" id="radio1" groupName="radio" selectedValue="yes" value="#{document1.radio}">
<xp:this.dojoAttributes>
<xp:dojoAttribute name="name" value="radio"></xp:dojoAttribute>
<xp:dojoAttribute name="value" value="yes"></xp:dojoAttribute>
</xp:this.dojoAttributes>
</xp:radio>
<xp:radio text="No" id="radio2" groupName="radio" selectedValue="no" value="#{document1.radio}">
<xp:this.dojoAttributes>
<xp:dojoAttribute name="name" value="radio"></xp:dojoAttribute>
<xp:dojoAttribute name="value" value="no"></xp:dojoAttribute>
</xp:this.dojoAttributes>
</xp:radio>
</xp:view>
I am not sure that the Not working code I wrote in the first example is correct, something may be missing from it. Is it possible to use dijit.form.Radio with working saving functionality on an Xpage ? If yes, then how?
The reason your first code snippet is not working because of this <xp:dojoAttribute name="name" value="radio"></xp:dojoAttribute>
. This statement sets the name
attribute of input
tag to radio
rather than something like this view:_id1:radio
. I removed the line it was working for me. You also don't need to add <xp:dojoAttribute name="value" value="yes"></xp:dojoAttribute>
as selectedValue
does the job for you.
So you code becomes something like this -
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="document1" formName="tstRadio"></xp:dominoDocument>
</xp:this.data>
<xp:this.resources>
<xp:dojoModule name="dijit.form.RadioButton"></xp:dojoModule>
</xp:this.resources>
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action>
<xp:saveDocument var="document1"></xp:saveDocument>
</xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:radio text="Yes" id="radio1" groupName="radio" selectedValue="yes" value="#{document1.radio}" dojoType="dijit.form.RadioButton">
</xp:radio>
<xp:radio text="No" id="radio2" groupName="radio" selectedValue="no" value="#{document1.radio}" dojoType="dijit.form.RadioButton">
</xp:radio>
</xp:view>