How to Freeze JSF Radio Buttons - jsf

i have the following jsf code:
<h:selectOneRadio value="#{ref.arrive.boardingInformation}">
<f:selectItems value="#{newMessage.boardingInformationSelectItemList}" />
</h:selectOneRadio>
Is it possible to freeze this kind of selectradiobutton in that way, that my user canĀ“t change the value?
This radiobuttons are only for reading and not for writing or changing.

Try this:
<h:selectOneRadio value="#{ref.arrive.boardingInformation}" disabled="true">
<f:selectItems value="#{newMessage.boardingInformationSelectItemList}" />
</h:selectOneRadio>
Here are the available properties: http://www.tutorialspoint.com/jsf/jsf_selectoneradio_tag.htm

Related

how to display value data from bean to radio button jsf

Is it possible to display values from my bean to radio button in the view?
I'm using jsf.
<h:outputLabel value="Gender"/>
<h:selectOneRadio value="#{ctrlLogin.session.gender}" readonly="true">
<f:selectItem itemValue="Male" itemLabel="Male" itemDisabled="true" />
<f:selectItem itemValue="Female" itemLabel="Female" itemDisabled="true"/>
</h:selectOneRadio>
i already have a user bean that carries the actual value from the database
Of course it is possible. I assume that you have some kind of list in a bean? You really should provide some code. Anyway, the solution below should give you an idea how to populate radio buttons with values.
<h:selectOneRadio id="radio"
value="#{bean.selectedOption}">
<f:selectItems value="#{bean.listOfOptions}" var="item" itemLabel="#{item}" itemValue="#{item}" />
</h:selectOneRadio>

How to use Primefaces SelectOneRadio's Custom Layout on Dynamic List

Primefaces provides option of customizing the Layout of p:selectOneRadio which is a good over the treditonal JSF h:selectOneRadio which generates <table>.
But everywhere I see using this Custom Layout on fixed/static Radio buttons even in Primefaces Showcase. where they used over:
<p:selectOneRadio id="customRadio" value="#{formBean.option}" layout="custom">
<f:selectItem itemLabel="Option 1" itemValue="1" />
<f:selectItem itemLabel="Option 2" itemValue="2" />
<f:selectItem itemLabel="Option 3" itemValue="3" />
</p:selectOneRadio>
I want use this custom Layout on f:selectItems which iterates over a ArrayList.
like,
<p:selectOneRadio id="customRadio" value="#{formBean.option}" layout="custom">
<f:selectItems value="#{formBean.mySelectItemList}"/>
</p:selectOneRadio>
How To do that? or any other alternatives?
Using: JSF 2.1.13 and Primefaces 3.5
A convenient way to solve it would be to use JSTL c:forEach with f:selectItems just the way you wrote it in your question. You could add the following to define the layout:
<c:forEach items="#{formBean.mySelectItemList}" var="item" varStatus="loop">
<p:radioButton id="customRadioButton" for="customRadio" itemIndex="#{loop.index}" />
<!-- whatever custom layout you prefer here -->
<p:inputText />
</c:forEach>
In my application I have a such implementation I am sharing the code
<p:selectOneRadio value="#{insertbean.lagCalid}" layout="pageDirection">
<f:selectItems value="#{insertbean.calendars}" var="cal" itemLabel="#{cal.calendarName}" itemValue="#{cal.calrowid}" />
</p:selectOneRadio>
lagcalid has getter setter; calendars is of type List<Calendar>, Calendar is my own model class. calendars has getter method in which it is populated with data. pageDirection has the same custom like view as primefaces showcase.

<p:selectOneMenu> getting null on submit/next

