0

datebox - function for selection of timeframe

asked 2010-02-08 02:55:36 +0800

jhuber gravatar image jhuber
192 1 4

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 :)

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2010-02-09 01:20:33 +0800

jhuber gravatar image jhuber
192 1 4

Does anybody have an idea?
I just want to combine these 2 datebox.
Thus the start datebox is hinge on the end datebox.

link publish delete flag offensive edit

answered 2010-02-09 22:42:32 +0800

tmillsclare gravatar image tmillsclare
799 2 5 30

Hey,

Could you create a function which takes two dates and compares them, then call this on the DateBox's onChange event?

link publish delete flag offensive edit

answered 2010-02-10 02:39:48 +0800

jhuber gravatar image jhuber
192 1 4

could you please give me a sample code. I don't understand what you want to say to me.

link publish delete flag offensive edit

answered 2010-02-10 03:07:01 +0800

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

updated 2010-02-10 03:08:34 +0800

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 :-)

link publish delete flag offensive edit

answered 2010-02-10 04:46:16 +0800

jhuber gravatar image jhuber
192 1 4

Great :)

Thank you very much...

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-02-08 02:55:36 +0800

Seen: 407 times

Last updated: Feb 10 '10

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