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.internal.services;
16:
17: import org.apache.tapestry.TapestryConstants;
18: import org.apache.tapestry.ioc.internal.util.InternalUtils;
19:
20: /**
21: * It represents an invocation target for an action link.
22: */
23: public class ActionLinkTarget implements InvocationTarget {
24: private final String _eventType;
25:
26: private final String _pageName;
27:
28: private final String _componentNestedId;
29:
30: public ActionLinkTarget(String action, String pageName,
31: String componentNestedId) {
32: _eventType = action;
33: _pageName = pageName;
34: _componentNestedId = componentNestedId;
35:
36: }
37:
38: public String getPath() {
39: StringBuilder builder = new StringBuilder();
40:
41: builder.append(_pageName.toLowerCase());
42:
43: boolean hasComponentId = InternalUtils
44: .isNonBlank(_componentNestedId);
45:
46: if (hasComponentId) {
47:
48: builder.append(".");
49: // Already lower case by design.
50: builder.append(_componentNestedId);
51: }
52:
53: // If no nested component id, then must append the action; the ':' and the action become the
54: // delimiter between the page name and the event context.
55:
56: if (!hasComponentId
57: || !_eventType.equals(TapestryConstants.ACTION_EVENT)) {
58: builder.append(":");
59: builder.append(_eventType);
60: }
61:
62: return builder.toString();
63: }
64:
65: public String getEventType() {
66: return _eventType;
67: }
68:
69: public String getComponentNestedId() {
70: return _componentNestedId;
71: }
72:
73: public String getPageName() {
74: return _pageName;
75: }
76:
77: }
|