<p:selectonebutton> - 选项二不调用ajax Action,但为什么?</p:selectonebutton>

时间:2012-10-19 08:34:10

标签: javascript ajax jsf jsf-2 primefaces

现在我有一个<p:selectOneButton>有两个选项试图转储我。 这是<p:selectOneButton>

的代码
<p:selectOneButton value="#{hldyPlanningController.selectedView}" id="opt_vType" >
   <f:selectItem itemLabel="Abteilungssicht" itemValue="1" />
   <f:selectItem itemLabel="Teamsicht" itemValue="2" />
   <p:ajax update="frm_plan:schedule" listener="#{hldyPlanningController.updateModel()}"/>
</p:selectOneButton>

我使用AJAX来更改数据,这是在<p:schedule>中查看的。选项1调用操作,但选项2不会调用操作。我试图调试并认识到值从1变为2,但根本不调用该方法。这有什么理由吗?

这是辅助bean中的方法,由<p:selectOneButton>

调用
public void updateModel() {

        eventModel = null;
        eventModel = new DefaultScheduleModel();

        try {

            switch(selectedView){
                case 1: holidayData = flow.sql.QueryMySQL.getHolidaysData(lgc.getSessionData().getDepartment_id(), 3); break;
                case 2: holidayData = flow.sql.QueryMySQL.getHolidaysData(lgc.getSessionData().getTeams_id(),2); break;
            }

            int k = 0;
            Calendar b1 = new GregorianCalendar();
            Calendar b2 = new GregorianCalendar();

            for(int i=0; i<=holidayData.size()-1; i++ ) {

                b1.setTime(holidayData.get(i).getHldy_startdate());
                b1.set(Calendar.DATE, b1.get(Calendar.DAY_OF_MONTH)+1);                
                b2.setTime(holidayData.get(i).getHldy_enddate());

                scheduledEvent = new DefaultScheduleEvent(holidayData.get(i).getUser_name(),b1.getTime(),b2.getTime(),holidayData.get(i));

                if(i==0){
                    scheduledEvent.setStyleClass(styleClasses[k]);
                }else if(holidayData.get(i).getUser_name().equals(holidayData.get(i-1).getUser_name())){
                    scheduledEvent.setStyleClass(styleClasses[k]);
                }else if(k < styleClasses.length){
                    k++;
                    scheduledEvent.setStyleClass(styleClasses[k]);
                }else {
                    k=0;
                    scheduledEvent.setStyleClass(styleClasses[k]);
                }

                scheduledEvent.setAllDay(true);

                eventModel.addEvent(scheduledEvent);

            }

            for(int y=0; y < 2; y++ ){

                gblHolidayData = flow.sql.QueryMySQL.getGblHolidays(Calendar.getInstance().get(Calendar.YEAR)+y);

                for(int i=0; i<=gblHolidayData.size()-1; i++ ) {

                    b1.setTime(gblHolidayData.get(i).getDate());
                    b1.set(Calendar.DATE, b1.get(Calendar.DAY_OF_MONTH)+1);                

                    scheduledEvent = new DefaultScheduleEvent(gblHolidayData.get(i).getDescription(),b1.getTime(),b1.getTime(),gblHolidayData.get(i));

                    scheduledEvent.setStyleClass("gblHoliday-event");

                    scheduledEvent.setAllDay(true);

                    eventModel.addEvent(scheduledEvent);

                }
                System.out.println("###DEBUG### UPDATE MODEL "+y);
            }

        }catch(Exception e){
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "HolidayCollector ", e.getMessage()));
        }

}

我在Tomcat 7.x上使用Primefaces 3.4.1和JSF2.1.13

希望有些人对我有所暗示。

0 个答案:

没有答案