01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.integration.app1.pages;
16:
17: import java.sql.Date;
18: import java.text.DateFormat;
19: import java.text.Format;
20: import java.util.Calendar;
21: import java.util.GregorianCalendar;
22: import java.util.Locale;
23:
24: import org.apache.tapestry.annotations.Component;
25: import org.apache.tapestry.annotations.MixinClasses;
26: import org.apache.tapestry.annotations.Mixins;
27: import org.apache.tapestry.annotations.OnEvent;
28: import org.apache.tapestry.annotations.Persist;
29: import org.apache.tapestry.annotations.Retain;
30: import org.apache.tapestry.integration.app1.components.Output;
31: import org.apache.tapestry.integration.app1.mixins.Emphasis;
32:
33: public class InstanceMixin {
34: @SuppressWarnings("unused")
35: @Component(parameters={"value=date2","format=format","test=showEmphasis"})
36: @Mixins("Emphasis")
37: private Output _output2;
38:
39: @SuppressWarnings("unused")
40: @Component(parameters={"value=date3","format=format","test=showEmphasis"})
41: @MixinClasses(Emphasis.class)
42: private Output _output3;
43:
44: @Retain
45: private final Format _format = DateFormat.getDateInstance(
46: DateFormat.MEDIUM, Locale.US);
47:
48: @Retain
49: private final Date _date1 = newDate(99, Calendar.JUNE, 13);
50:
51: @Retain
52: private final Date _date2 = newDate(101, Calendar.JULY, 15);
53:
54: @Retain
55: private final Date _date3 = newDate(105, Calendar.DECEMBER, 4);
56:
57: @Persist
58: private boolean _showEmphasis;
59:
60: public Format getFormat() {
61: return _format;
62: }
63:
64: private static Date newDate(int yearSince1900, int month, int day) {
65: return new Date(new GregorianCalendar(1900 + yearSince1900,
66: month, day).getTimeInMillis());
67: }
68:
69: public Date getDate1() {
70: return _date1;
71: }
72:
73: public Date getDate2() {
74: return _date2;
75: }
76:
77: public Date getDate3() {
78: return _date3;
79: }
80:
81: public boolean getShowEmphasis() {
82: return _showEmphasis;
83: }
84:
85: @OnEvent(component="toggle")
86: void toggle() {
87: _showEmphasis = !_showEmphasis;
88: }
89: }
|