I am using primefaces wizard. During wizard flow all parameters saved correctly . However <p:selectOneMenu> items getting NULL on submit.Also on 'back', it will not show what I have selected. Same for <p:selectManyMenu> also. Any solution ?
Here is the code snippets.I'm using primefaces-3.0.M3 and jsf2.
<h:outputText value="Employee Status" />
<p:selectOneMenu id="employeeStatus"value="#{employeeRepositoryImpl.employeeStatus.title}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Permanent" itemValue="Permanent" />
<f:selectItem itemLabel="Contract" itemValue="Contract" />
<f:selectItem itemLabel="Part-Time" itemValue="Part-Time" />
<f:selectItem itemLabel="Training" itemValue="Training" />
</p:selectOneMenu>
<p:message id="employeeStatusId" for="employeeStatus" />
This is in a <p:wizard> tab, while clicking next button or submit button, the itemValues getting null.Sorry for the re-post.
Have you deleted the previous post?
Anyway, firstly, you should upgrade to Primefaces 3.0.M4!
Secondly, it would be better to use a list along with f:selectItems and all those String values to be stored in a list(this way you have more control over what's in the list and what should the list return), but if you want to stick with f:selectItem try using it with the enclosing tag (it may be a bug without it):
<f:selectItem itemLabel="Permanent" itemValue="Permanent" ></f:selectItem>
Also, I repeat myself, upgrade to Primefaces 3.0.M4!
I have solved it by using primefaces AJAX
<p:ajax update="employeeStatus" listener="#{employeeRepositoryImpl.employeeStatusAjax}" />
inside my </p:selectOneMenu> and I check/process this in side employeeStatusAjax().

noSelectionLabel in jsf?

There are many situations when we want to tell the user to select an option from a selectOneMenu component. In Seam this is easily solved using noSelectionLabel.
<h:selectOneMenu value="#{seasonHome.id}">
<s:selectItems value="#{seasonListQuery.resultList}"
var="season"
label="xxxSeason #{season.startYear}"
noSelectionLabel="Select Season"
hideNoSelectionLabel="true" />
<s:convertEntity />
</h:selectOneMenu>
Can you please tell me if there is something similar in JSF 1.2?
I'm using icefaces with a list for selectItems like:
<ice:selectOneMenu
id="#{id}"
required="#{required}"
styleClass="#{styleClass} #{not required ? 'graNotRequired':''}"
style="width: #{width};font-size: #{fontSize};"
partialSubmit="#{partialSubmit}"
disabled="#{disabled}"
value="#{fieldOneDataHolder[fieldTwo]}">
<f:selectItems value="#{selectableItems}" />
<f:validator validatorId="#{validatorId}" />
</ice:selectOneMenu>
(please ignore parameters, this is a custom component I made).
I can introduce a new <f:selectItem itemLabel="Please select" itemValue=""/> above f:selectItems but this is difficult (I have to find a way to hide it in some cases etc)...
Do you know other work-around?
Thanks.
<f:selectItem itemLabel="Please select" itemValue="" itemDisabled="true" rendered="#{isShown}" />
The itemDisabled will make it shown but not selectable.
The boolean in rendered will decide whether the item is shown or not.

How to use h:selectOneMenu in f:selectItem?

<h:selectOneRadio id="profiles" layout="pageDirection" value="#{bean.selectedProfile}" style="font-size:12px;">
<f:selectItem itemValue="0" itemLabel="#{messages.msg_profile1} ">
<h:selectOneMenu id="countries" value="#{bean.selectedCountry}" required="false" style="width:190px">
<f:selectItems value="#{bean.countries}" />
</h:selectOneMenu>
</f:selectItem>
<f:selectItems value="#{fraudBinPageBean.profiles}"/>
</h:selectOneRadio>
I have written above code in my app. It is working fine.
But select box displaying above the radio button.
My requirement display the select box beside the radio button.
Can you please help me what is the problem?
Are you sure that it is working correctly? Referring to this answer it is not possible since the body of the f:selectItem tag must be empty.
Try to redesign your form that you get along without the nested h:selectOneMenu.
You want to keep your radio button and Select box in same line. This is more related to CSS.
Try This code.
<h:selectOneRadio id="profiles" layout="pageDirection"
value="#{bean.selectedProfile}" style="font-size:12px;display:inline">
<f:selectItems value="#{fraudBinPageBean.profiles}"/>
</h:selectOneRadio>
<f:selectItem itemValue="0" itemLabel="#{messages.msg_profile1} ">
<h:selectOneMenu id="countries" value="#{bean.selectedCountry}" required="false" style="width:190px">
<f:selectItems value="#{bean.countries}" />
</h:selectOneMenu>
as shown in above code Add CSS property Display:inline to your style attribute of selectoneradio

Resources