Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package pt.estgp.estgweb.web.tags;
import org.apache.log4j.Logger;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import pt.estgp.estgweb.domain.UserSessionImpl;
import pt.estgp.estgweb.domain.UserImpl;
import pt.estgp.estgweb.Globals;
public class IsInCourseUnitTag
extends BodyTagSupport
{
private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger =
1.5.0/docs/api/java/util/logging/Logger.html">Logger.
getLogger(IsInCourseUnitTag.
class);
private long courseUnitId
;
public long getCourseUnitId
()
{
return courseUnitId
;
}
public void setCourseUnitId
(long courseUnitId
)
{
this.
courseUnitId = courseUnitId
;
}
/**
*
* @return
* @throws javax.servlet.jsp.JspException
*/
public int doStartTag
() throws JspException
{
if (go
())
{
return EVAL_BODY_BUFFERED
;
}
else
return SKIP_BODY
;
}
public boolean go
()
{
UserSessionImpl userSession =
(UserSessionImpl
) pageContext.
getRequest().
getAttribute(Globals.
USER_SESSION_KEY);
return userSession
!=
null && userSession.
getUser() !=
null && ((UserImpl
)((userSession.
getUser()))).
isInCourseUnit(courseUnitId
);
}
public int doEndTag
() throws JspException
{
if (go
())
{
1.5.0/docs/api/java/lang/String.html">String toPage = bodyContent.
getString().
trim();
JspWriter writer = pageContext.
getOut();
try
{
writer.
write(toPage
);
}
catch (1.5.0/docs/api/java/lang/Exception.html">Exception e
)
{
logger.
error(e, e
);
throw new JspException
(e
);
}
}
// Continue processing this page
return EVAL_PAGE
;
}
}