KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > naming > PrefixNameInterceptor


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.tags.naming;
19
20 import org.apache.beehive.netui.script.ExpressionEvaluationException;
21
22 import javax.servlet.jsp.tagext.Tag JavaDoc;
23
24 /**
25  * A {@link INameInterceptor} that is used to add a prefix handler onto a
26  * NetUI tag that is being written to the client. Occasionally, NetUI
27  * tags need to be pre-processed before passing the name and value
28  * to the {@link org.apache.beehive.netui.pageflow.ProcessPopulate} handler
29  * in order to update a bean property. This preprocessing is done by
30  * implementing a handler implementing the interface
31  * {@link org.apache.beehive.netui.pageflow.RequestParameterHandler}, registering
32  * this interface with the {@link org.apache.beehive.netui.pageflow.ProcessPopulate#registerPrefixHandler(String, org.apache.beehive.netui.pageflow.RequestParameterHandler)}
33  * method, and adding a prefix which references this RequestParameterHandler to the
34  * name of each paramter that should be handled by the implementation before
35  * updating the bean property.
36  */

37 public class PrefixNameInterceptor implements INameInterceptor
38 {
39     private String JavaDoc tagKey;
40
41     public PrefixNameInterceptor(String JavaDoc key)
42     {
43         tagKey = key;
44     }
45
46     protected PrefixNameInterceptor()
47     {
48         super();
49     }
50
51     public String JavaDoc rewriteName(String JavaDoc name, Tag JavaDoc currentTag)
52             throws ExpressionEvaluationException
53     {
54         return rewriteNameInternal(name, tagKey);
55     }
56
57     protected String JavaDoc rewriteNameInternal(String JavaDoc name, String JavaDoc key)
58             throws ExpressionEvaluationException
59     {
60         return org.apache.beehive.netui.pageflow.ProcessPopulate.writeHandlerName(key, name);
61     }
62 }
63
Popular Tags