I am trying a userform with primefaces 3.5, all the components are working fine except selectonemenu, which not render correctly.
Its text field is not showing on selection of any drop down field.
i can't post image as i don't have that much reputation
Code
<p:panelGrid id="jobsGrid" columns="2" style="width:100%;margin-bottom:20px;margin-top:20px; margin-left:20px;margin-right:20px;text-align:left;">
<f:facet name="header"> ----- Quick Job Posting -----</f:facet>
<h:outputText value="OLF Number " />
<p:inputText value="#{jobs.jobDetail.OLF_No}" />
<h:outputText value="RRF Number " />
<p:inputText value="#{jobs.jobDetail.RRF_No}" />
<h:outputText value="OLF Status " />
<p:selectOneMenu value="#{jobs.jobDetail.OLF_Status}" style="margin-top:0px;margin-bottom:0px;height:5px;font-size:10px">
<f:selectItem itemLabel="---- Select ----" itemValue="" />
<f:selectItem itemLabel="Approved" itemValue="Approved" />
<f:selectItem itemLabel="Pending Approval" itemValue="Pending Approval" />
<f:selectItem itemLabel="New" itemValue="New" />
</p:selectOneMenu>
<h:outputText value="RRF Type " />
<p:selectOneMenu value="#{jobs.jobDetail.RRF_type}" style="margin-top:0px;margin-bottom:0px;height:5px;font-size:10px">
<f:selectItem itemLabel="---- Select ----" itemValue="" />
<f:selectItem itemLabel="Growth" itemValue="Growth" />
<f:selectItem itemLabel="Replacement" itemValue="Replacement" />
</p:selectOneMenu>
Screen Shot
How can i fix this ?
I fixed this this problem by adding following CSS to my page:
.ui-selectonemenu label.ui-selectonemenu-label{
width:100% !important;
}
I also have fixed widths on my selectonemenus.
Hope this helps in your case also. ;)
This is definitely a problem in Primefaces 3.5. I had the exact same issue, and downgrading to 3.4 solved it.
As a data point, it is worth noting that the rendering problem only existed when I navigated to the page through a p:remoteCommand. Normal action-based navigation works correctly, at least for me.
You can post your code some here, or if not try checking BalusC http://balusc.blogspot.nl/2007/09/objects-in-hselectonemenu.html
If you see that your bean annotations are correct, try using primefaces 3.4 or lower versions.
Related
I have a table, and I want to put inside any row of this table a custom p:radioButton, on two different columns.
This is the code of the p:selectOneRadio:
<p:selectOneRadio
value="#{bean.val}"
id="val"
required="true"
layout="custom"
>
<f:selectItem itemLabel="" itemValue="A" />
<f:selectItem itemLabel="" itemValue="B" />
</p:selectOneRadio>
and this is the code of one of the radioButton:
<p:radioButton for="tabs:table:#{i}:val" itemIndex="0"/>
I checked with the browser and the id is right. Anyway, I get this error:
javax.faces.FacesException: Cannot find component 'tabs:table:0:val' in view.
What could be the problem? Please help :)
I'm using Primefaces 3.4.1 with Mojarra 2.1.7
Well, the solution was simple, and it was suggested to me by BalusC:
<p:radioButton for="val" itemIndex="0"/>
I'm facing a problem related to radioButtons inside a rich:column of a h:extendedDatatable.
I've been reading several blogs and some questions right here in stackoverflow but almost everyone seems to want to put the radioButton options spread through several rows. This is not my case: I'd need to show 'n' groups of three radios every row in my table.
I can't find what I'm doing wrong because I tried putting the radioGroup out of the table and everything worked fine. However, if I put them into the rich:column all my radios appear unchecked.
Here the current code for the column:
<rich:column id="CCATEG_column" >
<h:selectOneRadio id="CCATEG" value="2">
<f:selectItem id="CCATEG_MANAGER" itemValue="1" itemLabel="" />
<f:selectItem id="CCATEG_COMANAGER" itemValue="2" itemLabel="" />
<f:selectItem id="CCATEG_MEMBER" itemValue="3" itemLabel="" />
</h:selectOneRadio>
</rich:column>
I've tried with h:selectOneRadio and wih t:selectOneRadio (tomahawk). Both of them show me the three radios unchecked every row, even when I'm specifying value="2" Any help?
Thanks in advance!!
According to the docs the #value is supposed to be a ValueExpression, so a hard-coded value will not do (I assume this isn't the final use-case). This will work:
<rich:dataTable value="#{bean.intList}" var="value">
<rich:column>
<h:selectOneRadio value="#{value}">
<f:selectItem itemValue="1" />
<f:selectItem itemValue="2" />
<f:selectItem itemValue="3" />
</h:selectOneRadio>
</rich:column>
</rich:dataTable>
By the way, your example doesn't work with standard <h:dataTable>, <h:column> either.
I have the following selectOneMenu and within of my component I want to have an item which shouldn't be shown, for e.g. in cases where the value from #{Mybean.value} match a value from #{Mybean.ListValues} I don't want to have an empty option in my combo box .
<p:selectOneMenu value="#{Mybean.value}" hideNoSelectionOption="true"
required="true" requiredMessage="Required data">
<f:selectItem itemLabel="" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{Mybean.ListValues}" var="option" itemLabel="#{option.optionName}"
itemValue="#{option.optionId}"/>
</p:selectOneMenu>
I searched, but I didn't find anything useful, just one link in primefaces forum where describes exactly this problem.
My primefaces version is 3.5
Edit: it is supported from version 9 and on, see the other answer.
That attribute doesn't exist in the official api or in the doc. Where did you get it from?
What you're actually looking for is the itemDisabled attribute on the f:selectItems component. It's this attribute that disables a selectItem from being selected. Historically, primefaces has had problems with that attribute.
Ideally, you should have
<p:selectOneMenu value="#{Mybean.value}" required="true" requiredMessage="Required data">
<f:selectItem itemLabel="" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems itemDisabled="#{Mybean.value=='aValue'}" value="#{Mybean.ListValues}" var="option" itemLabel="#{option.optionName}" itemValue="#{option.optionId}"/>
</p:selectOneMenu>
hideNoSelectionOption implemented in PrimeFaces 9.0
Issue: https://github.com/primefaces/primefaces/issues/5886
PR: https://github.com/primefaces/primefaces/pull/5909
So, basically and based on #kolossus answer, we can in primefaces (when you are using <p:selectOneMenu...) case add the following empty item
<f:selectItem itemValue="#{null}" itemLabel="--select--" itemDisabled="#{Mybean.value ne null}" />
We can in primefaces (when we have to use
Note: In such case we don't need the following two tags:
hideNoSelectionOption="true"
and
noSelectionOption="true"
below you see some part of my code, i just want to select the first value in a form and the rest should be updated via ajax, for example if you select PK than, MccName, MccVorname,MccDepartment should be shown via ajax after this selection.
This should also be possible in other forms indepently,
<h:panelGrid columns="4">
<h:form id="formmcc10">
<h:outputText value="Pls select PK: " />
<p:selectOneMenu value="#categorymcc.mcccatname}" id="mcccat"
immediate="true" valueChangeListener="#categorymcc.processScat}">
<f:selectItem itemLabel="#categorymcc.mcccatname}"itemValue="" />
<f:selectItems value="#categorymcc.categoryName}" />
<p:ajax update="formmcc10:mccscat1 formmcc10:mccscat2 formmcc10:mccscat3" event="change" />
</p:selectOneMenu><h:outputText value="Mcc Name" />
<p:selectOneMenu value="#{categorymcc.submcccatname}"id="mccscat1">
<f:selectItemsvalue="#{categorymcc.subCategoryName}" />
</p:selectOneMenu>
<h:outputText value="Mcc Vorname" />
<p:selectOneMenu value="#{categorymcc.subsubmcccatname}"id="mccscat2">
<f:selectItems value="#{categorymcc.subSubCategoryName}" />
</p:selectOneMenu>
<h:outputText value="Mcc Department:" />
<p:selectOneMenu value="#{categorymcc.abteilung}" id="mccscat3">
<f:selectItems value="#{categorymcc.abteilungCategoryName}" />
</p:selectOneMenu>
</h:form>
</h:panelGrid>
This could be anything, but I encountered one interesting problem like that recently. I tried to output a bean property like #{myBean.otherBean.name} and it worked when I loaded the page by normal request, but it didn't work with AJAX. When I tried #{myBean.otherBean.id}, it worked in both cases.
The problem was, that backend system didn't fill all data for otherBean on AJAX request, it filled only id (probably for better performance). I had to prepare a getOtherBeanById method and when I called that, AJAX started to work as expected.
I'm not an expert on this field, perhaps someone has a more precise explanation for that.
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().