use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class ContentListViewerWidgetAction method validateLink.
protected void validateLink() {
String pageLink = this.getWidget().getConfig().getProperty(IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK);
boolean existsPageLink = pageLink != null && this.getPage(pageLink) != null;
String linkDescrParamPrefix = IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK_DESCR + "_";
if (existsPageLink || this.isMultilanguageParamValued(linkDescrParamPrefix)) {
if (!existsPageLink) {
this.addFieldError(IContentListWidgetHelper.WIDGET_PARAM_PAGE_LINK, this.getText("error.widget.listViewer.pageLink.required"));
}
Lang defaultLang = this.getLangManager().getDefaultLang();
String defaultLinkDescrParam = linkDescrParamPrefix + defaultLang.getCode();
String defaultLinkDescr = this.getWidget().getConfig().getProperty(defaultLinkDescrParam);
if (defaultLinkDescr == null || defaultLinkDescr.length() == 0) {
String[] args = { defaultLang.getDescr() };
this.addFieldError(defaultLinkDescrParam, this.getText("error.widget.listViewer.defaultLangLink.required", args));
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class PageAction method checkTitles.
protected void checkTitles() {
this.updateTitles();
Iterator<Lang> langsIter = this.getLangManager().getLangs().iterator();
while (langsIter.hasNext()) {
Lang lang = langsIter.next();
String title = (String) this.getTitles().get(lang.getCode());
if (null == title || title.trim().length() == 0) {
String[] args = { lang.getDescr() };
String titleKey = "lang" + lang.getCode();
this.addFieldError(titleKey, this.getText("error.page.insertTitle", args));
}
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class BaseAction method getTitle.
/**
* Return a title by current lang.
* @param defaultValue The default value returned in case there is no valid title in properties.
* @param titles The titles.
* @return The title.
*/
public String getTitle(String defaultValue, Properties titles) {
if (null == titles)
return defaultValue;
Lang currentLang = this.getCurrentLang();
String title = titles.getProperty(currentLang.getCode());
if (null == title) {
Lang defaultLang = this.getLangManager().getDefaultLang();
title = titles.getProperty(defaultLang.getCode());
}
if (null == title) {
title = defaultValue;
}
return title;
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class BaseAction method getCurrentLang.
/**
* Return the current system language used in the back-end interface. If this language does not
* belong to those known by the system the default language is returned. A log line will
* report the problem.
* @return The current language.
*/
public Lang getCurrentLang() {
Locale locale = this.getLocale();
String langCode = locale.getLanguage();
Lang currentLang = this.getLangManager().getLang(langCode);
if (null != currentLang) {
return currentLang;
} else {
_logger.info("Required Lang '{}' invalid", langCode);
return this.getLangManager().getDefaultLang();
}
}
use of com.agiletec.aps.system.services.lang.Lang in project entando-core by entando.
the class EntityAttributeConfigAction method fillAttributeFields.
/**
* Fill attribute fields.
*
* @param attribute The attribute to edit with the form values.
* @return A custom return code in the attribute neads a extra
* configuration, else null.
*/
@Override
protected String fillAttributeFields(AttributeInterface attribute) {
super.fillAttributeFields(attribute);
AttributeInterface nestedType = null;
if (attribute instanceof AbstractListAttribute) {
AbstractListAttribute listAttribute = (AbstractListAttribute) attribute;
if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT && listAttribute.getNestedAttributeTypeCode().equals(this.getListNestedType())) {
if (listAttribute instanceof ListAttribute) {
Lang defaultLang = this.getLangManager().getDefaultLang();
// Composite Element
nestedType = ((ListAttribute) listAttribute).addAttribute(defaultLang.getCode());
((ListAttribute) listAttribute).getAttributeList(defaultLang.getCode()).clear();
} else {
// Composite Element
nestedType = ((MonoListAttribute) listAttribute).addAttribute();
((MonoListAttribute) listAttribute).getAttributes().clear();
}
} else {
nestedType = this.getAttributePrototype(this.getListNestedType());
if (nestedType != null) {
nestedType.setName(this.getAttributeName());
} else {
_logger.info("******** List Type NULL!!!!");
}
}
listAttribute.setNestedAttributeType(nestedType);
nestedType.setName(attribute.getName());
}
if ((attribute instanceof CompositeAttribute) || (nestedType != null && nestedType instanceof CompositeAttribute)) {
CompositeAttribute composite = ((attribute instanceof CompositeAttribute) ? (CompositeAttribute) attribute : (CompositeAttribute) nestedType);
if (null != nestedType) {
this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ATTRIBUTE_ON_EDIT_SESSION_PARAM, (AbstractListAttribute) attribute);
}
this.getRequest().getSession().setAttribute(ICompositeAttributeConfigAction.COMPOSITE_ATTRIBUTE_ON_EDIT_SESSION_PARAM, composite);
return "configureCompositeAttribute";
}
if (nestedType != null) {
this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ATTRIBUTE_ON_EDIT_SESSION_PARAM, (AbstractListAttribute) attribute);
this.getRequest().getSession().setAttribute(IListElementAttributeConfigAction.LIST_ELEMENT_ON_EDIT_SESSION_PARAM, nestedType);
return "configureListElementAttribute";
}
return null;
}
Aggregations