0

timebox BUG ?

asked 2012-10-31 13:35:10 +0800

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

updated 2012-10-31 13:47:42 +0800

Hi all,

ZK 5.0.11

i have a zul-file with annotated databinded datebox and timebox to the same bean property..

if i initialize the bean date property and call a binder.loadAll() there are different dates in it.

<hbox>
   <datebox id="dateb_Comment_Date" value="@{controller.comment.date}" constraint="no empty" disabled="true" width="110px" ></datebox>
   <timebox id="timeb_Comment_Time" value="@{controller.comment.date}" constraint="no empty" disabled="true" width="110px" ></timebox>
</hbox>

.
		Comment comment = getXXXXXXXXXXXService().getNewComment(tenant.getId(), objType);
		comment.setDate(new java.util.Date());

		// Refresh the binding mechanism
                . . .
		getCommentDetailCtrl().getBinder().loadAll();

                // For Console Output
		java.util.Date dt = getCommentDetailCtrl().dateb_Comment_Date.getValue();
		System.out.println("### datebox ###" + dt.toString());
		java.util.Date dt2 = getCommentDetailCtrl().timeb_Comment_Time.getValue();
		System.out.println("#### timebox ######" + dt2.toString());


### datebox ###Wed Oct 31 00:00:00 CET 2012
#### timebox ######Thu Jan 01 14:25:30 CET 1970

The problem is that the timebox resets the datebox to '01.01.1970'.
This occurs NOT if i change some of the timebox (hh:mm:ss) value in the view, than it's the same date.

any hint on this?

thanks
Stephan

after binder.loadAll()

after binder.saveAll() and saving

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2012-11-01 18:12:23 +0800

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

Push!

link publish delete flag offensive edit

answered 2012-11-02 04:01:21 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

Can you test with the latest ZK 6.x version to see if the issue still remain?

link publish delete flag offensive edit

answered 2012-11-02 10:48:31 +0800

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

updated 2012-11-02 11:15:30 +0800

Tested with 6.0.2 and 6.5.0 and 5.0.11

Seems the date part from the setted DateTime is not init correct by the timebox component.

ZK 6.0.2 / ### TimeboxBugCtrl()
### doAfterCompose
### onClickBtnInit | values are shown after binder.loadAll()
### datebox ###Fri Nov 02 00:00:00 CET 2012
### timebox ###Thu Jan 01 11:34:46 CET 1970
### btnShowComponentValue | values are shown binder.saveAll()
### datebox ###Fri Nov 02 00:00:00 CET 2012
### timebox ###Thu Jan 01 11:34:46 CET 1970
### onChange$timeboxTest | values are shown binder.saveAll()
### datebox ###Thu Jan 01 00:00:00 CET 1970
### timebox ###Fri Nov 02 11:34:47 CET 2012

ZK 6.5.0 / ### TimeboxBugCtrl()
### doAfterCompose
### onClickBtnInit | values are shown after binder.loadAll()
### datebox ###Fri Nov 02 00:00:00 CET 2012
### timebox ###Thu Jan 01 11:31:49 CET 1970

### btnShowComponentValue | values are shown binder.saveAll()
### datebox ###Fri Nov 02 00:00:00 CET 2012
### timebox ###Thu Jan 01 11:31:49 CET 1970

### onChange$timeboxTest | values are shown binder.saveAll()
### datebox ###Thu Jan 01 00:00:00 CET 1970
### timebox ###Fri Nov 02 11:31:50 CET 2012


zul

<?xml version="1.0" encoding="UTF-8"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="./windowTimeboxBug" ?>

<zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.zkoss.org/2005/zul
	http://www.zkoss.org/2005/zul/zul.xsd">

	<window id="windowTimeboxBug" apply="de.forsthaus.webui.test.TimeboxBugCtrl" title="Timebox Bug?" border="none"
		closable="true" mode="modal" width="500px" height="400px">
		<div>
			<hbox>
				<datebox id="dateboxTest" value="@{controller.comment.date}" constraint="no empty" disabled="false"
					width="110px" ></datebox>
				<timebox id="timeboxTest" value="@{controller.comment.date}" constraint="no empty" disabled="false"
					width="110px" ></timebox>
				<button id="btnInit" label="init with current dateTime" ></button>
				<button id="btnShowComponentValue" label="show values" ></button>
			</hbox>
		</div>
	</window>
</zk>

.
ctrl
package de.forsthaus.webui.test;

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zkplus.databind.AnnotateDataBinder;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Timebox;
import org.zkoss.zul.Window;

@SuppressWarnings("serial")
public class TimeboxBugCtrl extends GenericForwardComposer<Window> {

	protected Window windowTimeboxBug; // autowired
	protected Datebox dateboxTest; // autowired
	protected Timebox timeboxTest; // autowired

	// Databinding
	protected AnnotateDataBinder binder;
	private Comment comment;

	public TimeboxBugCtrl() {
		System.out.println("ZK " + this.getPage().getDesktop().getWebApp().getVersion() + " / ### TimeboxBugCtrl()");
	}

	@Override
	public void doAfterCompose(Window comp) {
		try {
			super.doAfterCompose((Window) comp);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("### doAfterCompose");
		self.setAttribute("controller", this, false);

		/**
		 * Get the data binder.
		 */
		binder = (AnnotateDataBinder) this.getPage().getAttribute("binder", true);

	}

	public void onClick$btnInit(Event event) {
		System.out.println("### onClickBtnInit | values are shown after binder.loadAll()");

		Comment comment = new Comment();
		comment.setDate(new java.util.Date());
		setComment(comment);

		binder.loadAll();

		System.out.println("### datebox ###" + dateboxTest.getValue());
		System.out.println("### timebox ###" + timeboxTest.getValue());
	}

	public void onClick$btnShowComponentValue(Event event) {
		System.out.println("### btnShowComponentValue | values are shown binder.saveAll()");

		binder.saveAll();

		System.out.println("### datebox ###" + dateboxTest.getValue());
		System.out.println("### timebox ###" + timeboxTest.getValue());
	}

	public void onChange$timeboxTest(Event event) {
		System.out.println("### onChange$timeboxTest |  values are shown binder.saveAll()");

		binder.saveAll();

		System.out.println("### datebox ###" + dateboxTest.getValue());
		System.out.println("### timebox ###" + timeboxTest.getValue());
	}

	public void setComment(Comment comment) {
		this.comment = comment;
	}

	public Comment getComment() {
		return comment;
	}

	/**
	 * Internal domain model class.
	 */
	public class Comment {

		private java.util.Date date;

		public Comment() {
		}

		public void setDate(java.util.Date date) {
			this.date = date;
		}

		public java.util.Date getDate() {
			return date;
		}

	}
}

i helped me with the long format at time until it's fixed.

 <datebox id="dateb_Comment_Date" cols="12" format="long+medium"	 value="@{controller.comment.date}" constraint="no empty" disabled="true"  width="230px" ></datebox>

thanks
Stephan

link publish delete flag offensive edit

answered 2012-11-14 10:20:48 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

As the Javadoc said - An input box for holding a time (a java.util.Date Object) , but only Hour & Minute are used.
So the result is correct.

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: 2012-10-31 13:35:10 +0800

Seen: 122 times

Last updated: Nov 14 '12

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