开发者

problem with primefaces schedule

i have tried开发者_C百科 to write a simple page containing scheduler

it looks fine but the listeners like

eventSelectListener,dateSelectListener,eventMoveListener never fired!

what is the problem

this is my code:

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@taglib uri="http://primefaces.prime.com.tr/ui" prefix="p"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
   <base href="<%=basePath%>">

   <title>My JSF 'Calendar.jsp' starting page</title>

   <meta http-equiv="pragma" content="no-cache">
   <meta http-equiv="cache-control" content="no-cache">
   <meta http-equiv="expires" content="0">   
   <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
   <meta http-equiv="description" content="This is my page">
   <!--
   <link rel="stylesheet" type="text/css" href="styles.css">
   -->

</head>

<body>
   <f:view>
   <p:resources/>
      <h:form>
      <p:schedule value="#{ScheduleBean.model}" editable="true"  aspectRatio="4"
      eventSelectListener="#{ScheduleBean.onEventSelect}"
      dateSelectListener="#{ScheduleBean.onDateSelect}"
      eventMoveListener="#{ScheduleBean.onEventMove}"
      >
      </p:schedule>
      </h:form>
   </f:view>
</body>
</html>

and my back bean is:

package com.pardis.calendar.model;

import java.util.HashMap;
import java.util.List;

import javax.annotation.PostConstruct;

import org.primefaces.event.DateSelectEvent;
import org.primefaces.event.ScheduleEntryMoveEvent;
import org.primefaces.event.ScheduleEntrySelectEvent;
import org.primefaces.model.DefaultScheduleModel;
import org.primefaces.model.ScheduleModel;

import com.fanava.genericmanagedbeans.utls.ManagedBeanUtils;
import com.pardis.calendar.dm.calendar.CalendarBean;
import com.pardis.calendar.dm.user.UserBean;

public class ScheduleBean {
   private ScheduleModel model;
   private int userId;
   private int systemId;

   public int getSystemId() {
      return 1;
   }

   public void setSystemId(int systemId) {
      this.systemId = systemId;
   }

   public ScheduleBean() {
      model = new DefaultScheduleModel();
   }
   @PostConstruct
   public void Initialize() {
      ...
   }
   public void onEventSelect(ScheduleEntrySelectEvent selectEvent){
      System.out.println("done");
   }
   public void onDateSelect(DateSelectEvent selectEvent) {
      System.out.println("done");
      }
   public void onEventMove(ScheduleEntryMoveEvent selectEvent) {
      System.out.println("move");
      }

   public ScheduleModel getModel() {
      return model;
   }

   public int getUserId() {
      return 1;
   }

   public void setUserId(int userId) {
      this.userId = userId;
   }
}


I had a similar issue with my events not showing up. As it turns out I had nested form and outputLabel elements that would not allow the schedule to render properly. I am not sure why but once I minimized the nesting it rendered just fine. Just throwing that out there.


The <p:resources/> sould be placed inside the <head>. Check chapter 2.3 of the User Guide.

Unrelated to the problem, I strongly recommend to abandon JSP and go use its successor Facelets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