On my screens I have radio buttons and the selected value is not getting submitted when a command button is clicked. Here is one example:
two radio buttons helping user to select whether it is public or provate. I know in this case a check box can serve the purpose and is a better choice. But this is how user wanted and screen is defined. Beside on other screen two radio buttons are needed to show selection.
Anyway, the tags are defined as folllowing:
value="#{myBean.privateSelected}"></ig:radioButton>
label="Public " groupName="visibility"
Where public/privateSelected are variables in bean defined of type boolean with appropraite accesssing methods. By defualt privateSelected is set to true and publicSelected to false. When I press say save button and control goes back the values of these variables are not updated.
When screen was initially rendering non of the radio button buttons was gettting selected. So I changed the tags to add checked attribute as following:
<ig:radioButton id="qPrivateButton" styleClass="radioButton"
value="#{myBean.privateSelected}" checked="#{myBean.privateSelected}"></ig:radioButton>
value="#{myBean.publicSelected}" checked="#{myBean.publicSelected}"></ig:radioButton>
after this change the initially the private radio button is selected as expected but the value is yet not getting changed if I cahnge my selection to public once the screen is rendered.
Am I missing something here?\
***********************************************************************************************************************************************************
To try it in clean and simple files today I created the following code files and issue remains the same:
-----------------------------
test.jsp
-----------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@taglib uri="http://ko.infragistics.com/faces/netadvantage"
pageEncoding="ISO-8859-1"%>
href="${pageContext.request.contextPath}/mpas/css/investments"
<link rel="stylesheet"
type="text/css">
href="../../../theme/stylesheet.css" title="Style">
<f:view >
<h:form id="form1" styleClass="form">
<ig:radioButton id="radioButtonRenderer1" styleClass="radioButton" label="Button 1" groupName="bGroup" value="#{testBean.radioB1}" binding="#{testBean.radioB1Html}"></ig:radioButton>
<ig:radioButton id="radioButtonRenderer2" styleClass="radioButton" label="Button 2" groupName="bGroup" value="#{testBean.radioB2}" binding="#{testBean.radioB2Html}"></ig:radioButton>
<hr>
action="#{testBean.submit}"></h:commandButton>
</h:form>
</f:view>
-----------------------------------
TestBean.java
------------------------------------
private boolean radioB2=true;
public TestBean(){
}
{
setRadioB2(radioB2Html.isChecked());
// if (radioB1Html!=null && radioB1Html.isChecked()==null)
// (radioB1Html.setChecked(radioB1))
// if (radioB2Html!=null && radioB2Html.isChecked()==null)
// {}
----------------------------------
If I use checked="true" attribute, in the tag , when page it displayed the radio button is checked otherwise it doesn't matter whether radioB1 or radioB2 is initially set to true or false. None of the button shows being checked.
Then I click on button 1 and submit the button in bean both get value os false. radioB2Html variables show checked null in debug mode and when I use radioB2Html.isChecked() it returns false for both buttons.
After submit action method when page is displayed again of course both buttons show not checked.
-----------------------------------------------------------------------------------------------------------------------------------------
If I add value change listener for both buttons and set immediate to true for both, in both value change listeners new and old values are false.
This is resolved. I was trying to use the radio button a little different than they actually are meant to be used. If any one else experience similar issues and contacts me I will then post the sample code to get them working.
Hi,
I have a same issue mentioned by you.
Actually i have radio button in my acreen and a submit button.
When i select the radio button and click on submit, the submit button is not working, its just refreshing the page
and leaves the radio button without selected. The submit button works fine if the radio button if it is not selected.
I badly need solution for this as I am braking head on this. Please send me the solution
to npragdesh@gmail.com
Greetings sfoziak,
I am also in need of similar requirement. It would be greatful/thankful if you can post the solution for selection based on radio button.
Thanks in advance
Shetty Mahesh