0

ZK Calendar DateFormatter

asked 2010-09-15 08:52:29 +0800

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

Hi all,

by implementing a DateFormatter Class for the zk calendar, i need information about the getCaptionByPopup() method.
I can not assign it to a visible date in the calendar. Can somebody explain me for what this is used?

	
       @Override
	public String getCaptionByPopup(Date date, Locale locale, TimeZone timezone) {
		// TODO Auto-generated method stub
		return null;
	}

thanks
Stephan

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2010-09-20 01:46:00 +0800

PeterKuo gravatar image PeterKuo
481 2

According to:
http://docs.zkoss.org/wiki/ZK_Calendar

getCaptionByPopup() Returns the caption of the popup title

To use your own it is possible to utilize the function setDateFormatter() of the Calendar to change the implementation.

link publish delete flag offensive edit

answered 2010-09-20 05:01:36 +0800

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

Hmmmm,

yes, i have implemented a custom DateFormatter.

But there is nothing that pops up.
I can see that the getCaptionByPopup() method is triggered automatically for every day by going in the month mold.
And i don't see at any place a string that i hardcoded as a return value.
Further i'm missing the place where the title should appears.

thanks
Stephan

link publish delete flag offensive edit

answered 2010-09-30 22:52:34 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

updated 2010-09-30 22:59:00 +0800

Hi Stephan

I have created a sample

<zscript><![CDATA[
DateFormatter df = new SimpleDateFormatter(){
	public String getCaptionByPopup(Date date, Locale locale, TimeZone timezone) {
		SimpleDateFormat df = new SimpleDateFormat("EEE, MMM/d", locale);
		df.setTimeZone(timezone);
		return "my " + df.format(date);
	}
};

]]></zscript>

<calendars ...ignore.. dateFormatter="${df}">

You have to change to month view, and create event until "more" appear,
then click on "more", you will see the title of the popup has been changed


I can see that the getCaptionByPopup() method is triggered automatically for every day by going in the month mold.

It just send the all of text to client side, and reuse when the text be used
If you update the return value, you have to create a new instant of DateFormatter
due to

public void setDateFormatter(DateFormatter dfmater) {
		if (_dfmter != dfmater) {

maybe I can improve the part of process in further future.

link publish delete flag offensive edit

answered 2010-10-01 03:10:34 +0800

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

Many thanks Jimmy,

this explaination should be written in the calendar docs/wiki where the DateFormatter methods are explained.

thanks
Stephan

link publish delete flag offensive edit

answered 2011-07-28 12:30:33 +0800

ripoll gravatar image ripoll
9

Hi, All

I'm using the title variable

sce.setTitle(title);


to show same information and it is showed in day and week event.
but when I implement a dateFormatter in order to internalization the date format of the calendar like:

calendars.setDateFormatter(new DateFormatter() {

public String getCaptionByWeekOfYear(Date date, Locale locale, TimeZone timezone) {
SimpleDateFormat df = new SimpleDateFormat("w", locale);
df.setTimeZone(timezone);
return df.format(date);
}
public String getCaptionByTimeOfDay(Date date, Locale locale, TimeZone timezone) {
return "";
}
public String getCaptionByPopup(Date date, Locale locale, TimeZone timezone) {
SimpleDateFormat df = new SimpleDateFormat("EEE d MMM ", locale);
df.setTimeZone(timezone);
return df.format(date);
}
public String getCaptionByDayOfWeek(Date date, Locale locale, TimeZone timezone) {
SimpleDateFormat df = new SimpleDateFormat("EEE", locale);
df.setTimeZone(timezone);
return df.format(date);
}
public String getCaptionByDateOfMonth(Date date, Locale locale, TimeZone timezone) {
SimpleDateFormat df = new SimpleDateFormat("d MMM", locale);
df.setTimeZone(timezone);
return df.format(date);
}
public String getCaptionByDate(Date date, Locale locale, TimeZone timezone) {
SimpleDateFormat df = new SimpleDateFormat("EEE d MMM ", locale);
df.setTimeZone(timezone);
return df.format(date);
}

});

the title is not show any more.

is it a Bug, or there are same wrong in my code?

Thanks for your response.

Best Regards.

link publish delete flag offensive edit

answered 2011-07-28 14:09:44 +0800

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

updated 2011-07-28 14:10:21 +0800

 */
public class  DateFormatter extends SimpleDateFormatter implements DateFormatter, Serializable {

     . . .

	@Override
	public String getCaptionByDate(Date date, Locale locale, TimeZone timezone) {
           . . .

link publish delete flag offensive edit

answered 2011-09-05 05:11:35 +0800

ripoll gravatar image ripoll
9

Hi all
that's not work
I'd tried that option
and if a DateFormatter is implemented,
Date replaces the customizable Title set by sce.setTitle(title).

I think it is a bug. Could you check it?
Best Regards.

link publish delete flag offensive edit

answered 2011-09-15 03:19:24 +0800

ripoll gravatar image ripoll
9

Hi All
it is working now
thanks.
Best Regards.

link publish delete flag offensive edit

answered 2015-03-02 08:30:05 +0800

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

Hello ripoll

I have the same problem as described here

I am happy to see that you got it. Can you please explain me how did you resolved this ?

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2010-09-15 08:52:29 +0800

Seen: 804 times

Last updated: Mar 02 '15

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