Java Code Examples for com.opensymphony.xwork2.ActionSupport#getText()

The following examples show how to use com.opensymphony.xwork2.ActionSupport#getText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinkAttributeManager.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    String errorCode = attributeFieldError.getErrorCode();
    String messageKey = null;
    if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_PAGE)) {
        messageKey = "LinkAttribute.fieldError.linkToPage";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.VOID_PAGE)) {
        messageKey = "LinkAttribute.fieldError.linkToPage.voidPage";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_CONTENT)) {
        messageKey = "LinkAttribute.fieldError.linkToContent";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_PAGE_GROUPS)) {
        messageKey = "LinkAttribute.fieldError.linkToPage.wrongGroups";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS)) {
        messageKey = "LinkAttribute.fieldError.linkToContent.wrongGroups";
    }
    if (null != messageKey) {
        return action.getText(messageKey);
    } else {
        return super.getCustomAttributeErrorMessage(attributeFieldError, action);
    }
}
 
Example 2
Source File: HypertextAttributeManager.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    String errorCode = attributeFieldError.getErrorCode();
    String messageKey = null;
    if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_PAGE)) {
        messageKey = "HypertextAttribute.fieldError.linkToPage";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.VOID_PAGE)) {
        messageKey = "HypertextAttribute.fieldError.linkToPage.voidPage";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_CONTENT)) {
        messageKey = "HypertextAttribute.fieldError.linkToContent";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_PAGE_GROUPS)) {
        messageKey = "HypertextAttribute.fieldError.linkToPage.wrongGroups";
    } else if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_CONTENT_GROUPS)) {
        messageKey = "HypertextAttribute.fieldError.linkToContent.wrongGroups";
    }
    if (null != messageKey) {
        String[] args = {attributeFieldError.getTracer().getLang().getDescr()};
        return action.getText(messageKey, args);
    } else {
        return super.getCustomAttributeErrorMessage(attributeFieldError, action);
    }
}
 
Example 3
Source File: ContentActionHelperAspect.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void checkFriendlyCodes(IApsEntity entity, ActionSupport action) {
	if (null == entity) {
		_logger.error("Invocazione di scansione/salvataggio contenuto nullo");
		return;
	}
	AttributeInterface attribute = entity.getAttributeByRole(JpseoSystemConstants.ATTRIBUTE_ROLE_FRIENDLY_CODE);
	if (null != attribute && attribute instanceof ITextAttribute) {
		String contentId = entity.getId();
		String msgPrefix = action.getText("EntityAttribute.singleAttribute.errorMessage.prefix", new String[] { attribute.getName() });
		ITextAttribute textAttr = (ITextAttribute) attribute;
		if (attribute.isMultilingual()) {
			String attributeName = attribute.getName();
			Iterator<Lang> langs = this.getLangManager().getLangs().iterator();
			while (langs.hasNext()) {
				Lang currentLang = langs.next();
				this.checkFriendlyCode(textAttr.getTextForLang(currentLang.getCode()), currentLang, attributeName, msgPrefix, contentId, action);
			}
		} else {
			this.checkFriendlyCode(textAttr.getText(), null, attribute.getName(), msgPrefix, contentId, action);
		}
	}
}
 
Example 4
Source File: ContentActionHelperAspect.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void checkFriendlyCode(String text, Lang currentLang, String attributeName, String msgPrefix, String contentId, ActionSupport action) {
	String friendlyCode = FriendlyCodeGenerator.generateFriendlyCode(text);
	if (null != friendlyCode) {
		FriendlyCodeVO fcVO = this.getSeoMappingManager().getReference(friendlyCode);
		if (null != fcVO && (contentId==null || !contentId.equals(fcVO.getContentId()))) {
			String errorMsg = null;
			if (currentLang == null) {
				errorMsg = action.getText("jpseo.error.content.friendlyCode.alreadyInUse", new String[] { friendlyCode });
			} else {
				errorMsg = action.getText("jpseo.error.content.friendlyCodeForLang.alreadyInUse", new String[] { friendlyCode, currentLang.getDescr() });
			}
			String fcUtilizer = null;
			if (fcVO.getPageCode() != null) {
				fcUtilizer = action.getText("jpseo.error.content.friendlyCode.utilizer.page", new String[] { fcVO.getPageCode() });
			} else {
				fcUtilizer = action.getText("jpseo.error.content.friendlyCode.utilizer.content", new String[] { fcVO.getContentId() });
			}
			action.addFieldError(attributeName, msgPrefix + " " + errorMsg + " " + fcUtilizer);
		}
	}
}
 
