-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hey guys,
I'd like to have a function for 2 dateboxes, which are for a particular period of time.
These 2 datebox are for startdate and enddate.
My question is:
Is it possible to implement a function, that prefent a selection of the enddate which is before the statdate?
For example I choosed startedate: 23.1.2010. Then I want to have a function which only allows to select the
date starting from 23.1.2010. Is this possible?
Thanks for your replies :)
Hey,
Could you create a function which takes two dates and compares them, then call this on the DateBox's onChange event?
Hi Julianne,
i'm help me for such a case with folowing code:
/** * when the "search/filter" button is clicked. It searches over a period. <br> * Checks if EndDate not before StartDate.<br> * * @param event */ public void onClick$button_SecLoginlogList_bb_SearchDate(Event event) throws Exception { if (logger.isDebugEnabled()) { logger.debug("--> " + event.toString()); } if ((!(dbox_LoginLog_DateFrom.getValue() == null)) && (!(dbox_LoginLog_DateTo.getValue() == null))) { if (dbox_LoginLog_DateFrom.getValue().after(dbox_LoginLog_DateTo.getValue())) { MultiLineMessageBox.doSetTemplate(); MultiLineMessageBox.show(Labels.getLabel("message_EndDate_Before_BeginDate")); } else { Date dateFrom = dbox_LoginLog_DateFrom.getValue(); Date dateTo = dbox_LoginLog_DateTo.getValue(); Calendar calFrom = Calendar.getInstance(); calFrom.setTime(dateFrom); calFrom.set(Calendar.AM_PM, 0); calFrom.set(Calendar.HOUR, 0); calFrom.set(Calendar.MINUTE, 0); calFrom.set(Calendar.SECOND, 1); dateFrom = calFrom.getTime(); Calendar calTo = Calendar.getInstance(); calTo.setTime(dateTo); calTo.set(Calendar.AM_PM, 1); calTo.set(Calendar.HOUR, 11); calTo.set(Calendar.MINUTE, 59); calTo.set(Calendar.SECOND, 59); dateTo = calTo.getTime(); // ++ create the searchObject and init sorting ++// HibernateSearchObject<SecLoginlog> soSecLoginlog = new HibernateSearchObject<SecLoginlog>(SecLoginlog.class, getMaxRows()); // deeper loading of the relations to prevent the lazy // loading problem. soSecLoginlog.addFetch("ip2Country.sysCountryCode"); soSecLoginlog.addSort("lglLogtime", true); soSecLoginlog.addFilter(new Filter("lglLogtime", dateFrom, Filter.OP_GREATER_OR_EQUAL)); soSecLoginlog.addFilter(new Filter("lglLogtime", dateTo, Filter.OP_LESS_OR_EQUAL)); // Set the ListModel getPagedListWrapper().init(soSecLoginlog, listBoxSecUserlog, paging_SecUserLogList); checkbox_SecLoginlogList_ShowAll.setChecked(false); } } }
from: Zksample2: de.forsthaus.webui.logging.loginlog.SecLoginlogListCtrl.java
best
Stephan
PS: Yes, there are shorter ways instead of using Calendar :-)
Asked: 2010-02-08 02:55:36 +0800
Seen: 407 times
Last updated: Feb 10 '10