package WEB-INF.classes.wenrgise.ejb.common.utility;

import java.util.logging.Logger;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
import wenrgise.common.utility.UserInfo;
import wenrgise.ejb.common.utility.ParamUtil;

public class EnrgiseDisplayUserTag extends BodyTagSupport {
  public static Logger log = Logger.getLogger("wenrgise.common.taglib.enrgise.EnrgiseDisplayUserTag");
  
  public int doStartTag() throws JspException {
    try {
      String sessionBeanName = ParamUtil.getSessionBeanName();
      UserInfo oUserInfo = (UserInfo)RequestUtils.lookup(this.pageContext, sessionBeanName, "userInfo", "session");
      if (null != oUserInfo) {
        String sEmp = RequestUtils.message(this.pageContext, null, "org.apache.struts.action.LOCALE", "wenrgise.common.user.name", null);
        StringBuffer sbOutString = new StringBuffer(sEmp);
        sbOutString.append(oUserInfo.getUserName());
        sbOutString.append("(");
        sbOutString.append(oUserInfo.getUserId());
        sbOutString.append(")");
        sbOutString.append(" ");
        String sSite = RequestUtils.message(this.pageContext, null, "org.apache.struts.action.LOCALE", "wenrgise.common.site.name", null);
        sbOutString.append(sSite);
        sbOutString.append(oUserInfo.getSiteName());
        sbOutString.append("(");
        sbOutString.append(oUserInfo.getSiteCode());
        sbOutString.append(")");
        ResponseUtils.write(this.pageContext, sbOutString.toString());
      } 
    } catch (Exception oEx) {
      log.info(oEx.getMessage());
    } 
    return 2;
  }
}
