Primefaces calendar component show only month and year

后端 未结 12 1894
南笙
南笙 2020-12-14 03:25

primefaces calendar component is getting Date by default. Can I get only month and year without dates.

How to get only month and year

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-14 03:57

    I just hid the table of the day picker with CSS. I also had to create my own arrows for navigating, because the standard arrows do not fire the dateSelect event.

    Markup:

    
    
    
        
    
    
    
    

    CSS:

    .tableView table,
    .tableView a.ui-datepicker-prev,
    .tableView a.ui-datepicker-next {
        display: none;
    }
    

    Bean methods:

    public void decrementMonth() throws Exception {  
        Calendar c = Calendar.getInstance();
        c.setTime(this.selectedDate);
        c.add(Calendar.MONTH, -1);
    
                //... business logic to update date dependent data
    }  
    
    public void incrementMonth() throws Exception {  
        Calendar c = Calendar.getInstance();
        c.setTime(this.selectedDate);
        c.add(Calendar.MONTH, 1);
    
                //... business logic to update date dependent data
    }  
    

    Result (PrimeFaces 3.4.2):

    PrimeFaces calendar modified to show only month and year

提交回复
热议问题