01: // Copyright 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.util.List;
18:
19: import org.apache.tapestry.ComponentResources;
20: import org.apache.tapestry.SelectModel;
21: import org.apache.tapestry.ValueEncoder;
22: import org.apache.tapestry.annotations.Inject;
23: import org.apache.tapestry.annotations.Persist;
24: import org.apache.tapestry.integration.app1.data.ProgrammingLanguage;
25: import org.apache.tapestry.util.EnumSelectModel;
26: import org.apache.tapestry.util.EnumValueEncoder;
27:
28: public class PaletteDemo {
29: @Inject
30: private ComponentResources _resources;
31:
32: @Persist
33: private List<ProgrammingLanguage> _languages;
34:
35: @Persist
36: private boolean _reorder;
37:
38: public boolean isReorder() {
39: return _reorder;
40: }
41:
42: public void setReorder(boolean reorder) {
43: _reorder = reorder;
44: }
45:
46: public List<ProgrammingLanguage> getLanguages() {
47: return _languages;
48: }
49:
50: public void setLanguages(List<ProgrammingLanguage> selected) {
51: _languages = selected;
52: }
53:
54: public SelectModel getLanguageModel() {
55: return new EnumSelectModel(ProgrammingLanguage.class,
56: _resources.getMessages());
57: }
58:
59: @SuppressWarnings("unchecked")
60: public ValueEncoder getLanguageEncoder() {
61: return new EnumValueEncoder(ProgrammingLanguage.class);
62: }
63:
64: void onActionFromReset() {
65: _reorder = false;
66: _languages = null;
67: }
68: }
|