Search in sources :

Example 31 with Lang

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);
            }
        }
    }
}
Also used : AttributeTracer(com.agiletec.aps.system.common.entity.model.AttributeTracer) Lang(com.agiletec.aps.system.services.lang.Lang) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) ListAttribute(com.agiletec.aps.system.common.entity.model.attribute.ListAttribute)

Example 32 with Lang

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());
}
Also used : ITextAttribute(com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute) Lang(com.agiletec.aps.system.services.lang.Lang) AttributeInterface(com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface) TextAttributeValidationRules(com.agiletec.aps.system.common.entity.model.attribute.util.TextAttributeValidationRules)

Example 33 with Lang

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;
}
Also used : ILangManager(com.agiletec.aps.system.services.lang.ILangManager) Lang(com.agiletec.aps.system.services.lang.Lang)

Example 34 with Lang

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));
            }
        }
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Example 35 with Lang

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());
        }
    }
}
Also used : Lang(com.agiletec.aps.system.services.lang.Lang)

Aggregations

Lang (com.agiletec.aps.system.services.lang.Lang)90 ArrayList (java.util.ArrayList)15 ApsProperties (com.agiletec.aps.util.ApsProperties)14 IPage (com.agiletec.aps.system.services.page.IPage)12 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)11 RequestContext (com.agiletec.aps.system.RequestContext)10 Widget (com.agiletec.aps.system.services.page.Widget)10 ILangManager (com.agiletec.aps.system.services.lang.ILangManager)8 AttributeTracer (com.agiletec.aps.system.common.entity.model.AttributeTracer)7 AttributeInterface (com.agiletec.aps.system.common.entity.model.attribute.AttributeInterface)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 HashMap (java.util.HashMap)6 ServletRequest (javax.servlet.ServletRequest)6 AttributeFieldError (com.agiletec.aps.system.common.entity.model.AttributeFieldError)4 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)4 IndexableAttributeInterface (com.agiletec.aps.system.common.searchengine.IndexableAttributeInterface)4 Category (com.agiletec.aps.system.services.category.Category)4 Properties (java.util.Properties)4 JspException (javax.servlet.jsp.JspException)4 StringField (org.apache.lucene.document.StringField)4