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

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>

Related

ValueChangeListener not firing for h:inputText when I have a converter as well for the inputText

When I remove the f:convertDateTime , the valueChangeListerner is fired. if I put the converter it is not working . Also onblur is working better than onchange.
Can anyone tell me the fix.
Code snippet
<h:inputText id="EffectiveDate" styleClass="textInput" value="#
{bbean.effectiveDate}" binding="#{bean.uiEffectiveDate}"
onchange="submit();"
valueChangeListener="#{bbean.valueChangeEffectiveDate}">
<f:convertDateTime type="date" pattern="#{bundle.datePattern}" />
</h:inputText>

p:calendar value not set in backing bean

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.

Triggering validation of <rich:calendar> client side?

I have a rich:calendar on a jsf page like this:
<rich:calendar id="someDate"
name="aName" validatorMessage="wrong format!"
enableManualInput="true" datePattern="dd/MM/yyyy"
value="#{MyBean.someDate}" >
</rich:calendar>
<rich:message id="validationSomeDate" for="someDate"
tooltip="false" showDetail="false">
<f:facet name="errorMarker">
<h:graphicImage id="imgError" value"/someImage.gif" />
</f:facet>
</rich:message>
<rich:tooltip for="validationSomeDate" value="wrong format!"/>
This succesfully validates that the user didn't write some nonsense into the date field like "12456" or something. The problem is, this validation is only triggered when the form is submitted. I would like to have this checked as soon as the date field loses focus, all client-side. Is there a way to do this?
I tried using a
<rich:validator>
tag but I'm using richfaces 3.x and this tag isn't available.
<rich:ajaxValidator event="onblur">
doesn't help either...

How to bind a Date with calendar control in primefaces using binding attribute?

I want to bind a date with a calendar control after a specific value is selected from an autocomplete. But the following exception occurs :
javax.servlet.ServletException: java.util.Date cannot be cast to javax.faces.component.UIComponent
<p:autoComplete value="#{rechargeCustomerBean.school.schoolName}" completeMethod="#{rechargeCustomerBean.completeSchool}" required="true" />
<p:calendar mode="popup"
navigator="true" pattern="dd-MM-yyyy" effect="fadeIn"
showButtonPanel="true"
binding="#{rechargeCustomerBean.school.expiryDate}" />
Are you sure you want to bind?
Use the value attribute instead.
Also, add <p:ajax to your calendar to update the calendar and you are ready to go.
like this
<p:autoComplete value="#{rechargeCustomerBean.school.schoolName}" completeMethod="#{rechargeCustomerBean.completeSchool}" required="true">
<p:ajax event="itemSelect" update="idOfCalendar" />
</p:autoComplete>
Change
binding="#{rechargeCustomerBean.school.expiryDate}"
into
value="#{rechargeCustomerBean.school.expiryDate}"
so it will look like this
<p:calendar value="#{rechargeCustomerBean.school.expiryDate}" id="idOfCalendar"..... />
use of binding attribute in <p:calender> might cause the problem...try chaging it with value=#{...}
also make sure your bean's "expiryDate" is of type Util.Date
hope this could resolve your problem..for detailed explanation see here

Form value not passed to Seam bean after a4j reRender

I'm making a webapp in Seam but ran into a problem I can't seem to fix.
I have a JSF form where the customer can select a reservation type through a combobox. Based on the selected value, other form components gets rendered.
For example: the customer selects Hours as reservation type, a panelGroup gets rendered where the customer can select a start- and an end hour. But if the customer would select 'part of the day' as reservation type, a selectOneMenu gets rendered where the customer can select a part of the day (morning, afternoon, evening)
The rerendering well but the values of the components with a rendered conditional won't get passed to the bean. They stay null values.
This is the code i'm talking about:
<s:div id="spot"
rendered="#{selectedProduct.productType.name eq 'Flex Spot'}">
<h:panelGrid columns="2">
<h:outputText value="Reservation Type" />
<h:selectOneMenu value="#{selectedPeriodPart}">
<s:selectItems
value="#{productManager.getAvailableDayPartsSpot()}"
var="daypart"
label="#{daypart.label}"></s:selectItems>
<s:convertEnum />
<a4j:support ajaxSingle="true"
event="onchange"
action="#"
reRender="spot">
</a4j:support>
</h:selectOneMenu>
<h:outputText id="date_spot" value="Date" />
<a4j:outputPanel id="calendar_spot" layout="block">
<rich:calendar value="#{reservation.reservationPeriod.startDate}"
locale="en" cellWidth="24px"
cellHeight="22px"
style="width:200px" />
</a4j:outputPanel>
<h:outputText rendered="#{selectedPeriodPart eq 'DAY_PART'}"
value="Daypart" />
<h:selectOneMenu value="#{selectedDaypart}"
rendered="#{selectedPeriodPart eq 'DAY_PART'}">
<f:selectItem id="si_morning" itemLabel="Morning (6:00 - 12:00)"
itemValue="morning" />
<f:selectItem id="si_afternoon"
itemLabel="Afternoon (12:00 - 18:00)" itemValue="afternoon" />
<f:selectItem id="si_evening" itemLabel="Evening (18:00 - 00:00)"
itemValue="evening" />
</h:selectOneMenu>
<h:outputText rendered="#{selectedPeriodPart eq 'HOURS'}"
value="Hours" />
<h:panelGroup id="hours_spot"
rendered="#{selectedPeriodPart eq 'HOURS'}">
<ui:include src="/includes/reservation/select_hours.xhtml" />
</h:panelGroup>
</h:panelGrid>
</s:div>
Note: The calendar value do get passed back to the bean but the value of this piece of code doesn't (it does if you remove the rendered conditional):
selectOneMenu value="#{selectedDaypart}" rendered="#{selectedPeriodPart eq 'DAY_PART'}"
You need to ensure that the conditionals responsible for the outcome of the rendered attribute are also the same in the subsequent request of the form submit. Because when a component isn't rendered, JSF won't apply the request values them.
In a nutshell, the property behind #{selectedPeriodPart} needs to be the same in the subsequent request. There are several solutions:
Put bean in session scope. Easiest solution, but bad for server memory and client experience (updates would be reflected in multiple tabs/windows in same session).
Pass it through using <h:inputHidden>. Not sure though how this fits in the Ajax/Richfaces picture. Better use <a4j:keepAlive> here.
Use a conversation scope. Seam offers facilities for this.
I fixed it -.- Nothing was wrong with the code I posted.
Because I wasn't able to solve this issue I continued on an other page in the same conversation. I noticed some more strange behaviour: outjection of a variable didn't work etc.
I figured the mistake was in some other part of the code which, after corrected, fixed the whole problem.
Thx for answering guys!

Resources