001 /*
002 Licensed to the Apache Software Foundation (ASF) under one
003 or more contributor license agreements. See the NOTICE file
004 distributed with this work for additional information
005 regarding copyright ownership. The ASF licenses this file
006 to you under the Apache License, Version 2.0 (the
007 "License"); you may not use this file except in compliance
008 with the License. You may obtain a copy of the License at
009
010 http://www.apache.org/licenses/LICENSE-2.0
011
012 Unless required by applicable law or agreed to in writing,
013 software distributed under the License is distributed on an
014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 KIND, either express or implied. See the License for the
016 specific language governing permissions and limitations
017 under the License.
018 */
019 package org.apache.wiki.tags;
020
021 import org.apache.wiki.ui.TemplateManager;
022
023 /**
024 * Provides easy access to TemplateManager.addResourceRequest(). You may use
025 * any of the request types defined there.
026 *
027 * @see TemplateManager
028 */
029 public class RequestResourceTag extends WikiTagBase
030 {
031 private static final long serialVersionUID = 0L;
032
033 private String m_type;
034 private String m_resource;
035
036 /**
037 * {@inheritDoc}
038 */
039 @Override
040 public void initTag()
041 {
042 super.initTag();
043 m_type = m_resource = null;
044 }
045
046 /**
047 * {@inheritDoc}
048 */
049 @Override
050 public int doWikiStartTag() throws Exception
051 {
052 if( m_type != null && m_resource != null )
053 {
054 TemplateManager.addResourceRequest( m_wikiContext, m_type, m_resource );
055 }
056
057 return SKIP_BODY;
058 }
059
060 /**
061 * Returns the resource that is to be added.
062 *
063 * @return The resource name.
064 */
065 public String getResource()
066 {
067 return m_resource;
068 }
069
070 /**
071 * Sets the resource name to be added.
072 *
073 * @param r Resource identifier.
074 */
075 public void setResource(String r)
076 {
077 m_resource = r;
078 }
079
080 /**
081 * Get the resource type.
082 *
083 * @return The type of the resource.
084 */
085 public String getType()
086 {
087 return m_type;
088 }
089
090 /**
091 * Set the type of the resource to be included. For example, "script". Please
092 * see the TemplateManager class for more information about the different kinds
093 * of types you can use.
094 *
095 * @see TemplateManager
096 *
097 * @param type The type to be set.
098 */
099
100 public void setType(String type)
101 {
102 m_type = type;
103 }
104
105 }