Package de.odysseus.calyxo.base.taglib.html

Source Code of de.odysseus.calyxo.base.taglib.html.ATag

/*
* Copyright 2004, 2005, 2006 Odysseus Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.odysseus.calyxo.base.taglib.html;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import de.odysseus.calyxo.base.ModuleContext;
import de.odysseus.calyxo.base.ModuleSupport;

/**
* Anchor tag to be used within calyxo applications.
* Correctly expands a module-relative action path and optional module
* name into a container-relative URL.
* <p/>
* Use like
* <pre>
* <calyxo-base:a action="/home">Going home...</calyxo-base:a>
* <calyxo-base:a module="main" action="/index">Main index page</calyxo-base:a>
* </pre>
*
* @author Christoph Beck */
public class ATag extends BasicTag {
  private String charset; 
  private String type;
  private String name;
  private String hreflang;
  private String rel;
  private String rev;
  private String accesskey;
  private String shape;
  private String coords;
  private String tabindex;
  private String onfocus;
  private String onblur;
  private String target;

  private String module;
  private String action;

  /**
   * Default constructor.
   */
  public ATag() {
    super("a", true);
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.taglib.html.BasicTag#appendAttributes(java.lang.StringBuffer)
   */
  protected void appendAttributes(StringBuffer buffer) throws Exception {
    super.appendAttributes(buffer);

    append(buffer, "charset", getCharsetAttribute());
    append(buffer, "type", getTypeAttribute());
    append(buffer, "name", getNameAttribute());
    append(buffer, "href", getHrefAttribute());
    append(buffer, "hreflang", getHreflangAttribute());
    append(buffer, "rel", getRelAttribute());
    append(buffer, "rev", getRevAttribute());
    append(buffer, "accesskey", getAccesskeyAttribute());
    append(buffer, "shape", getShapeAttribute());
    append(buffer, "coords", getCoordsAttribute());
    append(buffer, "tabindex", getTabindexAttribute());
    append(buffer, "onfocus", getOnfocusAttribute());
    append(buffer, "onblur", getOnblurAttribute());
    append(buffer, "target", getTargetAttribute());
  }

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.taglib.html.BasicTag#reset()
   */
  protected void reset() {
    super.reset();

    charset = null;
    type = null;
    name = null;
    hreflang = null;
    rel = null;
    rev = null;
    accesskey = null;
    shape = null;
    coords = null;
    tabindex = null;
    onfocus = null;
    onblur = null;
    target = null;

    module = null;
    action = null;
  }
 
  /**
   * Get href attribute
   */
  protected String getHrefAttribute() throws Exception {
    HttpServletRequest request =
      (HttpServletRequest)pageContext.getRequest();
    ModuleSupport support = ModuleSupport.getInstance(request);
    ModuleContext context = null;
    if (module == null) {
      context = support.getModuleContext(request);
    } else {
      context = support.getModuleContext(module);
    }
    StringBuffer buffer = new StringBuffer();
    buffer.append(request.getContextPath());
    buffer.append(context.getPath(action));

    HttpServletResponse response =
      (HttpServletResponse)pageContext.getResponse();
    return response.encodeURL(buffer.toString());
  }

  /**
   * Get accesskey attribute
   */
  protected String getAccesskeyAttribute() throws Exception {
    return accesskey;
  }

  /**
   * Get coords attribute
   */
  protected String getCoordsAttribute() throws Exception {
    return coords;
  }

  /**
   * Get charset attribute
   */
  protected String getCharsetAttribute() throws Exception {
    return charset;
  }

  /**
   * Get hreflang attribute
   */
  protected String getHreflangAttribute() throws Exception {
    return hreflang;
  }

  /**
   * Get name attribute
   */
  protected String getNameAttribute() throws Exception {
    return name;
  }

  /**
   * Get onblur attribute
   */
  protected String getOnblurAttribute() throws Exception {
    return onblur;
  }

  /**
   * Get onfocus attribute
   */
  protected String getOnfocusAttribute() throws Exception {
    return onfocus;
  }

  /**
   * Get rel attribute
   */
  protected String getRelAttribute() throws Exception {
    return rel;
  }

  /**
   * Get rev attribute
   */
  protected String getRevAttribute() throws Exception {
    return rev;
  }

  /**
   * Get shape attribute
   */
  protected String getShapeAttribute() throws Exception {
    return shape;
  }

  /**
   * Get tabindex attribute
   */
  protected String getTabindexAttribute() throws Exception {
    return tabindex;
  }

  /**
   * Get target attribute
   */
  protected String getTargetAttribute() throws Exception {
    return target;
  }

  /**
   * Get type attribute
   */
  protected String getTypeAttribute() throws Exception {
    return type;
  }

  /**
   * Set accesskey property
   */
  public final void setAccesskey(String string) {
    accesskey = string;
  }

  /**
   * Set coords property
   */
  public final void setCoords(String string) {
    coords = string;
  }

  /**
   * Set charset property
   */
  public final void setCharset(String string) {
    charset = string;
  }

  /**
   * Set hreflang property
   */
  public final void setHreflang(String string) {
    hreflang = string;
  }

  /**
   * Set name property
   */
  public final void setName(String string) {
    name = string;
  }

  /**
   * Set onblur property
   */
  public final void setOnblur(String string) {
    onblur = string;
  }

  /**
   * Set onfocus property
   */
  public final void setOnfocus(String string) {
    onfocus = string;
  }

  /**
   * Set rel property
   */
  public final void setRel(String string) {
    rel = string;
  }

  /**
   * Set rev property
   */
  public final void setRev(String string) {
    rev = string;
  }

  /**
   * Set shape property
   */
  public final void setShape(String string) {
    shape = string;
  }

  /**
   * Set final tabindex property
   */
  public final void setTabindex(String string) {
    tabindex = string;
  }

  /**
   * Set type property
   */
  public final void setType(String string) {
    type = string;
  }

  /**
   * Set action property
   */
  public final void setAction(String string) {
    action = string;
  }

  /**
   * Set module property
   */
  public final void setModule(String string) {
    module = string;
  }

  /**
   * Set target attribute
   */
  public final void setTarget(String string) {
    target = string;
  }

  /**
   * Get accesskey property
   */
  public final String getAccesskey() {
    return accesskey;
  }

  /**
   * Get action property
   */
  public final String getAction() {
    return action;
  }

  /**
   * Get charset property
   */
  public final String getCharset() {
    return charset;
  }

  /**
   * Get coords property
   */
  public final String getCoords() {
    return coords;
  }

  /**
   * Get hreflang property
   */
  public final String getHreflang() {
    return hreflang;
  }

  /**
   * Get module property
   */
  public final String getModule() {
    return module;
  }

  /**
   * Get name property
   */
  public final String getName() {
    return name;
  }

  /**
   * Get onblur property
   */
  public final String getOnblur() {
    return onblur;
  }

  /**
   * Get onfocus property
   */
  public final String getOnfocus() {
    return onfocus;
  }

  /**
   * Get rel property
   */
  public final String getRel() {
    return rel;
  }

  /**
   * Get rev property
   */
  public final String getRev() {
    return rev;
  }

  /**
   * Get shape property
   */
  public final String getShape() {
    return shape;
  }

  /**
   * Get tabindex property
   */
  public final String getTabindex() {
    return tabindex;
  }

  /**
   * Get target property
   */
  public final String getTarget() {
    return target;
  }

  /**
   * Get type property
   */
  public final String getType() {
    return type;
  }

}
TOP

Related Classes of de.odysseus.calyxo.base.taglib.html.ATag

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.