View Javadoc

1   /*
2    * Copyright 2010 FatWire Corporation. All Rights Reserved.
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 com.fatwire.gst.foundation.taglib;
17  
18  import java.io.IOException;
19  import javax.servlet.jsp.JspException;
20  
21  import COM.FutureTense.Interfaces.ICS;
22  
23  import com.fatwire.gst.foundation.properties.AssetApiPropertyDao;
24  import com.fatwire.gst.foundation.properties.Property;
25  import com.fatwire.gst.foundation.properties.PropertyDao;
26  
27  /**
28   * extract the asset id from the asset property value
29   *
30   * @author Tony Field
31   * @since 11-09-02
32   */
33  public final class GetPropertyTag extends GsfSimpleTag {
34  
35      private String name;
36      private String property;
37  
38      /*
39       * (non-Javadoc)
40       *
41       * @see javax.servlet.jsp.tagext.SimpleTagSupport#doTag()
42       */
43      @Override
44      public void doTag() throws JspException, IOException {
45          final ICS ics = getICS();
46          PropertyDao propertyDao = AssetApiPropertyDao.getInstance(ics);
47          Property p = propertyDao.getProperty(property);
48          if (p != null) {
49              getJspContext().setAttribute(name, p.asString());
50          }
51          super.doTag();
52      }
53  
54      /**
55       * @param name the name to set
56       */
57      public void setName(final String name) {
58          this.name = name;
59      }
60  
61      /**
62       * @param property the property to set
63       */
64      public void setProperty(final String property) {
65          this.property = property;
66      }
67  }