Package org.uned.agonzalo16.bitacora.web.tag

Source Code of org.uned.agonzalo16.bitacora.web.tag.MessagesNotReadTag

package org.uned.agonzalo16.bitacora.web.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.uned.agonzalo16.bitacora.dao.MessageDao;
import org.uned.agonzalo16.bitacora.dao.UserDao;
import org.uned.agonzalo16.bitacora.domain.User;
import org.uned.agonzalo16.bitacora.service.security.AuthenticatedUser;
import org.uned.agonzalo16.bitacora.service.security.AuthenticationProvider;

@Configurable
@SuppressWarnings("serial")
public class MessagesNotReadTag extends TagSupport {

  private String var;

  @Autowired
  private transient UserDao userDao;

  @Autowired
  private transient AuthenticationProvider authenticationProvider;

  @Autowired
  private transient MessageDao messageDao;

  public void setVar(String var) {
    this.var = var;
  }

  @Override
  public int doStartTag() throws JspException {

    AuthenticatedUser principal = authenticationProvider.getCurrentUserDetails();
    User user = userDao.get(principal.getId());

    pageContext.setAttribute(var, messageDao.findNotReadByDestination(user));
    return SKIP_BODY;
  }
}
TOP

Related Classes of org.uned.agonzalo16.bitacora.web.tag.MessagesNotReadTag

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.