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.internal.services;
16:
17: import java.util.Collection;
18:
19: import org.apache.tapestry.Link;
20: import org.apache.tapestry.services.PersistentFieldChange;
21: import org.apache.tapestry.services.PersistentFieldStrategy;
22:
23: /**
24: * Implements simple client-persistent properties. Most of the logic is delegated to an instance of
25: * {@link ClientPersistentFieldStorage}. This division of layer allows this service to be a true
26: * singleton, and a listener to the {@link LinkFactory}, and allow per-request state to be isolated
27: * inside the other service.
28: */
29: public class ClientPersistentFieldStrategy implements
30: PersistentFieldStrategy, LinkFactoryListener {
31: private final ClientPersistentFieldStorage _storage;
32:
33: public ClientPersistentFieldStrategy(
34: ClientPersistentFieldStorage storage) {
35: _storage = storage;
36: }
37:
38: public Collection<PersistentFieldChange> gatherFieldChanges(
39: String pageName) {
40: return _storage.gatherFieldChanges(pageName);
41: }
42:
43: public void postChange(String pageName, String componentId,
44: String fieldName, Object newValue) {
45: _storage.postChange(pageName, componentId, fieldName, newValue);
46: }
47:
48: public void createdActionLink(Link link) {
49: _storage.updateLink(link);
50: }
51:
52: public void createdPageLink(Link link) {
53: _storage.updateLink(link);
54: }
55: }
|