use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ListAttributeManager method updateAttribute.
@Override
protected void updateAttribute(AttributeInterface attribute, AttributeTracer tracer, HttpServletRequest request) {
List<Lang> langs = this.getLangManager().getLangs();
for (int i = 0; i < langs.size(); i++) {
Lang lang = langs.get(i);
List<AttributeInterface> attributeList = ((ListAttribute) attribute).getAttributeList(lang.getCode());
for (int j = 0; j < attributeList.size(); j++) {
AttributeInterface attributeElement = attributeList.get(j);
AttributeTracer elementTracer = (AttributeTracer) tracer.clone();
elementTracer.setListElement(true);
elementTracer.setListLang(lang);
elementTracer.setListIndex(j);
AbstractAttributeManager elementManager = (AbstractAttributeManager) this.getManager(attributeElement);
if (elementManager != null) {
elementManager.updateAttribute(attributeElement, elementTracer, request);
}
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TextAttributeManager method getCustomAttributeErrorMessage.
@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
AttributeInterface attribute = attributeFieldError.getAttribute();
TextAttributeValidationRules valRules = (TextAttributeValidationRules) attribute.getValidationRules();
if (null != valRules) {
ITextAttribute textAttribute = (ITextAttribute) attribute;
Lang lang = attributeFieldError.getTracer().getLang();
String langCode = (null != lang) ? lang.getCode() : null;
String text = textAttribute.getTextForLang(langCode);
String errorCode = attributeFieldError.getErrorCode();
if (errorCode.equals(FieldError.INVALID_MIN_LENGTH)) {
String[] args = { String.valueOf(text.length()), String.valueOf(valRules.getMinLength()), lang.getDescr() };
return action.getText("TextAttribute.fieldError.invalidMinLength", args);
} else if (errorCode.equals(FieldError.INVALID_MAX_LENGTH)) {
String[] args = { String.valueOf(text.length()), String.valueOf(valRules.getMaxLength()), lang.getDescr() };
return action.getText("TextAttribute.fieldError.invalidMaxLength", args);
} else if (errorCode.equals(FieldError.INVALID_FORMAT)) {
String[] args = { lang.getDescr() };
return action.getText("TextAttribute.fieldError.invalidInsertedText", args);
}
}
return action.getText(this.getInvalidAttributeMessage());
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class TracerFactoryTag method getBean.
@Override
public Component getBean(ValueStack valueStack, HttpServletRequest req, HttpServletResponse res) {
String langCode = this.getActualValue(this.getLang());
ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, req);
Lang lang = langManager.getLang(langCode);
TracerFactory tracerFactory = new TracerFactory(valueStack, lang);
valueStack.getContext().put(this.getVar(), tracerFactory.getAttributeTracer());
return tracerFactory;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class CategoryAction method checkTitles.
private void checkTitles(boolean checkErrors) {
Iterator<Lang> langsIter = this.getLangManager().getLangs().iterator();
while (langsIter.hasNext()) {
Lang lang = (Lang) langsIter.next();
String titleKey = "lang" + lang.getCode();
String title = this.getRequest().getParameter(titleKey);
if (null != title) {
this.getTitles().put(lang.getCode(), title.trim());
}
if (checkErrors) {
if (null == title || title.trim().length() == 0) {
String[] args = { lang.getDescr() };
this.addFieldError(titleKey, this.getText("error.category.insertTitle", args));
}
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class PageAction method updateTitles.
protected void updateTitles() {
Iterator<Lang> langsIter = this.getLangManager().getLangs().iterator();
while (langsIter.hasNext()) {
Lang lang = (Lang) langsIter.next();
String titleKey = "lang" + lang.getCode();
String title = this.getRequest().getParameter(titleKey);
if (null != title) {
this.getTitles().put(lang.getCode(), title.trim());
}
}
}
Aggregations