0

Problem in setting custom title for Calender Event with own dateformatter

asked 2015-03-02 06:53:58 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

updated 2015-03-03 03:32:27 +0800

Hello.

For ZK Calender, I am using my own date formatter as describe here.

And also, i have customized title for each calender event. The problem is if i am not using the own date formatter, then title of the each calender event shown correctly.

But when i use my own calender event, the customized title (getTitle from class that implements CalenderEvent) does not shown and the value from the date formatter is showing.

I think ZK Using the method getCaptionByTimeOfDay both for the caption for the left side of the calender and each calender event. Actually it should affect the left side of the calender , not the title of the each calender event.

Is this bug ?

        calendarCtrl.setDateFormatter(new MyCalenderDateFormat());
    package com.product.webapp.appt;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import org.zkoss.calendar.api.DateFormatter;

public class MyCalenderDateFormat implements DateFormatter {

    private String _dayFormat = "EEE MM/d";
    private String _weekFormat = "EEE";
    private String _timeFormat = "hh:mm a";
    private String _ppFormat = "EEE, MMM/d";
    private SimpleDateFormat _df, _wf, _tf, _pf;

    public String getCaptionByDate(Date date, Locale locale, TimeZone timezone) {
        if (_df == null) {
            _df = new SimpleDateFormat(_dayFormat, locale);
        }
        _df.setTimeZone(timezone);

        return _df.format(date);
    }

    public String getCaptionByDateOfMonth(Date date, Locale locale,
            TimeZone timezone) {
        Calendar cal = Calendar.getInstance(timezone, locale);
        cal.setTime(date);
        if (cal.get(Calendar.DAY_OF_MONTH) == 1) {
            SimpleDateFormat sd = new SimpleDateFormat("MMM d", locale);
            sd.setTimeZone(timezone);
            return sd.format(date);
        }
        return Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
    }

    public String getCaptionByDayOfWeek(Date date, Locale locale,
            TimeZone timezone) {
        if (_wf == null) {
            _wf = new SimpleDateFormat(_weekFormat, locale);
        }
        _wf.setTimeZone(timezone);
        return _wf.format(date);
    }

    public String getCaptionByTimeOfDay(Date date, Locale locale,
            TimeZone timezone) {
        if (_tf == null) {
            _tf = new SimpleDateFormat(_timeFormat, locale);
        }
        _tf.setTimeZone(timezone);

        return _tf.format(date);
    }

    public String getCaptionByPopup(Date date, Locale locale, TimeZone timezone) {
        if (_pf == null) {
            _pf = new SimpleDateFormat(_ppFormat, locale);
        }
        _pf.setTimeZone(timezone);

        return _pf.format(date);
    }

    public String getCaptionByWeekOfYear(Date date, Locale locale,
            TimeZone timezone) {
        Calendar cal = Calendar.getInstance(timezone, locale);
        cal.setTime(date);
        return String.valueOf(cal.get(Calendar.WEEK_OF_YEAR));
    }
}

If i comment the own date formatter, You can see the title as shown in the picture.

image description

If i use the own dateformatter, then customized title gone and default title are shown as shown here

image description

There is another problem, if we timeslots="6", then both Title text and Content text are showing in the Title bar itself as shown here image description

delete flag offensive retag edit

Comments

Any help please ?

Senthilchettyin ( 2015-03-03 01:27:31 +0800 )edit

Same kind of Problem reported by someone in this post

Senthilchettyin ( 2015-03-03 02:39:51 +0800 )edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2015-03-03 09:39:44 +0800

vincentjian gravatar image vincentjian
2245 6

No, it is not a bug, if you didn't use custom dateformatter, it will use CalendarEvent's title directly, otherwise, it will use the custom dateformatter. You can append the title in getCaptionByTimeOfDay() API if you want.

Also, we will append content if this event is less than one hour because it may not have enough space to show content.

You can double check the source code

link publish delete flag offensive edit

Comments

Appending content to tittle is really confusing. Look at the picture, it looks the only partial title appears and then both title and content have the same text. It will be really confusing to the user.

Senthilchettyin ( 2015-03-03 09:49:47 +0800 )edit
0

answered 2015-03-03 09:47:01 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

updated 2015-03-03 09:52:43 +0800

Thanks vincent.

But if i append the caption along with time in getCaptionByTimeOfDay, it changes the left side time display of the calender. In my case, i am storing the title of each event in the database and that should be shown in the event title.

And also, as it comes from the DB, so i am not sure or dont know how to know take that value and append . I think only static value can be append in getCaptionByTimeOfDay, we cannot append the value from the each event. And also, it will change the left side also as shown here.

image description

public String getCaptionByTimeOfDay(Date date, Locale locale,
            TimeZone timezone) {
        if (_tf == null) {
            _tf = new SimpleDateFormat(_timeFormat, locale);
        }
        _tf.setTimeZone(timezone);

        return "Testing " + _tf.format(date);
    }
link publish delete flag offensive edit
0

answered 2015-03-03 10:56:28 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

I would recommend, do not do any logic on event title, let it it be come from event.getTitle whatever developer want to store it.

And also, getCaptionByTimeOfDay should affect only left side of the calender.

link publish delete flag offensive edit
0

answered 2015-03-04 12:23:33 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

Vincent, Do you want me to create as feature release request in issue track ?

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-03-02 06:53:58 +0800

Seen: 15 times

Last updated: Mar 04 '15

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