0

Edit event not working in Tomcat Clustering

asked 2015-04-22 13:49:15 +0800

Aasifi gravatar image Aasifi
15 3

Hi, I have an application deployed on two tomcats(clustered).I have zk version7.0.3 and using zk calendar in my application.Everything works fine except when I click on any event for editing is gives me alert message as "null" and nothing happens.I have some SOP's at my Cotrollor class but it seems that the listener is not getting called.

Same scenario works perfectly fine when application is running only on single tomcat. What could be the possible reason behind that? I have all my classes made to implement Serializable interface.Please help.I have already asked this question but nobody has replied yet.Any help highly appreciated.

my zul file is

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

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

        <calendars id="calendars" firstDayOfWeek="Sunday" height="600px" 
            timeZone="Main=GMT+0" mold="month"/>
    </div>

    <!-- Create/Update Event Popup -->
    <include src="widgets/zk_calendar/zk_calendar/calendar_editor.zul" />

    <!-- Server+Client Fusion - Mouse Scroll Handling -->
    <script type="text/javascript"
        src="js/lib/jquery.mousewheel.min.js" />
    <script type="text/javascript"
        src="widgets/zk_calendar/zk_calendar/scroll.js" />
</window>

</zk>

And my CalendarController 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);
}

//control the calendar position
@Listen("onClick = #today")
public void gotoToday(){
    TimeZone timeZone = calendars.getDefaultTimeZone();
    System.out.println("calendars.getDefaultTimeZone() :::"+calendars.getDefaultTimeZone());
    calendars.setCurrentDate(Calendar.getInstance(timeZone).getTime());
}
@Listen("onClick = #next")
public void gotoNext(){
    calendars.nextPage();
}
@Listen("onClick = #prev")
public void gotoPrev(){
    calendars.previousPage();
}

//control page display
@Listen("onClick = #pageDay")
public void changeToDay(){
    calendars.setMold("default");
    calendars.setDays(1);
}
@Listen("onClick = #pageWeek")
public void changeToWeek(){
    calendars.setMold("default");
    calendars.setDays(7);
}
@Listen("onClick = #pageMonth")
public void changeToYear(){
    calendars.setMold("month");
}

//control the filter
@Listen("onClick = #applyFilter")
public void applyFilter(){
    calendarModel.setFilterText(filter.getValue());
    calendars.setModel(calendarModel);
}
@Listen("onClick = #resetFilter")
public void resetFilter(){
    filter.setText("");
    calendarModel.setFilterText("");
    calendars.setModel(calendarModel);
}

//listen to the calendar-create and edit of a event data
@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 = "c_event.jsp?startDate=" + stDate + "&endDate=" + endDate; 
    try {
        java.net.URLEncoder.encode(uri, "UTF-8");
    } catch (UnsupportedEncodingException e) {

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

//listen to the edit of a event data
@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);
    System.out.println("event Map :: "+Sessions.getCurrent().getAttribute("eventMap"));
    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 to the calendar-update of event data, usually send when user drag the event data 
    @Listen("onEventUpdate = #calendars")
    public void updateEvent(CalendarsEvent event) {
        CalendarEvents data = (CalendarEvents) event.getCalendarEvent();
        data.setBeginDate(event.getBeginDate());
        data.setEndDate(event.getEndDate());
        calendarModel.update(data);
    }

}

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-04-26 23:46:06 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Aasifi,

As a reference please use the following url:

http://books.zkoss.org/wiki/SmallTalks/2007/April/HowtoRunZKonApache%2BTomcatclustering,Part_I

Furthermore the doc mentions that:

  1. All your session attributes must implement java.io.Serializable.
  2. Make sure your web.xml has the <distributable/> element

So could you check the second prerequisite?

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-04-27 08:34:38 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2015-04-27 08:38:30 +0800

Have you try this: implements SerializableEventListener

myComponent.addEventListener(Events.ON_CLICK, new OnEditEventListener<event>());

private final class OnEditEventListener implements SerializableEventListener
    {

        /**
         * serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onEvent(Event event) throws Exception {

        //your code here
        . . .
}
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-04-22 13:49:15 +0800

Seen: 24 times

Last updated: Apr 27 '15

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