01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.tags.naming;
20:
21: import org.apache.beehive.netui.script.ExpressionEvaluationException;
22:
23: import javax.servlet.jsp.tagext.Tag;
24:
25: /**
26: * A {@link INameInterceptor} that is used to add a prefix handler onto a
27: * NetUI tag that is being written to the client. Occasionally, NetUI
28: * tags need to be pre-processed before passing the name and value
29: * to the {@link org.apache.beehive.netui.pageflow.ProcessPopulate} handler
30: * in order to update a bean property. This preprocessing is done by
31: * implementing a handler implementing the interface
32: * {@link org.apache.beehive.netui.pageflow.RequestParameterHandler}, registering
33: * this interface with the {@link org.apache.beehive.netui.pageflow.ProcessPopulate#registerPrefixHandler(String, org.apache.beehive.netui.pageflow.RequestParameterHandler)}
34: * method, and adding a prefix which references this RequestParameterHandler to the
35: * name of each paramter that should be handled by the implementation before
36: * updating the bean property.
37: */
38: public class PrefixNameInterceptor implements INameInterceptor {
39: private String tagKey;
40:
41: public PrefixNameInterceptor(String key) {
42: tagKey = key;
43: }
44:
45: protected PrefixNameInterceptor() {
46: super ();
47: }
48:
49: public String rewriteName(String name, Tag currentTag)
50: throws ExpressionEvaluationException {
51: return rewriteNameInternal(name, tagKey);
52: }
53:
54: protected String rewriteNameInternal(String name, String key)
55: throws ExpressionEvaluationException {
56: return org.apache.beehive.netui.pageflow.ProcessPopulate
57: .writeHandlerName(key, name);
58: }
59: }
|