Revision history [back]

click to hide/show revision 1
initial version

asked 2015-04-10 08:37:26 +0800

Aasifi gravatar image Aasifi

getting null on @Listen("onEventEdit = #calendars") event SelectorComposer<component> on clustered environment

Hello Everyone,

I have two tomcats deployed at my machine and using clustered environment for my application.I am using zk calendar at in my application.I am using SelectorComposer<component> for listing events and for Create/Edit of events I am calling my own custom jsp files.Everything works fine when application is deployed only on one tomcat but for clustering on clicking of edit of event I am getting an alert mentioning "null" only.It works fine for create event.I am unable to get the issue as it is displaying only "null" in alert.

My zul file looks like

<zk> <style src="/widgets/zk_calendar/zk_calendar/style.css"/> <window id="displayMyEntry">

<hlayout sclass="z-valign-middle"> <button id="today" label="${labels.Today}"/> <button id="prev" image="../img/arrow-180.png"/> <button id="next" image="../img/arrow.png"/> <separator width="50px"/> <button id="pageDay" label="${labels.Day}" width="55px"/> <button id="pageWeek" label="${labels.Week}" width="55px"/> <button id="pageMonth" label="${labels.Month}" width="55px"/> <separator width="50px"/> ${labels.Filter} : <textbox id="filter"/> <button id="applyFilter" label="${labels.Apply}"/> <button id="resetFilter" label="${labels.Reset}"/> </hlayout> <separator bar="true" height="20px"/>

        <calendars id="calendars" firstDayOfWeek="Sunday" height="600px" 
            mold="month">
            <toolbar sclass="calendar-toolbar">
                <div class="float-left">
                </div>
            </toolbar>
            </calendars>
    </div>

</window>

</zk>

Also my CalendarController.java is

public class CalendarController extends SelectorComposer<component> implements Serializable {

private static final long serialVersionUID = 1L;
 DateFormat formatter;
 int key = 0;
 public HashMap eventMap = new HashMap();

@Wire
private Calendars calendars;
@Wire
private Textbox filter;

private CalendarModel calendarModel;

//the in editing calendar ui event
private CalendarsEvent calendarsEvent = null;

@Override
public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);
    calendarModel = new CalendarModel(new CalendarData().getCalendarEvents());
    calendars.setModel(this.calendarModel);
}


@Listen("onEventCreate = #calendars")
public void createEvent(CalendarsEvent event) {
    System.out.println("onEventCreate :::"+event.getName());
    formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    String stDate = "";
    String endDate = "";
    if (event != null)
    {
        stDate = formatter.format(event.getBeginDate());
        endDate = formatter.format(event.getEndDate());
    }
    String uri = "createEvent.jsp?startDate=" + stDate + "&endDate=" + endDate; 
    try {
        java.net.URLEncoder.encode(uri, "UTF-8");
    } catch (UnsupportedEncodingException e) {

        e.printStackTrace();
    }

    Executions.getCurrent().sendRedirect(uri, "_parent");
}

/* Unable to call this method when used in clustering*/
@Listen("onEventEdit = #calendars")
public void editEvent(CalendarsEvent event) {
        try {
    System.out.println("onEventEdit");      
    org.zkoss.calendar.Calendars cal = (org.zkoss.calendar.Calendars) event.getTarget();
    SimpleCalendarModel m = (SimpleCalendarModel) cal.getModel();
    SimpleCalendarEvent sce = (SimpleCalendarEvent) event.getCalendarEvent();
    int index = m.indexOf(sce);

    eventMap = (HashMap)Sessions.getCurrent().getAttribute("eventMap");
    int eventid = Integer.parseInt(eventMap.get(index).toString());
    String uri = "e_event.jsp?eventid="+eventid;

        java.net.URLEncoder.encode(uri, "UTF-8");
        Executions.getCurrent().sendRedirect(uri, "_parent");
        } catch (UnsupportedEncodingException e) {

            e.printStackTrace();
        }
    }

@Listen("onEventUpdate = #calendars")
public void updateEvent(CalendarsEvent event) {
    System.out.println("onEventUpdate");
    CalendarEvents data = (CalendarEvents) event.getCalendarEvent();
    data.setBeginDate(event.getBeginDate());
    data.setEndDate(event.getEndDate());
    calendarModel.update(data);
}

}