Example 5
Source File: AbstractAttributeManager.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String getErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    try {
        String errorCode = attributeFieldError.getErrorCode();
        if (errorCode.equals(FieldError.MANDATORY)) {
            return action.getText(this.getRequiredAttributeMessage());
        } else if (errorCode.equals(AttributeFieldError.OGNL_VALIDATION)) {
            String message = attributeFieldError.getMessage();
            if (null != message && message.trim().length() > 0) {
                return message;
            }
            String label = null;
            String labelKey = attributeFieldError.getMessageKey();
            if (null != labelKey && labelKey.trim().length() > 0) {
                Lang currentLang = this.getLangManager().getDefaultLang();
                if (action instanceof BaseAction) {
                    currentLang = ((BaseAction) action).getCurrentLang();
                }
                label = this.getI18nManager().getLabel(labelKey, currentLang.getCode());
            }
            if (label != null) {
                return label;
            } else return this.getCustomAttributeErrorMessage(attributeFieldError, action);
        } else {
            return this.getCustomAttributeErrorMessage(attributeFieldError, action);
        }
    } catch (Throwable t) {
    	_logger.error("Error creating Error Message", t);
        throw new RuntimeException("Error creating Error Message", t);
    }
}
 
Example 6
Source File: TestCustomLocalizedTextProvider.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testExtractGlobalLabels_1() throws Throwable {
    ActionSupport action = this.executeList("admin", "en");
    String localLabel = action.getText("title.userManagement.searchUsers");
    assertNotNull(localLabel);
    assertEquals("Search for and choose more users", localLabel);
    String globalLabel = action.getText("licensing.type");
    assertNotNull(globalLabel);
    assertEquals("GNU/LGPL license, Version 2.1", globalLabel);
}
 
Example 7
Source File: TestCustomLocalizedTextProvider.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testExtractGlobalLabels_2() throws Throwable {
    ActionSupport action = this.executeList("admin", "it");
    String localLabel = action.getText("title.userManagement.searchUsers");
    assertNotNull(localLabel);
    assertEquals("Cerca e scegli altri utenti", localLabel);
    String globalLabel = action.getText("licensing.type");
    assertNotNull(globalLabel);
    assertEquals("Licenza GNU/LGPL Versione 2.1", globalLabel);
}
 
Example 8
Source File: ResourceAttributeManager.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    String errorCode = attributeFieldError.getErrorCode();
    String messageKey = null;
    if (errorCode.equals(ICmsAttributeErrorCodes.INVALID_RESOURCE_GROUPS)) {
        messageKey = "ResourceAttribute.fieldError.invalidGroup";
    }
    if (null != messageKey) {
        return action.getText(messageKey);
    } else {
        return super.getCustomAttributeErrorMessage(attributeFieldError, action);
    }
}
 
Example 9
Source File: AbstractAttributeManager.java    From entando-core with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Return a custom error message.
 * This method shouwld to be extended for custom attribute manager
 * @param attributeFieldError The field error 
 * @param action The current action
 * @return The message for the specific error code.
 */
protected String getCustomAttributeErrorMessage(AttributeFieldError attributeFieldError, ActionSupport action) {
    return action.getText(this.getInvalidAttributeMessage());
}