p:calendar value not set in backing bean - jsf

Hi I am using PrimeFaces. I have a <p:calendar> in a dialog box and I would type date manual . But my date is not setting in bean's variable. It works for dataSelect event but don't work keypress or keydown event. I am wondering it is also working outside dialog box. Here is my code:
<p:calendar readonlyInput="false" id="Date1" rendered="true"
navigator="true" showButtonPanel="true"
styleClass="form-control cal_input" showOn="both"
pattern="#{sessionManager.defaultDateFormat.substring(0,11)}"
yearRange="#{appLabel['year_Range']}" tabindex="203"
value="#{mangeCreateOrdersTO.searchOrderPatientBean.DOB}"
disabled="false" mask="true"
maxdate="#{mangeCreateOrdersTO.maxDateOfBirth}"
autocomplete="#{appLabel['autoCompleteSetting']}"
onkeypress="return disableEnterKey(event)">
<p:ajax event="dateSelect" process="#this" partialSubmit="true" ignoreAutoUpdate="true" update="form:Date1"/>
<p:ajax event="keydown" process="#this" immediate="true" partialSubmit="true" ignoreAutoUpdate="true" listener="#{mangeCreateOrdersTO.add(mangeCreateOrdersTO.searchOrderPatientBean.DOB)}"/>
</p:calendar>
Please help me to get rid from this problem. Thanks in advance.

I found what was wrong. So:
My <p:Calendar> must be under the <h:form> which I was missing.

Related

PrimeFaces dialog doesn't use the information I provide in the view

I have a view which contain the following fields:
<p:selectOneMenu style="width:40px" value="#{capacityFamilyBean.capacityFamily.bottleneck}">
<f:selectItems value="#{capacityFamilyBean.availableCapFamilyBottlenecks()}"/>
</p:selectOneMenu>
<p:inputText id="capacityFamilyName" binding="#{capacityFamilyName}" style="margin-left:20px" value="#{capacityFamilyBean.capacityFamily.name}">
<p:ajax event="change" update="newBundleButton"/>
</p:inputText>
<p:commandButton id="newBundleButton" icon="ui-icon-plus" disabled="#{empty capacityFamilyName.value}" value="${msgs.New}" oncomplete="PF('capacityFamilyDialog').show();"/>
you can see the value properties are {capacityFamilyBean.capacityFamily.prprty}
capacityFamilyDialog uses the same properties, but they are not pre-filled
<p:selectOneMenu value="#{capacityFamilyBean.capacityFamily.bottleneck}">
<f:selectItems value="#{capacityFamilyBean.availableCapFamilyBottlenecks()}" />
</p:selectOneMenu>
<p:inputText id="capacityFamilyName" style="margin-left:20px" value="#{capacityFamilyBean.capacityFamily.name}"/>
I'm assuming they refer to different capacityFamily object, but how can I counter that?
The dialog is delivered with the page. So it's completely empty.
oncomplete="PF('capacityFamilyDialog').show();"
is pure javascript and only shows this empty popup. If you like to have a dialog with actual values, you have to update it in an ajax-call like your commandButton.
<p:commandButton value="${msgs.New}" update="capacityFamilyDialog_ID" oncomplete="PF('capacityFamilyDialog').show();"/>
The dialogue is functional when you click the button. I think you should update the id for dialogue box.
JSF Code
<p:commandButton id="impBtb"
process="#this" icon="ui-icon-plus" disabled="#{empty capacityFamilyName.value}"
value="${msgs.New}" oncomplete="PF('capacityFamilyDialog').show();" update="#form:capacityFamilyDialog">
</p:commandButton>
So, you may have to perform a ajax-call from your commandbutton to update the dialog box.
Hope it helps!!

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.

ice:selectInputDate - valueChangeListener attribut not working when date entered manually

When I try to enter dates manually in tag that uses ice:selectInputDate, the valueChangeListener attribute doesnt work. When I click on the calendar symbol and select the date, the valueChangeListener works fine and my debug is redirected at proper method in bean.
Can anyone suggest on how to use valueChangeListener for this ice:selectInputDate when date is entered manually.
ValueChangeListener is not necessary
<ice:selectInputDate id="d1" renderMonthAsDropdown="true"
renderYearAsDropdown="true"
rendered="true"
renderAsPopup="true"
value="#{bean.myoDate}">
<f:convertDateTime pattern="dd/MM/yyyy"/>
</ice:selectInputDate>
make sure your panel/grid is enclosed with from
Try using ajax events as below
<ice:selectInputDate id="d1" renderMonthAsDropdown="true"
renderYearAsDropdown="true"
valueChangeListener ="#{yourbean.yourValueChangeListener}"
rendered="true"
renderAsPopup="true"
value="#{bean.myoDate}">
<f:convertDateTime pattern="dd/MM/yyyy"/>
<ace:ajax event="dateTextChange" execute="#this" />
<ace:ajax event="dateSelect" execute="#this" />
</ice:selectInputDate>

Update components without processing in Primefaces

I would like to update a component without processing it. I use a binding get the value of a checkbox and decide if the other component should be rendered. Unfortunately, the update? or the binding? doesn't work as i would.
<p:selectBooleanCheckbox id="isPercentage" value="#{myBean.isDiscountInPercentage}"
label="Percentage" binding="#{discountInPercentage}">
<p:ajax process="" update="outpDiscountValue" />
</p:selectBooleanCheckbox>
<p:outputPanel id="outpDiscountValue">
<h:outputLabel value="$" rendered="#{!discountInPercentage.value}" />
<h:outputLabel value="%" rendered="#{discountInPercentage.value}" />
</p:outputPanel>

Primefaces focus form

<p:inputText value="#{bmiCalculatorBean.height}" update="#form" id="height">
<p:ajax update="#form" />
<f:convertNumber pattern="0" />
</p:inputText>
<p:inputText value="#{bmiCalculatorBean.weight}" update="#form" id="weight">
<p:ajax update="#form" />
<f:convertNumber pattern="0" />
</p:inputText>
I have a problem where after I enter a value into the first inputText and click on the "weight" inputText after a short delay the focus is lost and you need to click on the input box again.
How do I fix this?
This is caused by update="#form" and expected behavior.
In general, just do not update parts which do not need to be updated and update only those which really need to be updated. E.g. only the result calculated so far and the <h|p:message> of the current input:
<p:ajax update="calculatedResult currentInput_message" />
True, this may end up in a boilerplate of IDs in update attribute in large forms. The PrimeFaces Selectors (PFS, supporting jQuery selector syntax in JSF selectors) may then help a lot in this.

Resources