use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class CategoriesTag method doStartTag.
@Override
public int doStartTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
ICategoryManager catManager = (ICategoryManager) ApsWebApplicationUtils.getBean(SystemConstants.CATEGORY_MANAGER, this.pageContext);
try {
List<SelectItem> categories = new ArrayList<SelectItem>();
Category root = (null != this.getRoot()) ? catManager.getCategory(this.getRoot()) : null;
if (null == root) {
root = catManager.getRoot();
}
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String langCode = currentLang.getCode();
String reqTitStyle = this.getTitleStyle();
List<String> allowedStyles = Arrays.asList(ALLOWED_TITLE_TYPES);
String titleStyle = (null != reqTitStyle && (allowedStyles.contains(reqTitStyle))) ? reqTitStyle : null;
this.addSmallCategory(categories, root, langCode, titleStyle, catManager);
this.pageContext.setAttribute(this.getVar(), categories);
} catch (Throwable t) {
_logger.error("Error starting tag", t);
throw new JspException("Error starting tag", t);
}
return super.doStartTag();
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class CurrentPageTag method doEndTag.
@Override
public int doEndTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
try {
IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
if (this.getParam() == null || this.getParam().equals(TITLE_INFO)) {
this.extractPageTitle(page, currentLang, reqCtx);
} else if (this.getParam().equals(CODE_INFO)) {
this.setValue(page.getCode());
} else if (this.getParam().equals(OWNER_INFO)) {
this.extractPageOwner(page, reqCtx);
} else if (this.getInfo().equals(CHILD_OF_INFO)) {
this.extractIsChildOfTarget(page);
} else if (this.getInfo().equals(HAS_CHILD)) {
boolean hasChild = (page.getChildrenCodes() != null && page.getChildrenCodes().length > 0);
this.setValue(new Boolean(hasChild).toString());
}
this.evalValue();
} catch (Throwable t) {
_logger.error("error in doStartTag", t);
// ApsSystemUtils.logThrowable(t, this, "doStartTag");
throw new JspException("Error during tag initialization ", t);
}
return EVAL_PAGE;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class I18nTag method doEndTag.
@Override
public int doEndTag() throws JspException {
RequestContext reqCtx = (RequestContext) this.pageContext.getRequest().getAttribute(RequestContext.REQCTX);
try {
Lang currentLang = null;
if (reqCtx != null) {
currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
} else {
ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
currentLang = langManager.getDefaultLang();
}
String label = this.extractLabel(currentLang);
if (this._varName != null) {
this.pageContext.setAttribute(this._varName, label);
} else {
if (this.getEscapeXml()) {
out(this.pageContext, this.getEscapeXml(), label);
} else {
this.pageContext.getOut().print(label);
}
}
} catch (Throwable t) {
_logger.error("Error during tag initialization", t);
throw new JspException("Error during tag initialization", t);
}
return super.doStartTag();
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class PageInfoTag method doEndTag.
@Override
public int doEndTag() throws JspException {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
try {
IPageManager pageManager = (IPageManager) ApsWebApplicationUtils.getBean(SystemConstants.PAGE_MANAGER, this.pageContext);
IPage page = pageManager.getOnlinePage(this.getPageCode());
if (null == page) {
_logger.error("Required info for null page : inserted code '{}'", this.getPageCode());
}
if (this.getInfo() == null || this.getInfo().equals(CODE_INFO)) {
this.setValue(page.getCode());
} else if (this.getInfo().equals(TITLE_INFO)) {
this.extractPageTitle(page, currentLang);
} else if (this.getInfo().equals(URL_INFO)) {
this.extractPageUrl(page, currentLang, reqCtx);
} else if (this.getInfo().equals(OWNER_INFO)) {
this.extractPageOwner(page, reqCtx);
} else if (this.getInfo().equals(CHILD_OF_INFO)) {
this.extractIsChildOfTarget(page);
} else if (this.getInfo().equals(HAS_CHILD)) {
boolean hasChild = (page.getChildrenCodes() != null && page.getChildrenCodes().length > 0);
this._value = new Boolean(hasChild).toString();
}
this.evalValue();
} catch (Throwable t) {
_logger.error("Error during tag initialization", t);
// ApsSystemUtils.logThrowable(t, this, "doStartTag");
throw new JspException("Error during tag initialization ", t);
}
this.release();
return EVAL_PAGE;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class NavigatorTarget method getTitle.
/**
* Restituisce il titolo della pagina nella lingua corrente. Nel caso il
* titolo nella lingua corrente sia assente, viene restituito il titolo
* nella lingua di default.
*
* @return Il titolo della pagina.
*/
public String getTitle() {
Lang lang = (Lang) this._reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String title = this.getPage().getTitle(lang.getCode());
if (title == null || title.trim().equals("")) {
ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this._reqCtx.getRequest());
title = this.getPage().getTitle(langManager.getDefaultLang().getCode());
}
if (title == null || title.trim().equals("")) {
title = this.getPage().getCode();
}
return title;
}
Aggregations