Please help me out.Any help would be highly appreciated. Regards, Aasif Iqbal

getting null on @Listen("onEventEdit = #calendars") event SelectorComposer<component> on clustered environment

Hello Everyone,

I have two tomcats deployed at my machine and using clustered environment for my application.I am using zk calendar at in my application.I am using SelectorComposer<component> for listing events and for Create/Edit of events I am calling my own custom jsp files.Everything works fine when application is deployed only on one tomcat but for clustering on clicking of edit of event I am getting an alert mentioning "null" only.It works fine for create event.I am unable to get the issue as it is displaying only "null" in alert.

My zul file looks like

<zk> <style src="/widgets/zk_calendar/zk_calendar/style.css"/> <window id="displayMyEntry">

<hlayout sclass="z-valign-middle"> <button id="today" label="${labels.Today}"/> <button id="prev" image="../img/arrow-180.png"/> <button id="next" image="../img/arrow.png"/> <separator width="50px"/> <button id="pageDay" label="${labels.Day}" width="55px"/> <button id="pageWeek" label="${labels.Week}" width="55px"/> <button id="pageMonth" label="${labels.Month}" width="55px"/> <separator width="50px"/> ${labels.Filter} : <textbox id="filter"/> <button id="applyFilter" label="${labels.Apply}"/> <button id="resetFilter" label="${labels.Reset}"/> </hlayout> <separator bar="true" height="20px"/>

        <calendars id="calendars" firstDayOfWeek="Sunday" height="600px" 
            mold="month">
            <toolbar sclass="calendar-toolbar">
                <div class="float-left">
                </div>
            </toolbar>
            </calendars>
    </div>

</window>

</zk>

Also my CalendarController.java is

public class CalendarController extends SelectorComposer<component> implements Serializable {

private static final long serialVersionUID = 1L;
 DateFormat formatter;
 int key = 0;
 public HashMap eventMap = new HashMap();

@Wire
private Calendars calendars;
@Wire
private Textbox filter;

private CalendarModel calendarModel;

//the in editing calendar ui event
private CalendarsEvent calendarsEvent = null;

@Override
public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);
    calendarModel = new CalendarModel(new CalendarData().getCalendarEvents());
    calendars.setModel(this.calendarModel);
}


@Listen("onEventCreate = #calendars")
public void createEvent(CalendarsEvent event) {
    System.out.println("onEventCreate :::"+event.getName());
    formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    String stDate = "";
    String endDate = "";
    if (event != null)
    {
        stDate = formatter.format(event.getBeginDate());
        endDate = formatter.format(event.getEndDate());
    }
    String uri = "createEvent.jsp?startDate=" + stDate + "&endDate=" + endDate; 
    try {
        java.net.URLEncoder.encode(uri, "UTF-8");
    } catch (UnsupportedEncodingException e) {

        e.printStackTrace();
    }

    Executions.getCurrent().sendRedirect(uri, "_parent");
}

/* Unable to call this method when used in clustering*/
@Listen("onEventEdit = #calendars")
public void editEvent(CalendarsEvent event) {
        try {
    System.out.println("onEventEdit");      
    org.zkoss.calendar.Calendars cal = (org.zkoss.calendar.Calendars) event.getTarget();
    SimpleCalendarModel m = (SimpleCalendarModel) cal.getModel();
    SimpleCalendarEvent sce = (SimpleCalendarEvent) event.getCalendarEvent();
    int index = m.indexOf(sce);

    eventMap = (HashMap)Sessions.getCurrent().getAttribute("eventMap");
    int eventid = Integer.parseInt(eventMap.get(index).toString());
    String uri = "e_event.jsp?eventid="+eventid;

        java.net.URLEncoder.encode(uri, "UTF-8");
        Executions.getCurrent().sendRedirect(uri, "_parent");
        } catch (UnsupportedEncodingException e) {

            e.printStackTrace();
        }
    }

@Listen("onEventUpdate = #calendars")
public void updateEvent(CalendarsEvent event) {
    System.out.println("onEventUpdate");
    CalendarEvents data = (CalendarEvents) event.getCalendarEvent();
    data.setBeginDate(event.getBeginDate());
    data.setEndDate(event.getEndDate());
    calendarModel.update(data);
}

}

Please help me out.Any help would be highly appreciated. Regards, Aasif Iqbal

