Package de.innovationgate.wgpublisher.webtml

Source Code of de.innovationgate.wgpublisher.webtml.Link

/*******************************************************************************
* Copyright 2009, 2010 Innovation Gate GmbH. All Rights Reserved.
*
* This file is part of the OpenWGA server platform.
*
* OpenWGA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition, a special exception is granted by the copyright holders
* of OpenWGA called "OpenWGA plugin exception". You should have received
* a copy of this exception along with OpenWGA in file COPYING.
* If not, see <http://www.openwga.com/gpl-plugin-exception>.
*
* OpenWGA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenWGA in file COPYING.
* If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package de.innovationgate.wgpublisher.webtml;

import java.io.UnsupportedEncodingException;

import de.innovationgate.webgate.api.WGAPIException;
import de.innovationgate.webgate.api.WGContent;
import de.innovationgate.wgpublisher.webtml.utils.TMLContext;
import de.innovationgate.wgpublisher.webtml.utils.TMLException;

public class Link extends Base {
 
  private String astext;
  private String layoutkey;
  private String mediakey;

  /**
   * @throws WGAPIException
   * @see Base#tmlEndTag()
   */
  public void tmlEndTag() throws TMLException, WGAPIException {

    try {
            TMLContext context = this.getTMLContext();
            WGContent content = context.content()
           
            // Build link body
            String contentURL = context.contenturl(this.getMedium(), this.getLayout());
            String imageBaseURL = context.contenturl(this.getMedium(), this.getLayout(), true);
            String linkBody = null;
            String moEventAttributes = "";
           
           
            linkBody = content.getTitle();
           
            String linkTarget = content.getLinkTarget();
            if (linkTarget != null && !linkTarget.equals("")) {
              linkTarget = "target=\"" + linkTarget + "\" ";
            }
            else {
              linkTarget = "";
            }


            String result = "<a href=\"" + getResponse().encodeURL(contentURL) + "\" " + linkTarget + moEventAttributes + this.getResultString() + ">" + linkBody + "</a>";
           
           
            this.setResult(result);
        }
        catch (UnsupportedEncodingException e) {
            addWarning("Cannot create link because of unsupported encoding: " + e.getMessage());
        }

  }

  /**
   * Gets the astext
   * @return Returns a String
   */
  public String getAstext() {
    return this.getTagAttributeValue("astext", this.astext, "false");
  }
  /**
   * Sets the astext
   * @param astext The astext to set
   */
  public void setAstext(String astext) {
    this.astext = astext;
  }

  /**
   * Gets the layoutkey
   * @return Returns a String
   */
  public String getLayout() {
    return this.getTagAttributeValue("layout", layoutkey, null);
  }
  /**
   * Sets the layoutkey
   * @param layoutkey The layoutkey to set
   */
  public void setLayout(String layoutkey) {
    this.layoutkey = layoutkey;
  }

  /**
   * Gets the mediakey
   * @return Returns a String
   */
  public String getMedium() {
    return this.getTagAttributeValue("medium", mediakey, (String) getStatus().getOption(OPTION_LINK_MEDIUM));
  }
  /**
   * Sets the mediakey
   * @param mediakey The mediakey to set
   */
  public void setMedium(String mediakey) {
    this.mediakey = mediakey;
  }

}
TOP

Related Classes of de.innovationgate.wgpublisher.webtml.Link

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.