views:

98

answers:

1

hi all

i have tried 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;
   }
}
A: 

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.

BalusC
thanks, changing the <p:/resources> position does not help!i have tried to use faceclet but i was unsuccessfull!could you please answer my post?http://stackoverflow.com/questions/3598738/how-to-make-facelet-workthanks
arash
thanks now facelet works. but it does not show events! also the above problem has not been solved!
arash
Are you using JSF 1.2 or 2.0? I have the impression that you were using JSF 1.2 and are reading guidelines/tutorials targeted on JSF 2.0 which leads to all the problems and confusion. If your servletcontainer is capable of it, I recommend to go for JSF 2.0.
BalusC
i am using myfaces api 1.2.7. i can't go for JSF2.0, how can i use this component on my configuration? is any specific tutorial available?
arash
Oh, it's MyFaces 1.2? Okay.. Why can't you go for JSF 2.0? Well, after all you need to carefully read the JSF 1.2 specific instructions in PrimeFaces guide and another places. Sorry, I can't be of more assistance since I can't tell from top of head how PrimeFaces 2 + JSF 1.2 is supposed to work together. In future questions, I strongly recommend to mention the JSF impl/version used to avoid confusions and red herrings in question/answers.
BalusC
i am using primefaces-1.0.2.jar which compatible with JSF1.2!
arash