1 package net.sf.tacos.mixins;
2
3 import org.apache.tapestry.ComponentResources;
4 import org.apache.tapestry.MarkupWriter;
5 import org.apache.tapestry.PageRenderSupport;
6 import org.apache.tapestry.TapestryConstants;
7 import org.apache.tapestry.annotations.Environmental;
8 import org.apache.tapestry.annotations.IncludeJavaScriptLibrary;
9 import org.apache.tapestry.annotations.Parameter;
10 import org.apache.tapestry.ioc.Messages;
11 import org.apache.tapestry.ioc.annotations.Inject;
12
13
14
15
16
17
18
19
20
21
22
23
24 @IncludeJavaScriptLibrary({"${tapestry.scriptaculous}/prototype.js","${tacos.datejs}/date.js","${tacos}/tacos.js"})
25 public class DateJS {
26
27 @Parameter(defaultPrefix = TapestryConstants.LITERAL_BINDING_PREFIX, name="format")
28 private String format = "MM/dd/yy";
29
30 @Parameter(defaultPrefix = "message")
31 private String message;
32
33 @Environmental
34 private PageRenderSupport pageRenderSupport;
35
36 @Inject
37 private ComponentResources resources;
38
39 @Inject
40 private Messages messages;
41
42 void afterRender(MarkupWriter writer){
43 if(message==null){
44 message=messages.get("invalid");
45 }
46 pageRenderSupport.addScript("new Tacos.Date('%s','%s','%s')", resources.getId(),format,message);
47
48 }
49 }