p:calendar problem with navigator and yearRange

UI Components for JSF
Post Reply
foogaro
Posts: 4
Joined: 27 Sep 2011, 11:41

04 Nov 2011, 16:59

When enabling navigator and setting the yearRange attribute,
when you select an year, the year navigation drop-box will set the value in different century, updating its values list too.

Code: Select all

<p:calendar  size="12" navigator="true" yearRange="c-100:c-17" value="#{myBean.myDate}" validator="#{myBean.validateMyDate}" id="myDate" locale="it"><f:convertDateTime  pattern="dd/MM/yyyy" /></p:calendar>

Code: Select all

@ManagedBean(name = "myBean")
@ViewScoped
public class MyBean {

   private Date myDate;

   public void setMyDate(Date date) { this.myDate = date; }
   public Date getMyDate() {return this.myDate; }

   public void validateMyDate(FacesContext context, UIComponent component, Object value){
        if(value!=null && value instanceof Date){
            Date d = (Date) value;

            if(!atLeast17(d)){
                throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Must be at least 17", "Must be at least 17"));
            }
        }
    }

}
Just for your information, the validation method just checks if it is 17 years old, eventually throwing a ValidatorException.

If I select 1994, I got selected 1894 and the values list is updated recalculating with its yearRange, so every time a select a different year, the maximum year available decreases of 17 units.

Any ideas?

Regards,
foogaro

JSF 2.0
PrimeFaces 2.2.1
Mojarra 2.1.3
Glassfish 3.1.1
Chrome 15.0.874.106

foogaro
Posts: 4
Joined: 27 Sep 2011, 11:41

14 Nov 2011, 12:32

Nobody knows about it?

;)

martijnhiemstra
Posts: 9
Joined: 04 Apr 2013, 15:48

30 May 2013, 15:24

I can confirm this is a bug in Primefaces 3.4.

A temporary solution is not to use c but a variable containing the current year.

felixthomas
Posts: 4
Joined: 17 Jan 2014, 17:30
Location: Chennai

19 Jan 2014, 13:16

The same thing is happening in primefaces 4.0 also. If i value in the date picker is 01-01-1990 and yearRange property set to c-20 then it shows years from 1970 and not from the current year. though I am very new to Primefaces i feel that it shouldn't be this way.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 66 guests