# Using Datebox with time

18691 1 10 129

Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4107172

By: kkurt

I want to use datebox with time, how can i do ? Thanks..

delete retag edit

## 15 Replies

18691 1 10 129

Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4108930

By: henrichen

Currently there is no "time" part for datebox. Please post to our Feature Request.
And we need a proper UI design for this time component. Any reference?

/henri

18691 1 10 129

Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4109158

By: taffit_

Just as reference:
The dojo toolkit has a timepicker, can be seen in action at http://dojotoolkit.org/ under See it in action -> Form Widgets -> CiviCrmDateTimePicker or Timepicker.
Other examples:
http://www.rainforestnet.com/datetimepicker.htm
As applet and also with intervalls:
http://www.java2s.com/Code/JavaScript/GUI-Components/FancyTimePicker.htm
http://www.softcomplex.com/products/tigra_calendar/demo1.html

Just some inspiration ;-)

taffit

18691 1 10 129

Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4109499

By: henrichen

Thanks for the info.

/henri

18691 1 10 129

Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4122513

By: siriusjava

I believe there already is a feature request to add a time to the calendar widget.

abrar
27

Has this feature been implemented yet? We are currently reviewing RIA frameworks and Time picking widgets is one of our requirement.

jj
638 3

Looks like it is in since version 3.0.
Look at ZUL JavaDoc: Timebox, Only tracks hour and minutes.

bob007
384 3 4

Hi JJ,

I need to use this feature too. Where did u see we can use a datebox with time (not a Datebox and a Timebox) ? I can't find it anywhere.

I need this because i want to data bind the date and the time with the same class attribute. Or else how can i do it ?

Thanks,
Steve

henrichen
3869 2

Steve,

There is no Datebox with time part in ZK yet. You have to use Datebox + Timebox solution. As for "bind the date and the time with the same class attribute.", you can write TypeConverter to 'extract' only the required part so they are combined automatically.

bob007
384 3 4

Hi Henri,

I tried your solution, it seem a great idea, but i think it can't work.

DateTimeConverter.java

import java.util.Date;
import org.zkoss.zkplus.databind.TypeConverter;
import org.zkoss.zul.Timebox;

public class DateTimeConverter implements TypeConverter {

public Object coerceToBean(java.lang.Object val, org.zkoss.zk.ui.Component comp) {
Date date = (Date) val;
Date newDate = ((Timebox) comp).getValue();

//just to see the value of val and comp
System.out.println("val :" + date);
System.out.println("comp val :" + newDate);

/*
date.setHours(newDate.getHours());
date.setMinutes(newDate.getMinutes());
return date;
*/

return null;
}

public Object coerceToUi(java.lang.Object val, org.zkoss.zk.ui.Component comp) {
return val;
}
}


<datebox value="@{person.birth}" />
<timebox value="@{person.birth, converter='DateTimeConverter'}" />

the printed value are :
val :Thu Jan 01 11:26:00 EST 1970
comp val :Thu Jan 01 11:26:00 EST 1970

So neither contain the previous value of the datebox (it was the current date), so then how can i combine the values of the Datebox and the Timebox ?

Thanks
Steve

henrichen
3869 2

Steve,

You are right. No way to get the original bean value in TypeConverter :(.

There is no direct way as what I can think then. You might need a transient variable to hold the <timebox>
value and then combine them later in onChange event listener of <timebox>.

[hide preview]