[Newbie] Add a yui calendar without a datetextfield
Hi *, i'm new to the group and hope to find some answers here :-). I checked the examples and i got the idea to add a simple rendered yui calendar instance to a webpage. I don't want to add a datetextfield and then click the button beside it. Is this possible? And if so how? Thanks for your time Cheers Per - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Newbie] Add a yui calendar without a datetextfield
i used to use the code below, but now i see eelco has removed AbstractCalendar :( so maybe he can tell us how we can accomplish it now package com.tbs.webapp.component; import java.util.Date; import java.util.Map; import org.apache.wicket.extensions.yui.calendar.AbstractCalendar; import org.apache.wicket.markup.html.IHeaderContributor; import org.apache.wicket.markup.html.IHeaderResponse; import org.apache.wicket.markup.html.link.ILinkListener; import org.apache.wicket.model.IModel; import org.joda.time.DateMidnight; public class Calendar extends AbstractCalendar implements ILinkListener, IHeaderContributor { public Calendar(String id) { super(id); } public Calendar(String id, IModel model) { super(id); setModel(model); } public final void onLinkClicked() { String arg = getRequest().getParameter(getJavascriptWidgetId()); String[] parts = arg.split(,); int year = Integer.parseInt(parts[0]); int month = Integer.parseInt(parts[1]); int day = Integer.parseInt(parts[2]); setModelObject(new DateMidnight(year, month, day).toDate()); onClick(); } @Override protected void appendToInit(String markupId, String javascriptId, String javascriptWidgetId, StringBuffer b) { super.appendToInit(markupId, javascriptId, javascriptWidgetId, b); b.append(getJavascriptWidgetId()); b.append(.selectEvent.subscribe(\n\tfunction(type,args,obj) {\n\t\twindow.location='); b.append(urlFor(ILinkListener.INTERFACE)); b.append().append(getJavascriptWidgetId()).append(='+args;\n); b.append(\t}\n\t,).append(getJavascriptWidgetId()).append(, true);); Date date = (Date) getModelObject(); b.append(getJavascriptWidgetId()); b.append(.setYear().append(1900 + date.getYear()); b.append();); b.append(getJavascriptWidgetId()); b.append(.setMonth().append(date.getMonth()); b.append();); } public void renderHead(IHeaderResponse response) { // TODO Auto-generated method stub } @Override protected void configureWidgetProperties(Map widgetProperties) { super.configureWidgetProperties(widgetProperties); Date date = (Date) getModelObject(); if (date != null) { widgetProperties.put(selected, (date.getMonth() + 1) + / + date.getDate() + / + (1900 + date.getYear())); } } protected void onClick() { } } -igor On 8/8/07, Per Newgro [EMAIL PROTECTED] wrote: Hi *, i'm new to the group and hope to find some answers here :-). I checked the examples and i got the idea to add a simple rendered yui calendar instance to a webpage. I don't want to add a datetextfield and then click the button beside it. Is this possible? And if so how? Thanks for your time Cheers Per - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Newbie] Add a yui calendar without a datetextfield
i was looking for AbstractCalendar too... hm, maybe we could use this as an opportunity to provide an all around YUI Calendar integration with features like a standalone calendar, multiple calendars, calendars that open when a specific event occurs (eg. focus of textfield or click on an image). this could also be a step in the direction of a wicket-yui project. eelco, wdyt? On 8/8/07, Igor Vaynberg [EMAIL PROTECTED] wrote: i used to use the code below, but now i see eelco has removed AbstractCalendar :( so maybe he can tell us how we can accomplish it now package com.tbs.webapp.component; import java.util.Date; import java.util.Map; import org.apache.wicket.extensions.yui.calendar.AbstractCalendar; import org.apache.wicket.markup.html.IHeaderContributor; import org.apache.wicket.markup.html.IHeaderResponse; import org.apache.wicket.markup.html.link.ILinkListener; import org.apache.wicket.model.IModel; import org.joda.time.DateMidnight; public class Calendar extends AbstractCalendar implements ILinkListener, IHeaderContributor { public Calendar(String id) { super(id); } public Calendar(String id, IModel model) { super(id); setModel(model); } public final void onLinkClicked() { String arg = getRequest().getParameter(getJavascriptWidgetId()); String[] parts = arg.split(,); int year = Integer.parseInt(parts[0]); int month = Integer.parseInt(parts[1]); int day = Integer.parseInt(parts[2]); setModelObject(new DateMidnight(year, month, day).toDate()); onClick(); } @Override protected void appendToInit(String markupId, String javascriptId, String javascriptWidgetId, StringBuffer b) { super.appendToInit(markupId, javascriptId, javascriptWidgetId, b); b.append(getJavascriptWidgetId()); b.append(.selectEvent.subscribe(\n\tfunction(type,args,obj) {\n\t\twindow.location='); b.append(urlFor(ILinkListener.INTERFACE)); b.append ().append(getJavascriptWidgetId()).append(='+args;\n); b.append(\t}\n\t,).append(getJavascriptWidgetId()).append(, true);); Date date = (Date) getModelObject(); b.append(getJavascriptWidgetId()); b.append(.setYear().append(1900 + date.getYear()); b.append();); b.append(getJavascriptWidgetId()); b.append(.setMonth().append(date.getMonth()); b.append();); } public void renderHead(IHeaderResponse response) { // TODO Auto-generated method stub } @Override protected void configureWidgetProperties(Map widgetProperties) { super.configureWidgetProperties(widgetProperties); Date date = (Date) getModelObject(); if (date != null) { widgetProperties.put(selected, (date.getMonth() + 1) + / + date.getDate() + / + (1900 + date.getYear())); } } protected void onClick() { } } -igor On 8/8/07, Per Newgro [EMAIL PROTECTED] wrote: Hi *, i'm new to the group and hope to find some answers here :-). I checked the examples and i got the idea to add a simple rendered yui calendar instance to a webpage. I don't want to add a datetextfield and then click the button beside it. Is this possible? And if so how? Thanks for your time Cheers Per - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Newbie] Add a yui calendar without a datetextfield
On 8/8/07, Igor Vaynberg [EMAIL PROTECTED] wrote: i used to use the code below, but now i see eelco has removed AbstractCalendar :( Sorry. I put it back. The problem is that it isn't maintained well, as all the effort so far has been around the date picker. And since the datepicker is a behavior, and AbstractCalendar a component there's a lot of code duplication. AbstractCalendar should be fixed for that sometime. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Newbie] Add a yui calendar without a datetextfield
On 8/8/07, Gerolf Seitz [EMAIL PROTECTED] wrote: i was looking for AbstractCalendar too... hm, maybe we could use this as an opportunity to provide an all around YUI Calendar integration with features like a standalone calendar, multiple calendars, calendars that open when a specific event occurs (eg. focus of textfield or click on an image). this could also be a step in the direction of a wicket-yui project. eelco, wdyt? Yeah, I'm all for that. It would be nice to have a calendar that works as both a popup and normal (I guess we can just create a component that uses the datepicker behavior internally but in an opened state without a close button, and that component itself could be a hidden field. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Newbie] Add a yui calendar without a datetextfield
can you not factor out the common thing into an abstract behavior and have abstractcalendar add that abstract behavior to itself and bridge config methods through itself? -igor On 8/8/07, Eelco Hillenius [EMAIL PROTECTED] wrote: On 8/8/07, Igor Vaynberg [EMAIL PROTECTED] wrote: i used to use the code below, but now i see eelco has removed AbstractCalendar :( Sorry. I put it back. The problem is that it isn't maintained well, as all the effort so far has been around the date picker. And since the datepicker is a behavior, and AbstractCalendar a component there's a lot of code duplication. AbstractCalendar should be fixed for that sometime. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [Newbie] Add a yui calendar without a datetextfield
On 8/8/07, Igor Vaynberg [EMAIL PROTECTED] wrote: can you not factor out the common thing into an abstract behavior and have abstractcalendar add that abstract behavior to itself and bridge config methods through itself? Possibly. Core of the matter is that we should get rid of the code duplication we have now, and update the normal calendar component so that it takes advantage of all the things we've been building into the datepicker recently. Eelco - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]