primefaces JSF p:selectOneMenu submitting null value - jsf

after researching for a while I still cannot find what I'm doing wrong.
I'm using Primefaces 3.5 with Seam. I have a selectOneMenu that is submitting a null value to the method manualServiceRequestController.setService(Service service).
This is the .xhtml code:
<p:selectOneMenu id="service" value="#{manualServiceRequestController.service}">
<f:converter converterId="serviceConverter" />
<f:selectItems value="#{manualServiceRequestController.allServices}" />
<p:ajax render="parameterPanel" event="change" process="#parent" partialSubmit="true" />
</p:selectOneMenu>
Thanks!

The problem was the attribute partialSubmit="true". I removed it and now the correct value is sent. I still don't understand exactly why.
Thanks skuntsel and Xtreme Biker for your responses.
Regards!

Related

Custom p:radioButton does not work inside a table: id of select not found

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"/>

richfaces 4 extendeddatatable not showing updated data after ajax render

Environment:
Jboss 7.1.1.Final JSF 2.2.6 Seam 2.3.1.Final Richfaces 4.5.10.Final
Issue
Richfaces 4 extendeddatatable on render does not hold the value (Resource dropdown in the example listed below).
Steps:
First I choose a value from the Resource dropdown
Then I choose a value form the Result dropdown which triggers the a4j:ajax call
My XHTML structure is as listed below:
<a4j:region id="hraregion">
<rich:extendedDataTable id="hraProcessing"
value="#{maActionList}" var="mpa" selectionMode="single">
<h:column width="200px">
<f:facet name="header">
<h:outputText value="Resource" />
</f:facet>
<h:selectOneMenu id="staffResources" value="{mpa.staffResources}" label="Resource"
<s:selectItems value="#{mpa.validStaffResources}" var="sr" label="#{sr.firstName} #{sr.lastName}"/>
<s:convertEntity />
</h:selectOneMenu>
</h:column>
<rich:column width="140px">
<f:facet name="header">
<h:outputText value="Result" />
</f:facet>
<h:selectOneMenu id="results" value="#{mpa.actionResults}">
<a4j:ajax execute="region" listener="#{maintainAssessment.performNextAction(mpa, 'mpa')}" render="hraProcessing, actionMessage" />
<s:selectItems value="#{mpa.validActionResults}" var="ar" label="#{ar.name}" noSelectionLabel="Select One" />
<s:convertEntity />
</h:selectOneMenu>
</rich:column>
</rich:extendedDataTable>
</a4j:region>
Note:
We are migrating from Richfaces 3.3 to 4.5 and this functionality was working fine in Richfaces 3.3 but ofcourse the entire page was refreshed in 3.3 as opposed to the partial refresh in Richfaces 4.5
Can someone please point me in the right direction on how to retain the selected value after the a4j render happens?
I found a way to accomplish this by updating the backing bean immediately using f:ajax after the value changes in the Resource dropdown. Hope this helps someone who faces the same issue.
<h:selectOneMenu id="staffResources" value="#{mpa.staffResources}"
label="Resource" styleClass="LFloat">
<s:selectItems value="#{mpa.validStaffResources}" var="sr"
label="#{sr.firstName} #{sr.lastName}"/>
<s:convertEntity />
<f:ajax event="valueChange" execute="#this" render="#none"/>
</h:selectOneMenu>

p:commandLink not getting updated

I am using Primefaces 4.0.
Problem i am facing is CommandLink not Getting updated on change event of SelectOnemenu.Code as Follows:-
<p:selectOneMenu id="List"
value="#{Bean.selectedId}" style="width:230px">
<f:selectItem itemLabel="--Select--" />
<f:selectItems value="#{Bean.SelectItemList}" />
<p:ajax event="change" update="enableGo,disableGo"></p:ajax>
</p:selectOneMenu>
<p:commandLink id="enableGo" value="GO" styleClass="blueButton"
rendered="#{Bean.selectedId != null}"
action="#{note.load}">
</p:commandLink>
<p:commandLink id="disableGo" value="GO"
styleClass="disabledButton"
rendered="#{Bean.selectedId == null}">
</p:commandLink>
I also tried updating with the formid eg: ":formid:enableGo,:formid:disableGo" but it didnt work!.
The client side javascript won't be able to find either of the components to update. You'll need to wrap them (the <p:commandLink>s) in a wrapper and then update the wrappers. See BalusC's answer for more details and an example.

p:watermark clears on updating Component even if there is no value

I'm using Primefaces p:watermark on a p:inputText. Its working fine.
When ever I update the component its loosing watermark,even when there is no content inside the p:inputText
<h:form id="reg_frm">
<p:inputText id="name" value="#{user.name}"/>
<p:watermark value="your name" for="name" id="name_watermark" />
<p:selectOneMenu value="#{user.drpvalue}">
<f:selectItem itemLabel="One" itemValue="1"/>
<f:selectItem itemLabel="two" itemValue="2"/>
<f:selectItem itemLabel="three" itemValue="3"/>
<f:selectItem itemLabel="four" itemValue="4"/>
<p:ajax event="change" update="name name_watermark"/>
</p:selectOneMenu>
</h:form>
How do I retain the Watermark when there is no content in the
p:inputText after update?
Note: Primefaces version - 3.5
According to the PrimeFaces showcase for watermarks: "Watermark displays a hint about input fields by using native placeholder in supported browsers and a javascript solution in others browser compatibility."
PrimeFaces probably adds some hidden javascript stuff to the element which is a parent of both components (input and watermark). In your case that's the form which you would need to update. If you don't want that, put a new panelgroup around both elements and update that, which will have the same effect.
Try this attribute:
oncomplete="PrimeFaces.showWatermarks()"
It was given in Primefaces User's Guide.

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