getting null on @Listen("onEventEdit = #calendars") event SelectorComposer<component> on clustered environment

Hello Everyone,

I have two tomcats deployed at my machine and using clustered environment for my application.I am using zk calendar at in my application.I am using SelectorComposer<component> for listing events and for Create/Edit of events I am calling my own custom jsp files.Everything works fine when application is deployed only on one tomcat but for clustering on clicking of edit of event I am getting an alert mentioning "null" only.It works fine for create event.I am unable to get the issue as it is displaying only "null" in alert.

My zul file looks like

<zk> <style src="/widgets/zk_calendar/zk_calendar/style.css"/> <window id="displayMyEntry">

<hlayout sclass="z-valign-middle"> <button id="today" label="${labels.Today}"/> <button id="prev" image="../img/arrow-180.png"/> <button id="next" image="../img/arrow.png"/> <separator width="50px"/> <button id="pageDay" label="${labels.Day}" width="55px"/> <button id="pageWeek" label="${labels.Week}" width="55px"/> <button id="pageMonth" label="${labels.Month}" width="55px"/> <separator width="50px"/> ${labels.Filter} : <textbox id="filter"/> <button id="applyFilter" label="${labels.Apply}"/> <button id="resetFilter" label="${labels.Reset}"/> </hlayout> <separator bar="true" height="20px"/>

        <calendars id="calendars" firstDayOfWeek="Sunday" height="600px" 
            mold="month">
            <toolbar sclass="calendar-toolbar">
                <div class="float-left">
                </div>
            </toolbar>
            </calendars>
    </div>

</window>

</zk>

Also my CalendarController.java is

public class CalendarController extends SelectorComposer<component> implements Serializable {

{
    private static final long serialVersionUID = 1L;
  DateFormat formatter;
  int key = 0;
  public HashMap eventMap = new HashMap();

HashMap();

@Wire
private Calendars calendars;
@Wire
private Textbox filter;

private CalendarModel calendarModel;

//the in editing calendar ui event
private CalendarsEvent calendarsEvent = null;

@Override
public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);
    calendarModel = new CalendarModel(new CalendarData().getCalendarEvents());
    calendars.setModel(this.calendarModel);
}


@Listen("onEventCreate = #calendars")
public void createEvent(CalendarsEvent event) {
    System.out.println("onEventCreate :::"+event.getName());
    formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");

    String stDate = "";
    String endDate = "";
    if (event != null)
    {
        stDate = formatter.format(event.getBeginDate());
        endDate = formatter.format(event.getEndDate());
    }
    String uri = "createEvent.jsp?startDate=" + stDate + "&endDate=" + endDate; 
    try {
        java.net.URLEncoder.encode(uri, "UTF-8");
    } catch (UnsupportedEncodingException e) {

        e.printStackTrace();
    }

    Executions.getCurrent().sendRedirect(uri, "_parent");
}

/* Unable to call this method when used in clustering*/
@Listen("onEventEdit = #calendars")
public void editEvent(CalendarsEvent event) {
        try {
    System.out.println("onEventEdit");      
    org.zkoss.calendar.Calendars cal = (org.zkoss.calendar.Calendars) event.getTarget();
    SimpleCalendarModel m = (SimpleCalendarModel) cal.getModel();
    SimpleCalendarEvent sce = (SimpleCalendarEvent) event.getCalendarEvent();
    int index = m.indexOf(sce);

    eventMap = (HashMap)Sessions.getCurrent().getAttribute("eventMap");
    int eventid = Integer.parseInt(eventMap.get(index).toString());
    String uri = "e_event.jsp?eventid="+eventid;

        java.net.URLEncoder.encode(uri, "UTF-8");
        Executions.getCurrent().sendRedirect(uri, "_parent");
        } catch (UnsupportedEncodingException e) {

            e.printStackTrace();
        }
    }

@Listen("onEventUpdate = #calendars")
public void updateEvent(CalendarsEvent event) {
    System.out.println("onEventUpdate");
    CalendarEvents data = (CalendarEvents) event.getCalendarEvent();
    data.setBeginDate(event.getBeginDate());
    data.setEndDate(event.getEndDate());
    calendarModel.update(data);
}

}

Please help me out.Any help would be highly appreciated. Regards, Aasif Iqbal

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More