KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jelly > tags > define > InvokeTag


1 /*
2  * Copyright 2002,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 package org.apache.commons.jelly.tags.define;
17
18 import org.apache.commons.jelly.JellyTagException;
19 import org.apache.commons.jelly.MissingAttributeException;
20 import org.apache.commons.jelly.Script;
21 import org.apache.commons.jelly.TagSupport;
22 import org.apache.commons.jelly.XMLOutput;
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25
26 /**
27  * The <invoke> tag will invoke a given Script instance.
28  * It can be used with the <script> tag which defines scripts
29  * as variables that can later be invoked by this <invoke> tag.
30  *
31  * @author <a HREF="mailto:jstrachan@apache.org">James Strachan</a>
32  * @version $Revision: 155420 $
33  */

34 public class InvokeTag extends TagSupport {
35
36     /** The Log to which logging calls will be made. */
37     private static final Log log = LogFactory.getLog(InvokeTag.class);
38
39     private Script script;
40
41
42     public InvokeTag() {
43     }
44
45     /**
46      * Sets the Script to be invoked by this tag, which typically has been previously
47      * defined by the use of the &lt;script&gt; tag.
48      */

49     public void setScript(Script script) {
50         this.script = script;
51     }
52
53     // Tag interface
54
//-------------------------------------------------------------------------
55
public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
56         if ( script == null ) {
57             throw new MissingAttributeException("script");
58         }
59         script.run(context, output);
60     }
61 }
62
Popular Tags