-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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());
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
Push!
Hi,
Can you test with the latest ZK 6.x version to see if the issue still remain?
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>
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
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.
Asked: 2012-10-31 13:35:10 +0800
Seen: 122 times
Last updated: Nov 14 '12