本文整理汇总了Java中org.kuali.rice.krad.service.KRADServiceLocatorWeb.getMessageService方法的典型用法代码示例。如果您正苦于以下问题:Java KRADServiceLocatorWeb.getMessageService方法的具体用法?Java KRADServiceLocatorWeb.getMessageService怎么用?Java KRADServiceLocatorWeb.getMessageService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.service.KRADServiceLocatorWeb
的用法示例。
在下文中一共展示了KRADServiceLocatorWeb.getMessageService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateValidatorMessagesOption
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* Generates the js object used to override all default messages for validator jquery plugin
* with custom messages retrieved from the message service
*
* @return script for message override
*/
public static String generateValidatorMessagesOption() {
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
String mOption = "";
String keyValuePairs = "";
for (ValidationMessageKeys element : EnumSet.allOf(ValidationMessageKeys.class)) {
String key = element.toString();
String message = messageService.getMessageText(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + key);
if (StringUtils.isNotEmpty(message)) {
message = MessageStructureUtils.translateStringMessage(message);
keyValuePairs = keyValuePairs + "\n" + key + ": '" + message + "',";
}
}
keyValuePairs = StringUtils.removeEnd(keyValuePairs, ",");
if (StringUtils.isNotEmpty(keyValuePairs)) {
mOption = "{" + keyValuePairs + "}";
}
return mOption;
}
示例2: getValidationMessageParams
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidDataPatternConstraint#getValidationMessageParams()
*/
@Override
public List<String> getValidationMessageParams() {
if (validationMessageParams == null) {
validationMessageParams = new ArrayList<String>();
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
if (allowNegative) {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positiveOrNegative"));
} else {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positive"));
}
}
return validationMessageParams;
}
示例3: getValidationMessageParams
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* This overridden method ...
*
* @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidDataPatternConstraint#getValidationMessageParams()
*/
@Override
public List<String> getValidationMessageParams() {
if (validationMessageParams == null) {
validationMessageParams = new ArrayList<String>();
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
if (allowNegative) {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positiveOrNegative"));
} else {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positiveOrZero"));
}
validationMessageParams.add(Integer.toString(precision));
validationMessageParams.add(Integer.toString(scale));
}
return validationMessageParams;
}
示例4: performFinalize
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* Special handling for lightbox links to add and onclick data attribute to be handled by a global handler
*/
@Override
public void performFinalize(Object model, LifecycleElement parent) {
super.performFinalize(model, parent);
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
if (openInDialog){
this.addDataAttribute(UifConstants.DataAttributes.ONCLICK, "e.preventDefault(); "
+ "openLinkInDialog(jQuery(this), \""
+ linkDialogId + "\");");
this.addDataAttribute(UifConstants.DataAttributes.ROLE, UifConstants.RoleTypes.ACTION);
}
// when icon only is set, add the icon class to the action
if (StringUtils.isNotBlank(iconClass) && (UifConstants.ICON_ONLY_PLACEMENT.equals(linkIconPlacement)
|| StringUtils.isBlank(linkText))) {
getCssClasses().add(iconClass);
// force icon only placement
linkIconPlacement = UifConstants.ICON_ONLY_PLACEMENT;
}
if (target.equals(UifConstants.HtmlAttributeValues.TARGET_BLANK)) {
String title = this.getTitle();
if (StringUtils.isNotBlank(title)) {
this.setTitle(title + " - " + messageService.getMessageText("accessibility.link.opensTab"));
}
else{
this.setTitle(messageService.getMessageText("accessibility.link.opensTab"));
}
}
}
示例5: getValidationMessageParams
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* This overridden method ...
*
* @see org.kuali.rice.krad.datadictionary.validation.constraint.ValidDataPatternConstraint#getValidationMessageParams()
*/
@Override
public List<String> getValidationMessageParams() {
if (validationMessageParams == null) {
validationMessageParams = new ArrayList<String>();
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
if (allowNegative && !onlyNegative) {
if (omitZero) {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positiveOrNegative"));
} else {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positiveOrNegativeOrZero"));
}
} else if (onlyNegative) {
if (omitZero) {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "negative"));
} else {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "negativeOrZero"));
}
} else {
if (omitZero) {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positive"));
} else {
validationMessageParams.add(messageService.getMessageText(
UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "positiveOrZero"));
}
}
}
return validationMessageParams;
}
示例6: setUp
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
messageService = KRADServiceLocatorWeb.getMessageService();
}
示例7: buildGrowlScript
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* Builds JS script that will invoke the show growl method to display a growl message when the
* page is rendered.
*
* <p>A growl call will be created for any explicit growl messages added to the message map.</p>
*
* @param growlMessagingEnabled indicates whether growls have been enabled, if not any growl messages are
* written as info messages
* @return JS script string for generated growl messages
*/
protected static String buildGrowlScript(boolean growlMessagingEnabled) {
StringBuilder growlScript = new StringBuilder();
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
MessageMap messageMap = GlobalVariables.getMessageMap();
for (GrowlMessage growl : messageMap.getGrowlMessages()) {
if (growlMessagingEnabled) {
String message = messageService.getMessageText(growl.getNamespaceCode(), growl.getComponentCode(),
growl.getMessageKey());
if (StringUtils.isBlank(message)) {
continue;
}
if (growl.getMessageParameters() != null) {
message = message.replace("'", "''");
message = MessageFormat.format(message, (Object[]) growl.getMessageParameters());
}
// escape single quotes in message or title since that will cause problem with plugin
message = message.replace("'", "\\'");
String title = growl.getTitle();
if (StringUtils.isNotBlank(growl.getTitleKey())) {
title = messageService.getMessageText(growl.getNamespaceCode(), growl.getComponentCode(),
growl.getTitleKey());
}
title = title.replace("'", "\\'");
growlScript.append(ScriptUtils.buildFunctionCall(UifConstants.JsFunctions.SHOW_GROWL, message, title,
growl.getTheme()));
} else {
ErrorMessage infoMessage = new ErrorMessage(growl.getMessageKey(), growl.getMessageParameters());
infoMessage.setNamespaceCode(growl.getNamespaceCode());
infoMessage.setComponentCode(growl.getComponentCode());
messageMap.putInfoForSectionId(KRADConstants.GLOBAL_INFO, infoMessage);
}
}
return growlScript.toString();
}
示例8: processAuditErrors
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* Process any AuditErrors which exist in AuditClusters in the AuditErrorMap of GlobalVariables and add them
* to either errors or warnings for this component, matching on errorKey.
*
* @param masterKeyList the keys to look for
*/
private void processAuditErrors(List<String> masterKeyList) {
Map<String, AuditCluster> clusterMap = GlobalVariables.getAuditErrorMap();
for (AuditCluster auditCluster : clusterMap.values()) {
boolean isError = !(auditCluster.getCategory().equals(KRADConstants.Audit.AUDIT_WARNINGS));
List<AuditError> auditErrors = auditCluster.getAuditErrorList();
if (auditErrors == null) {
continue;
}
for (AuditError auditError: auditErrors) {
if (!masterKeyList.contains(auditError.getValidationKey())) {
continue;
}
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
// find message by key
String message = messageService.getMessageText(auditError.getMessageKey());
if (message == null) {
message = "Intended message with key: " + auditError.getErrorKey() + " not found.";
}
if (auditError.getParams() != null && StringUtils.isNotBlank(message)) {
message = message.replace("'", "''");
message = MessageFormat.format(message, auditError.getParams());
}
message = MessageStructureUtils.translateStringMessage(message);
if (isError) {
errors.add(message);
}
else {
warnings.add(message);
}
}
}
}
示例9: performFinalize
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* Populates the stepLabelClasses, accessibilityText, segmentSizes, and segmentClasses lists based on the settings
* of this StepProgressBar.
*
* {@inheritDoc}
*/
@Override
public void performFinalize(Object model, LifecycleElement parent) {
// If a percentageComplete value is set, use it to try to determine the current step, otherwise if currentStep
// is set just use that (null percentComplete value)
if (this.getPercentComplete() != null && currentStep == null) {
calculateCurrentStepFromPercentage();
} else if (currentStep != null) {
this.setPercentComplete(null);
}
super.performFinalize(model, parent);
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
// Initializing and checking for validity of values:
String cssDimension = CssConstants.WIDTH;
if (this.isVertical()) {
cssDimension = CssConstants.HEIGHT;
this.addStyleClass(CssConstants.ProgressBar.VERTICAL_STEP_PROGRESS_BAR);
}
int totalSteps = steps.size();
if (totalSteps == 0) {
throw new RuntimeException(
"At least one step is required for a StepProgressBar: " + this.getId() + " with parent: " + parent
.getId());
}
boolean explicitlySetPercentages = CollectionUtils.isNotEmpty(getSegmentPercentages());
boolean explicitlySetClasses = CollectionUtils.isNotEmpty(this.getSegmentClasses());
if (explicitlySetPercentages && explicitlySetClasses && this.getSegmentClasses().size() != this
.getSegmentPercentages().size()) {
throw new RuntimeException(
"If segmentPercentages are set on a StepProgressBar type, and segmentClasses are also "
+ "set, the lists MUST contain the same number of items");
}
// Populate the information used by the template based on settings of this StepProgressBar
populateProgressBarRenderingLists(totalSteps, cssDimension, explicitlySetPercentages, explicitlySetClasses);
// Explicitly set the vertical height for vertical cases where the verticalHeight is not set using
// verticalStepHeight
if (this.isVertical() && getVerticalHeight() == null) {
setVerticalHeight(getSegmentSizes().size() * verticalStepHeight);
}
// If the step is considered complete, set the aria attributes appropriately
if (currentStep != null && currentStep.equals(completeStep)) {
this.addAriaAttribute(UifConstants.AriaAttributes.VALUE_NOW, Integer.toString(steps.size()));
this.addAriaAttribute(UifConstants.AriaAttributes.VALUE_TEXT, messageService.getMessageText(
"accessibility.progressBar.complete"));
}
// Add aria attributes
this.addAriaAttribute(UifConstants.AriaAttributes.VALUE_MIN, "0");
this.addAriaAttribute(UifConstants.AriaAttributes.VALUE_MAX, Integer.toString(totalSteps));
}
示例10: buildGrowlScript
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String buildGrowlScript() {
View view = ViewLifecycle.getView();
String growlScript = "";
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
MessageMap messageMap = GlobalVariables.getMessageMap();
for (GrowlMessage growl : messageMap.getGrowlMessages()) {
if (view.isGrowlMessagingEnabled()) {
String message = messageService.getMessageText(growl.getNamespaceCode(), growl.getComponentCode(),
growl.getMessageKey());
if (StringUtils.isNotBlank(message)) {
if (growl.getMessageParameters() != null) {
message = message.replace("'", "''");
message = MessageFormat.format(message, (Object[]) growl.getMessageParameters());
}
// escape single quotes in message or title since that will cause problem with plugin
message = message.replace("'", "\\'");
String title = growl.getTitle();
if (StringUtils.isNotBlank(growl.getTitleKey())) {
title = messageService.getMessageText(growl.getNamespaceCode(), growl.getComponentCode(),
growl.getTitleKey());
}
title = title.replace("'", "\\'");
growlScript =
growlScript + "showGrowl('" + message + "', '" + title + "', '" + growl.getTheme() + "');";
}
} else {
ErrorMessage infoMessage = new ErrorMessage(growl.getMessageKey(), growl.getMessageParameters());
infoMessage.setNamespaceCode(growl.getNamespaceCode());
infoMessage.setComponentCode(growl.getComponentCode());
messageMap.putInfoForSectionId(KRADConstants.GLOBAL_INFO, infoMessage);
}
}
return growlScript;
}
示例11: getPrerequisiteStatement
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* Creates the script necessary for executing a prerequisite rule in which this field occurs
* after the field specified in the prerequisite rule - since it requires a specific set of UI
* logic. Builds an if statement containing an addMethod jquery validator call. Adds a
* "dependsOn" css class to this field for the field specified.
*
* @param constraint prerequisiteConstraint
* @param booleanStatement the booleanstatement in js - should return true when the validation
* rule should be applied
* @return statement derived from the constraint
*/
private static String getPrerequisiteStatement(InputField field, View view, PrerequisiteConstraint constraint,
String booleanStatement) {
methodKey++;
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
String message = "";
if (StringUtils.isEmpty(constraint.getMessageKey())) {
message = messageService.getMessageText(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "prerequisite");
message = MessageStructureUtils.translateStringMessage(message);
} else {
message = generateMessageText(constraint.getMessageNamespaceCode(),
constraint.getMessageComponentCode(), constraint.getMessageKey(),
constraint.getValidationMessageParams());
}
if (StringUtils.isEmpty(message)) {
message = "prerequisite - No message";
} else {
Field requiredField = (Field) view.getViewIndex().getDataFieldByPath(constraint.getPropertyName());
if (requiredField != null && StringUtils.isNotEmpty(requiredField.getLabel())) {
message = MessageFormat.format(message, requiredField.getLabel());
} else {
String genericFieldLabel = messageService.getMessageText(GENERIC_FIELD_MSG_KEY);
message = MessageFormat.format(message, genericFieldLabel);
}
}
// field occurs before case
String methodName = "prConstraint-"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ methodKey;
String addClass = "jQuery('[name=\""
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "\"]').addClass('"
+ methodName
+ "');\n";
String method = "\njQuery.validator.addMethod(\"" + methodName + "\", function(value, element) {\n" +
" if(" + booleanStatement + "){ return ((this.optional(element) !== false) || (coerceValue('" + ScriptUtils
.escapeName(constraint.getPropertyName()) + "')));}else{return true;} " +
"}, \"" + message + "\");";
String ifStatement = "if(occursBefore('"
+ ScriptUtils.escapeName(constraint.getPropertyName())
+ "','"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+
"')){"
+ addClass
+ method
+ "}";
return ifStatement;
}
示例12: getPostrequisiteStatement
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* This method creates the script necessary for executing a prerequisite rule in which this
* field occurs before the field specified in the prerequisite rule - since it requires a
* specific set of UI logic. Builds an if statement containing an addMethod jquery validator
* call.
*
* @param constraint prerequisiteConstraint
* @param booleanStatement the booleanstatement in js - should return true when the validation
* rule should be applied
* @return statement derived from the constraint
*/
private static String getPostrequisiteStatement(InputField field, PrerequisiteConstraint constraint,
String booleanStatement) {
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
// field occurs after case
String message = "";
if (StringUtils.isEmpty(constraint.getMessageKey())) {
message = messageService.getMessageText(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX + "postrequisite");
message = MessageStructureUtils.translateStringMessage(message);
} else {
message = generateMessageText(constraint.getMessageNamespaceCode(), constraint.getMessageComponentCode(),
constraint.getMessageKey(), constraint.getValidationMessageParams());
}
if (StringUtils.isEmpty(constraint.getMessageKey())) {
if (StringUtils.isNotEmpty(field.getLabel())) {
message = MessageFormat.format(message, field.getLabel());
} else {
String genericFieldLabel = messageService.getMessageText(GENERIC_FIELD_MSG_KEY);
message = MessageFormat.format(message, genericFieldLabel);
}
}
String function = "function(element){\n" +
"return (coerceValue('"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "') && "
+ booleanStatement
+ ");}";
String postStatement = "\nelse if(occursBefore('"
+ ScriptUtils.escapeName(field.getBindingInfo().getBindingPath())
+ "','"
+ ScriptUtils.escapeName(constraint.getPropertyName())
+
"')){\njQuery('[name=\""
+ ScriptUtils.escapeName(constraint.getPropertyName())
+
"\"]').rules(\"add\", { required: \n"
+ function
+ ", \nmessages: {\nrequired: \""
+ message
+ "\"}});}\n";
return postStatement;
}
示例13: getMessageText
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* Gets the message associated with ErrorMessage object passed in, using message service.
* The prefix and suffix will be appended to the retrieved message if processPrefixSuffix is true and if those
* settings are set on the ErrorMessage passed in.
*
* @param errorMessage the ErrorMessage object containing the message key(s)
* @param processPrefixSuffix if true appends the prefix and suffix to the message if they exist on ErrorMessage
* @return the converted/retrieved message
*/
public static String getMessageText(ErrorMessage errorMessage, boolean processPrefixSuffix) {
String message = "";
if (errorMessage != null && errorMessage.getErrorKey() != null) {
MessageService messageService = KRADServiceLocatorWeb.getMessageService();
// find message by key
message = messageService.getMessageText(errorMessage.getNamespaceCode(), errorMessage.getComponentCode(),
errorMessage.getErrorKey());
if (message == null) {
message = "Intended message with key: " + errorMessage.getErrorKey() + " not found.";
}
if (errorMessage.getMessageParameters() != null && StringUtils.isNotBlank(message)) {
message = message.replace("'", "''");
message = MessageFormat.format(message, (Object[]) errorMessage.getMessageParameters());
}
// add prefix
if (StringUtils.isNotBlank(errorMessage.getMessagePrefixKey()) && processPrefixSuffix) {
String prefix = messageService.getMessageText(errorMessage.getNamespaceCode(),
errorMessage.getComponentCode(), errorMessage.getMessagePrefixKey());
if (errorMessage.getMessagePrefixParameters() != null && StringUtils.isNotBlank(prefix)) {
prefix = prefix.replace("'", "''");
prefix = MessageFormat.format(prefix, (Object[]) errorMessage.getMessagePrefixParameters());
}
if (StringUtils.isNotBlank(prefix)) {
message = prefix + " " + message;
}
}
// add suffix
if (StringUtils.isNotBlank(errorMessage.getMessageSuffixKey()) && processPrefixSuffix) {
String suffix = messageService.getMessageText(errorMessage.getNamespaceCode(),
errorMessage.getComponentCode(), errorMessage.getMessageSuffixKey());
if (errorMessage.getMessageSuffixParameters() != null && StringUtils.isNotBlank(suffix)) {
suffix = suffix.replace("'", "''");
suffix = MessageFormat.format(suffix, (Object[]) errorMessage.getMessageSuffixParameters());
}
if (StringUtils.isNotBlank(suffix)) {
message = message + " " + suffix;
}
}
}
return message;
}
示例14: getMessageService
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
public MessageService getMessageService() {
return KRADServiceLocatorWeb.getMessageService();
}
示例15: getMessageService
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; //导入方法依赖的package包/类
/**
* Returns instance of the Message Service
*
* @return MessageService isntanc
*/
protected MessageService getMessageService() {
return KRADServiceLocatorWeb.getMessageService();
}