java - Primefaces schedule and selectEvent -


i use 5.0 now, in 4.0 same. 3.5 works well.

i've got scheduleevent implementation, store in postgresql table jpa. use lazy data model, can persist new events, , load them back. event , title appear in schedult.

schedulemanager session scoped bean, handle ajax events, oneventmove, oneventresize, , oneventselect. last event handler getobject method give null, can't edit event.

my event implementation this:

@entity @table(name = "basescheduleevent") @namedquery(name = "basescheduleevent.findall", query = "select l basescheduleevent l") public class basescheduleevent implements scheduleevent, serializable {    private static final long serialversionuid = 6213082779383114637l;    private string id;   private string title;   private object data;   private date startdate;   private date enddate;   private string description;     @id    @generatedvalue(strategy = generationtype.identity)    @column(unique = true, nullable = false)    public string getid() {       return this.id;    }     public void setid(string id) {       this.id = id;    }     @lob    @override    public object getdata() {       return this.data;    }     public void setdata(object data) {       this.data = data;    } ... 

and handler method this:

   public void oneventselect(selectevent selectevent) {       scheduleevent event = (scheduleevent) selectevent.getobject();       if (event != null) {          eventhistory eventhistory = (eventhistory) event.getdata();          subject subject = eventhistory.getsubject();       }    } 

and here xhtml schedule:

<h:form id="scheduleform">      <p:schedule style="width:100%;height:100%" view="month" id="schedule" widgetvar="schedulewidget"         timezone="europe/budapest" widgetvar="schedulewidget" locale="hu"         value="#{schedulemanager.eventmodel}"         binding="#{schedulemanager.schedule}">         <p:ajax event="dateselect"            listener="#{schedulemanager.ondateselect}" update=":timerform"            oncomplete="pf('timerdialogwidget').show();" />         <p:ajax event="eventselect"            listener="#{schedulemanager.oneventselect}" update=":timerform"            oncomplete="pf('timerdialogwidget').show();" />         <p:ajax event="eventmove" listener="#{schedulemanager.oneventmove}" />         <p:ajax event="eventresize"            listener="#{schedulemanager.oneventresize}" />      </p:schedule> </h:form> 

so googled around solution, can't find solution. found allways old primeface event handlers, , solutions.

move , resize have null pointer exception before event handler.

please let me know solution.

i put clean method call load method sessionscoped bean:

@named @sessionscoped public class schedulemanager implements serializable {     private static final long serialversionuid = 620934289508314544l;     private basescheduleevent currentevent;     private schedulemodel lazyeventmodel;     @inject    private userservice userservice;     @inject    private scheduleservice scheduleservice;     public schedulemodel geteventmodel() {       lazyeventmodel = new lazyschedulemodel() {           private static final long serialversionuid = -7030798462691388329l;           public void loadevents(date start, date end) {              final timezone timezone = timezone.gettimezone("europe/budapest");             list<scheduleevent> eventlist = scheduleservice.loadevents(                   start, end, timezone);             clear();             (scheduleevent event : eventlist) {                addevent(event);             }          }       };       return lazyeventmodel;    } 

in schedule.java found may find problem. id missing.

    else if(eventname.equals("eventselect")) {         string selectedeventid = params.get(clientid + "_selectedeventid");     scheduleevent selectedevent = this.getvalue().getevent(selectedeventid);          wrapperevent = new selectevent(this, behaviorevent.getbehavior(), selectedevent); 

this.getvalue().getevent() give null (getvalue event arraylist.size = 0, , why selectedevent null). run after persist object, , event has id, confirmed @ database. events load scheduler, see events in view. when load events, each has id value.

in defaultschedulemodel @ public scheduleevent getevent(string id) id parameter "e3fdce6b-8f4b-4b41-b6f4-19c0a9496e63" value , (arraylist)events.size = 0 @ loop (scheduleevent event : events) each time when check id @ sessionscoped bean methods id null.

the solution easier. add check null.

 public schedulemodel geteventmodel() {   if (lazyeventmodel == null) {      lazyeventmodel = new lazyschedulemodel() { 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -