Problem with calendar and required="true" validation

UI Components for JSF
Post Reply
damm
Posts: 27
Joined: 27 Apr 2011, 13:55
Location: Cordoba, Argentina

27 Apr 2011, 15:03

Hello everyone. I'm using glassfish 3.1, primefaces 2.2.1 and firefox 3.6.
I'm using a calendar with showOn="button" and I want to validate that a value was inserted when focus is lost, using required="true", p:ajax and a message. The problem is that when I click the calendar button and choose a date, the validator message appears for a second and then dissapears. I think it should never appear. Also, if I first click in the input field of the calendar and then click the calendar button, the validator message appears, and doesn't dissapear until I select a date.

Then I have a second calendar. If I click the calendar button and select a date, the validator message appears and doesn't go away.
here's the code:

Code: Select all

<h:outputLabel value="Date from" />
<p:calendar id="dateFrom" value="#{applications.dateFrom}" label="Date from"
                  required="true" pattern="dd/MM/yyyy" showOn="button"
                  selectListener="#{applications.handleDateFromSelect}"
                  onSelectUpdate="dateTo dateFromVal">
        <p:ajax event="blur" process="dateFrom" update="dateFromVal"/>
</p:calendar>
 <p:message id="dateFromVal" for="dateFrom" display="icon"/>
<h:outputLabel value="Date to" />
<p:calendar id="dateTo" value="#{applications.dateTo}" label="Date to"
                  showOn="button" pattern="dd/MM/yyyy" required="true"
                  mindate="#{applications.dateFrom}" 
                  onSelectProcess="dateTo" onSelectUpdate="dateToVal">
        <p:ajax event="blur" update="dateToVal"/>
 </p:calendar>
<p:message id="dateToVal" for="dateTo" display="icon"/>
This is the method handleDateFromSelect in the backing bean:

Code: Select all

public void handleDateFromSelect(DateSelectEvent event) {
        dateFrom = event.getDate();
}
What am I doing wrong? what's the best way to implement required validation in a calendar?

Thank you very much,
Damian

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 29 guests