public class LoadSurveyTag extends TagSupport {
public int doStartTag() throws JspException {
ISurveyManager surveyManager = (ISurveyManager) ApsWebApplicationUtils.getBean(SurveySystemConstants.SURVEY_MANAGER, pageContext);
ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER,pageContext);
IResourceManager resourceManager = (IResourceManager) ApsWebApplicationUtils.getBean(JacmsSystemConstants.RESOURCE_MANAGER, this.pageContext);
SurveyRecord survey = null;
try {
String defaultLang = langManager.getDefaultLang().getCode();
survey = surveyManager.loadSurvey(this.getSurveyId());
if (this._preferredLang == null) {
this._preferredLang = defaultLang;
}
this.pageContext.setAttribute(this.getCtxName(), survey);
// fetch image
if (null != this.getCtxImageUrl() && null != survey.getImageId()) {
ImageResource resource = (ImageResource) resourceManager.loadResource(survey.getImageId());
if (null != this.getImageDimension() && null != resource.getImagePath(this.getImageDimension())) {
this.pageContext.setAttribute(this.getCtxImageUrl(), resource.getImagePath(this.getImageDimension()));
} else {
this.pageContext.setAttribute(this.getCtxImageUrl(), resource.getImagePath("0"));
}