How to set radio button as true bydefault - jsf

I want to make my radio button bydefault as true. My sample code is given below:
<p:selectOneRadio value="#{empcategoryBean.dto.is_Esi}" disabled="#{empcategoryBean.sta}" >
<f:selectItem itemLabel="Yes" itemValue="1"/>
<f:selectItem itemLabel="No" itemValue="0"/>
</p:selectOneRadio>

go the following link:-
JSF set default value Radio Button h:selectOneRadio
Set value in your backing bean with the desired default value. For example if you want "1" as default:

Related

Checkbox is shown twice on select one radio button primefaces

I have selectOneRadio component in form with wizard and I have checkbox which should be enabled if first radio button is select. Here is my code for radio button:
<p:selectOneRadio id="decision" value="#{bean.decisionApproved}">
<f:selectItem itemLabel="Approved" itemValue="true" />
<f:selectItem itemLabel="Declined" itemValue="false"/>
<p:ajax update="permitPriniting"/>
</p:selectOneRadio>
Here is my code for checkbox:
<h:panelGroup id="permitPriniting">
<p:column colspan="2">
<p:selectBooleanCheckbox value="#{bean.printingApproved}"
id="printingApId"
disabled="#{bean.decisionApproved ne true}">
However when I select first radio button , the checkbox is not enabled and it is shown twice, like it is rendered again.
I just changed this:
<p:ajax update="permitPriniting"/>
to this:
<p:ajax update="printingApId"/>
And it works:)

Set up default radio button h:selectOneRadio on JSF

I have this code
<h:selectOneRadio value="#{MyBean.valueAttr}" >
<f:selectItem itemLabel="Button1"/>
<f:selectItem itemLabel="Button2" />
<f:selectItem itemLabel="Button3" />
</h:selectOneRadio>
I wanted to know if there is a way to set up the Button3 as the chosen button (default) initially.
Thanks
Add itemValue attribute to your f:selectItem and set default value of #{MyBean.valueAttr} in your bean

Nesting a h:selectOneRadio inside another h:selectOneRadio 's f:selectitem

I want to create a group of radio buttons inside an option of another radio button.
It has to look like this.
Radio Title1
O Yes
Radio Title2
O Yes
O No
O No
When I try the following code the items are rendered as two rows of a table, but when i keep another component inside this selectone radio item, it keeps out of the table, So I am not able to achieve what I want.
<h:selectOneRadio id="reportDestination" layout="pageDirection">
<f:selectItem itemLabel="Yes" itemValue="Yes" />
<h:selectOneRadio layout="pageDirection">
<f:selectItems itemLabel="Yes" itemValue="Yes"/>
<f:selectItems itemLabel="No" itemValue="No"/>
</h:selectOneRadio >
<f:selectItem itemLabel="No" itemValue="No" />
</h:selectOneRadio>
Is there anyway to do it?
Any input is appreciated like a reference or a logic or anything.
Thanks in advance.

Radio button not passing value when submitted

I have an UI where I use a radio button to select the gender. However, when I press submit to store the data to the database I only ever get a null value
This is the code:
<p:selectOneRadio id="gender"
value="{formBean.number}"
layout="grid"
columns="2"
required = "True"
requiredMessage="#{bundle.requiredGender}">
<f:selectItem itemLabel="#{bundle.labelMale}" itemValue="Male"/>
<f:selectItem itemLabel="#{bundle.labelFemale}" itemValue="Female" />
</p:selectOneRadio>
What have I missed out?

Are there any attributes to pre select some radio button in <h:selectOneRadio > tag on page lodads

Are there any attributes to pre select some radio button in tag on page lodads
below is my code i want the Now radio button to be selected when page loads ,
<h:selectOneRadio id="Radios"
value="#{pc_ClosureDecision.closureDetails.approvalDateSelected}"
layout="lineDirection" onclick="check_Date()">
<f:selectItem itemValue="now" itemLabel="Now" />
<f:selectItem itemValue="later" itemLabel="Resolve Later" />
</h:selectOneRadio></td>
Initialize #{pc_ClosureDecision.closureDetails.approvalDateSelected} with a value of "now" (in the Java code, or by injection in your faces-config.xml).

Resources