Here is the DateInput component for t5: http://juanemaya.blogspot.com/2007/05/tapestry-5-date-input-component.html I am not sure if that's the best way to do it. I think that building the date in the year set is not the best way but well, i am learning slowly :)
Thanks a lot for ur help! On 5/29/07, Juan Maya <[EMAIL PROTECTED]> wrote:
Thanks Alexander! I have used your idea and i have component already working! :) I just need to add a validator and that's it. Hopefully i will have time to finish it tomorrow so i will post the code to show the t5 way (And it's quiet easy!:) On 5/29/07, Kolesnikov, Alexander GNI <[EMAIL PROTECTED]> wrote: > > Well, here is the code. If you need comments, the whole issue will be > published soon, hopefully on the next week. That will be #14, and there are > three other issues to be published before it: > > #11: DatePicker and Shell > #12: PropertySelection and IPropertySelectionModel > #13: Autocompleter and InlineEditBox > > Cheers, > > Alexander > > *** > > Template: > > <html> > <head> > <title>DateInput Template</title> > </head> > <body jwcid="$content$"> > <select jwcid="month"> > <option>January</option> > <option>February</option> > </select> > <select jwcid="day"> > <option>1</option> > <option>2</option> > </select>, > <select jwcid="year"> > <option>2005</option> > <option>2006</option> > </select> > </body> > </html> > > Specification: > > <?xml version="1.0 " encoding="UTF-8"?> > <!DOCTYPE component-specification PUBLIC > "-//Apache Software Foundation//Tapestry Specification 4.0//EN" > " http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> > > <component-specification > class="com.devshed.tapestry.celebrities.DateInput"> > > <description>Component for choosing a date</description> > > <component id="day" type="PropertySelection"> > <binding name="model" value="daysModel"/> > <binding name="value" value="day"/> > </component> > <component id="month" type="PropertySelection"> > <binding name="model" value="monthsModel"/> > <binding name="value" value="month"/> > </component> > <component id="year" type="PropertySelection"> > <binding name="model" value="yearsModel"/> > <binding name="value" value="year"/> > </component> > > </component-specification> > > Class: > > public abstract class DateInput extends BaseComponent implements > PageBeginRenderListener { > > @Parameter(required = true) > public abstract Date getDate(); > public abstract void setDate(Date d); > > private Calendar c = Calendar.getInstance(); > > public void pageBeginRender(PageEvent event) { > c.setTime(getDate() == null ? new Date() : getDate()); > } > > public IPropertySelectionModel getDaysModel() { > return new DayModel(); > } > > public IPropertySelectionModel getMonthsModel() { > return new LocalisedMonthsModel(getPage().getLocale()); > } > > public IPropertySelectionModel getYearsModel() { > return new YearModel(); > } > > public int getDay() { > return c.get(Calendar.DATE); > } > > public void setDay(int day) { > c.set(Calendar.DATE, day); > } > > public int getMonth() { > return c.get(Calendar.MONTH); > } > > public void setMonth(int month) { > c.set(Calendar.MONTH, month); > } > > public int getYear() { > return c.get(Calendar.YEAR); > } > > public void setYear(int year) { > c.set(Calendar.YEAR, year); > setDate(c.getTime()); > } > } > > Models: > > public class DayModel implements IPropertySelectionModel { > > public String getLabel(int index) { > return "" + (index + 1); > } > > public Object getOption(int index) { > return index + 1; > } > > public int getOptionCount() { > return 31; > } > > public String getValue(int index) { > return "" + index; > } > > public Object translateValue(String value) { > return Integer.parseInt(value) + 1; > } > } > > public class YearModel implements IPropertySelectionModel { > > private final static int START_YEAR = 1900; > private final static int END_YEAR = > new GregorianCalendar().get(Calendar.YEAR); > > public String getLabel(int index) { > return Integer.toString(index + START_YEAR); > } > > public Object getOption(int index) { > return index + START_YEAR; > } > > public int getOptionCount() { > return END_YEAR - START_YEAR + 1; > } > > public String getValue(int index) { > return "" + index; > } > > public Object translateValue(String value) { > return Integer.parseInt(value) + START_YEAR; > } > > } > > public class LocalisedMonthsModel implements IPropertySelectionModel { > > private String[] months; > > public LocalisedMonthsModel(Locale locale) { > DateFormatSymbols symbols = new DateFormatSymbols(locale); > months = symbols.getMonths(); > } > > public String getLabel(int index) { > return months[index]; > } > > public Object getOption(int index) { > return index; > } > > public int getOptionCount() { > return 12; > } > > public String getValue(int index) { > return "" + index; > } > > public Object translateValue(String value) { > return Integer.parseInt(value); > } > > } > > -----Original Message----- > From: Juan Maya [mailto: [EMAIL PROTECTED] > Sent: 25 May 2007 16:26 > To: Tapestry users > Subject: Re: t5: Date input component > > > So i will wait patiently :) > Thanks! > > On 5/25/07, Kolesnikov, Alexander GNI < [EMAIL PROTECTED]> > wrote: > > > > I don't know what will be needed in T5, but in T4 everything is plain > > and easy. Three PropertySelection components, three simple models for > > them and a trivial wire-up. You'll see it soon. > > > > -----Original Message----- > > From: Juan Maya [mailto:[EMAIL PROTECTED] > > Sent: 25 May 2007 16:01 > > To: Tapestry users > > Subject: Re: t5: Date input component > > > > > > My only concern with the Translators is that they only transalate "one > > value" and to translate the date i need 3 values (month, day, year) > > > > public Double parseClient(String clientValue, Messages messages) > > throws ValidationException > > > > so, is it possible to obtain the 3 values within the translator? > > > > > > On 5/25/07, Juan Maya < [EMAIL PROTECTED]> wrote: > > > > > > Thanks! > > > I think translators are way to go. I will try it and tell u how it > > > goes. > > > > > > > > > > > > On 5/25/07, 蝈蝈龙 <[EMAIL PROTECTED] > wrote: > > > > > > > > I want to give you a attachement size is not greater than 4k. But > > > > SMTP server always give me a error > > > > > > > > The following is the text > > > > > > > > I think if you would like to your html look like > > > > <select id="month"..../><select id="day"..../><select > > > > id="year"..../> It's right way to render 3 selectc component. > > > > > > > > If you just want to render a component ,the html should look like > > > > <select t:id="mydate" .......> > > > > > > > > Suppose my point is right, you have to know translator concept > > > > that is reponsible for the translation between the server-side and > > > > client -side 1. Here you first need to create a translator class > > > > implment the translation between Date and String > > > > see the attached file org/opend/bogo/translator/DateTranslator > > > > 2. create you own module for your application > > > > see the attached file org/opend/bogo/module/MyAppModule to > > > > register the translaor > > > > 3. Register the Module to let the module start when staring your > > > > application > > > > see the attached file MEAT-INF/MANIFEST.MF > > > > 4. Open the attached Page class name Login to see how the date be > > > > invoked > > > > > > > > > > > > > > > > 2007/5/25, 蝈蝈龙 < [EMAIL PROTECTED]>: > > > > > > > > > > I think if you would like to your html look like <select > > > > > id="month"..../><select id="day"..../><select id="year"..../> > > > > > It's right way to render 3 selectc component. > > > > > > > > > > If you just want to render a component ,the html should look > > > > > like <select t:id="mydate" .......> > > > > > > > > > > Suppose my point is right, you have to know translator concept > > > > > that is > > > > > > > > > reponsible for the translation between the server-side and > > > > > client > > > > -side > > > > > 1. Here you first need to create a translator class implment the > > > > > translation between Date and String > > > > > see the attached file > > > > > org/opend/bogo/translator/DateTranslator > > > > > 2. create you own module for your application > > > > > see the attached file org/opend/bogo/module/MyAppModule to > > > > > register > > > > the > > > > > translaor > > > > > 3. Register the Module to let the module start when staring your > > > > > application > > > > > see the attached file MEAT-INF/MANIFEST.MF > > > > > 4. Open the attached Page class name Login to see how the date > > > > > be > > > > invoked > > > > > > > > > > > > > > > 2007/5/25, Juan Maya < [EMAIL PROTECTED] >: > > > > > > > > > > > > Thank for u help, marcelo, but what i need it's something > > > > > > different The component i want would be use like this: > > > > > > > > > > > > <t:date value="date"/> > > > > > > > > > > > > and t:date has: > > > > > > <select id="month"..../><select id="day"..../><select > > > > id="year"..../> > > > > > > > > > > > > The component renders 3 selects with the day month and year. > > > > > > That's already done, what i don't know is how to create a new > > > > > > java.util.Date() > > > > inside > > > > > > my > > > > > > date component and transfer it as the value entered to my > > > > > > page. I > > > > could > > > > > > transfer to my page day, month and year and then build the > > > > > > entered > > > > Date > > > > > > but > > > > > > it's not a clean solution. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 5/25/07, Marcelo lotif <[EMAIL PROTECTED] > wrote: > > > > > > > > > > > > > > Juan, i have an simple component that maybe can help you. It > > > > > > dinamically > > > > > > > grabs information from the database and put into a > > > > PropertySelection. > > > > > > It's > > > > > > > quite simple, but you may have problems because it's not > > > > documented > > > > > > --and > > > > > > > i'ts in portuguese, but still is java syntax :-). For your > > > > > > information, I > > > > > > > followed an example that Warner Onstine put on his book > > > > > > > (Tapestry > > > > > > 101), > > > > > > > maybe taking a look on it you can get more useful > > > > > > > information. > > > > > > > > > > > > > > 2007/5/24, Juan Maya < [EMAIL PROTECTED]>: > > > > > > > > > > > > > > > > Does any body know the best way to implement this type of > > > > component? > > > > > > > > > > > > > > > > On 5/23/07, Juan Maya < [EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > > > > > > Hi all, > > > > > > > > > i have been trying to create a new Date component that > > > > > > > > > would > > > > help > > > > > > to > > > > > > > > enter > > > > > > > > > dates using 3 select components. It would be something > > > > > > > > > like > > > > this: > > > > > > > > > <select id="month"..../><select id="day"..../><select > > > > > > id="year"..../> > > > > > > > > > > > > > > > > > > However i don't know how to accomplish this. > > > > > > > > > I have seen that i can do it creating a > > > > ProcessSubmissionAction on > > > > > > my > > > > > > > > > component that would take the values of the select > > > > > > > > > components > > > > but > > > > > > i > > > > > > > want > > > > > > > > to > > > > > > > > > be sure that there isn't a cleaner way to do it. > > > > > > > > > > > > > > > > > > Thanks > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Best Regards, > > > > > > > -- > > > > > > > Atenciosamente, > > > > > > > Marcelo Lotif > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > -------- > > CONFIDENTIALITY NOTICE: If you have received this email in error, > please > > immediately notify the sender by e-mail at the address shown. This > email > > transmission may contain confidential information. This information > is > > intended only for the use of the individual(s) or entity to whom it is > > > intended even if addressed incorrectly. Please delete it from your > files if > > you are not the intended recipient. Thank you for your > > compliance. Copyright 2007 CIGNA > > > > ====================================================================== > > > ======== > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > ------------------------------------------------------------------------------ > > CONFIDENTIALITY NOTICE: If you have received this email in error, please > immediately notify the sender by e-mail at the address shown. This email > transmission may contain confidential information. This information is > intended only for the use of the individual(s) or entity to whom it is > intended even if addressed incorrectly. Please delete it from your files if > you are not the intended recipient. Thank you for your > compliance. Copyright 2007 CIGNA > > ============================================================================== > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >