On my XPage I have a radio button group control which is binded to a managed bean:
<xp:radioGroup value="#{employeeBean.employee.staffMember}" id="radioStaff">
<xp:selectItem itemLabel="Yes" />
<xp:selectItem itemLabel="No" />
<xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="radioStaffDept"></xp:eventHandler>
</xp:radioGroup>
When set to Yes I would like to display another input field to enter the department.
I have tried to set the visibility via the partial refresh option but I always get the value returned how it is set via my bean.
I tested to collect it's value via:
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:
var radio1:com.ibm.xsp.component.xp.XspInputRadio = getComponent("radioStaff");
return radio1.getValue()}]]></xp:this.value>
</xp:text>
So when loaded and the value is No, if I set the radiobutton to Yes it remains No.
How should I collect the (changed) value from the radiobutton?
Ps I tried adding a binding property (e.g. binding="#{myValue}"
) but got same undesired result via this method.
PPs I also tried to set the staffMember field on the onChange event but this did not work either (employeeBean.employee.setStaffMember("Yes");
)
===
I am not sure if I understood it correctly Yes with the following code I can check if a person is a staff member, but how do I write (temporarely) value back to my proposal object in my bean when I change options in the radio button?
private Employee employee;
public Boolean isStaffMember(){
if (employee.getStaffMember()=="Yes"){
return false;
}
else{
return true;
}
}
public void setStaffMember(String value){
employee.setStaffMember(value);
}
<xp:radioGroup
value="#{employeeBean.employee.staffMember}"
binding="#{staffMember}" id="radioStaffMember">
<xp:selectItem itemLabel="Yes" />
<xp:selectItem itemLabel="No" />
<xp:eventHandler event="onchange"
submit="true" refreshMode="partial"
refreshId="pnlStaffMemberDept" >
<xp:this.action><![CDATA[#{javascript:var thisVal = getComponent("radioStaffMember").getValue();
employeeBean.setStaffMember(thisVal);}]]></xp:this.action>
</xp:eventHandler>
</xp:radioGroup>