What does the layout property mean in JSF tags? - jsf

Please can anyone explain what the layout property represents in this tag?
<h:selectOneRadio value="" layout="pageDirection" border="1">
<f:selectItem itemLabel="red" itemValue="1" />
<f:selectItem itemLabel="white" itemValue="2" />
</h:selectOneRadio>
Thank you.

See this question: layout with h:selectoneradio.
Basically, JSF can lay out the radio buttons horizontally by layout="lineDirection" or vertically by layout="pageDirection".
Here's the <h:selectOneRadio> reference for you.

Checkboxes and buttons can be set up to either go next to each other on the current line (layout="lineDirection") or stacked vertically, with line breaks after each one (layout="pageDirection").
Since the component is writing a bunch of HTML on your behalf, this just affects how it does it.

Related

p:radioButton with render rule is never rendered

EDIT: I adjusted the code, but the problem remains. See below
I have this p:selectOneRadio:
<p:selectOneRadio
value="#{bean.val}"
id="val"
layout="custom"
>
<f:selectItem itemLabel="" itemValue="A" />
<f:selectItem itemLabel="" itemValue="B" />
<p:ajax update="wrapper AData" />
</p:selectOneRadio>
and this p:radioButton:
<h:panelGroup id="wrapper">
<p:radioButton for="val" itemIndex="0" rendered="#{bean.val != 'A'}"/>
</h:panelGroup>
and AData contains other inputs. They are displayed only if the first radio is selected. But this is not important.
When I get a fresh page, both the radios are displayed. When I select one of them, the first one disappear.
The expected behavior by me is that the first radio disappear when selected, and re-appear when the other one is selected.
EDIT2: I tried to remove the rendered. It continued to not work! After I removed the update, it remains visible. But render does not work, so the radio never disappear.
What I'm wronging?
I found the solution. The problem was I have to update an ancestor in common with both the p:selectOneRadio and the p:radioButton

Select one many doesn't appear correctly

I am developing a primefaces web page. The problem i have is that when i try to use a select one menu with primefaces, the menu appears with the color of the button that when clicked shows the menu.
<p:selectOneMenu id="nombre" value="#{actividad.nombre} style="width:150px">
<f:selectItem itemLabel="Nombre" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{actividad.a}" />
</p:selectOneMenu>
If i change it to it appears correctly but i want to use the one from primefaces
to make the interface look good. Any suggestions on why this happens, Thank you!!
Give the correct doctype to your page.
Your page should also have all the required tags properly (<head>, <body> etc)
Validate the output HTML and see if it is validateable. (Note that not all Primefaces components output validateable code)
Check on multiple browsers and see what is happening.

JSF Trinidad Rendering not working

I have a requirement, where selection of an item from one drop down, triggers the displays for another drop down. So i used a autosubmit on the 1st dropdown and valueChange Listener which set the flags for displaying the 2nd drop down.Thought the flag is set to true, the 2nd drop down is not getting rendered. Is this a right way to do, am i missing some thing here.
I am testing this in tomcat using trinidad 2.0.1 and JSF Core 2.0.2. Any help on this is highly appreciated
<h:form>
<tr:panelFormLayout labelWidth="30%">
<tr:selectOneChoice id="prior" value="#{render.priority}"
label="Priority" immediate="true" autoSubmit="true"
valueChangeListener="#{render.valueChanged}"
unselectedLabel="..Please select a priority">
<f:selectItem itemLabel="Low" itemValue="1" />
<f:selectItem itemLabel="Medium" itemValue="2" />
<f:selectItem itemLabel="High" itemValue="3" />
</tr:selectOneChoice>
</tr:panelFormLayout>
<tr:panelGroupLayout partialTriggers="prior"
rendered="#{render.displayInput}">
<tr:outputLabel value="Testing"></tr:outputLabel>
</tr:panelGroupLayout>
</h:form>
Is this your whole code? You would be missing some tags
<tr:document>
<tr:form>
........
</tr:form>
</tr:document>
////
<tr:form> instead of <h:form>

p:selectBooleanCheckbox and the label attached to it

The natural behaviour for a label attached to a checkbox button is to change the state of the button when it (the label) is clicked.
This works in JSF and Richfaces.
Is there a way to make it work in Primefaces(3.5) without involving javascript ?
Is this a bug ?
<p:outputLabel for="checkbox" value="Select it:" />
<p:selectBooleanCheckbox id="checkbox" label="My label" value="#{bean.value}" />
It doesn't work out-of-the-box in plain JSF but in PrimeFaces the itemLabel attribute should do it:
<p:selectBooleanCheckbox id="checkbox" itemLabel="My label" ... />
This bug has been fixed since PrimeFaces 4, so you can use p:outputLabel with recent versions of PrimeFaces. Good thing of the p:outputLabel is that it allows you to add body content to it. So you can add images, icons, a link to terms and conditions, etc.
<p:selectBooleanCheckbox value="#{bean.value}"/>
<p:outputLabel for="#previous">
Label to <strong>click</strong>
</p:outputLabel>

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.

Resources