ActionTag.java :  » ERP-CRM-Financial » OpenXava-3.0 » org » openxava » web » taglib » Java Open Source

Java Open Source » ERP CRM Financial » OpenXava 3.0 
OpenXava 3.0 » org » openxava » web » taglib » ActionTag.java
package org.openxava.web.taglib;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

import org.apache.commons.logging.*;
import org.openxava.controller.meta.*;
import org.openxava.util.*;

/**
 * @author Javier Paniza
 */

public class ActionTag extends TagSupport {
  
  private static Log log = LogFactory.getLog(ActionTag.class);
  
  private IActionTag actionTag;
  private String action;
  private String argv;
  
  public int doStartTag() throws JspException {
    try {
      if (Is.emptyString(getAction())) {  
        return SKIP_BODY;
      }

      MetaAction metaAction = MetaControllers.getMetaAction(getAction());
      if (metaAction.hasImage()) actionTag = new ImageTag();   
      else if(XavaPreferences.getInstance().isButtonsForNoImageActions()) actionTag = new ButtonTag();  
      else actionTag = new LinkTag(); 
      actionTag.setPageContext(pageContext);
      actionTag.setAction(action);
      actionTag.setArgv(argv);
      return actionTag.doStartTag();      
    }
    catch (Exception ex) {
      log.error(ex.getMessage(), ex);
      throw new JspException(XavaResources.getString("action_tag_error", getAction()));
    }    
  }

  public int doAfterBody() throws JspException { 
    return actionTag==null?super.doAfterBody():actionTag.doAfterBody();          
  }

  public int doEndTag() throws JspException { 
    return actionTag==null?super.doEndTag():actionTag.doEndTag();
  }

  public String getAction() {
    return action;
  }

  public void setAction(String string) {
    action = string;
  }

  public String getArgv() {
    return argv;
  }

  public void setArgv(String string) {
    argv = string;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.