本文整理匯總了Java中org.springframework.context.support.MessageSourceAccessor.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageSourceAccessor.getMessage方法的具體用法?Java MessageSourceAccessor.getMessage怎麽用?Java MessageSourceAccessor.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.support.MessageSourceAccessor
的用法示例。
在下文中一共展示了MessageSourceAccessor.getMessage方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSubmit
import org.springframework.context.support.MessageSourceAccessor; //導入方法依賴的package包/類
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
String view = getFormView();
if (Context.isAuthenticated()) {
String[] cdList = request.getParameterValues("conceptDatatypeId");
ConceptService cs = Context.getConceptService();
StringBuilder success = new StringBuilder("");
StringBuilder error = new StringBuilder();
MessageSourceAccessor msa = getMessageSourceAccessor();
String deleted = msa.getMessage("general.deleted");
String notDeleted = msa.getMessage("general.cannot.delete");
if (cdList.length != 0) {
log.warn("Deleting concept datatype is not supported");
if (!"".equals(error.toString())) {
error.append("<br/>");
}
error.append("ConceptDatatype").append(" ").append(notDeleted);
}
view = getSuccessView();
if (!"".equals(success.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString());
}
if (!"".equals(error.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString());
}
}
return new ModelAndView(new RedirectView(view));
}
示例2: onSubmit
import org.springframework.context.support.MessageSourceAccessor; //導入方法依賴的package包/類
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
Locale locale = Context.getLocale();
if (Context.isAuthenticated()) {
AlertService as = Context.getAlertService();
MessageSourceAccessor msa = getMessageSourceAccessor();
String msg = "";
// expire the selected alerts
String[] alertIds = request.getParameterValues("alertId");
if (alertIds != null) {
for (String alertIdString : alertIds) {
Integer alertId = Integer.parseInt(alertIdString);
Alert a = as.getAlert(alertId);
a.setDateToExpire(new Date());
as.saveAlert(a);
}
msg = msa.getMessage("Alert.expired", new Object[] { alertIds.length }, locale);
} else {
msg = msa.getMessage("Alert.select");
}
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, msg);
return new ModelAndView(new RedirectView(getSuccessView()));
}
// The user isn't authenticated or their session has expired
return showForm(request, response, errors);
}
示例3: PermissionDTO
import org.springframework.context.support.MessageSourceAccessor; //導入方法依賴的package包/類
public PermissionDTO(Permission permission, Group group, String roleName, Set<Permission> enabledSet, MessageSourceAccessor messageSourceAccessor) {
this.permission = permission;
this.groupUid = group.getUid();
this.forRole = roleName;
this.permissionName = permission.getName();
this.permissionLabel = messageSourceAccessor.getMessage("rest.permission." + permission.getName(), Locale.getDefault());
this.permissionDesc = messageSourceAccessor.getMessage("rest.permission.desc." + permission.getName(), Locale.getDefault());
this.permissionEnabled = enabledSet.contains(permission);
this.position = displayedPermissionsSorted.get(permission);
}
示例4: onSubmit
import org.springframework.context.support.MessageSourceAccessor; //導入方法依賴的package包/類
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
String view = getFormView();
if (Context.isAuthenticated()) {
String[] formList = request.getParameterValues("formId");
FormService fs = Context.getFormService();
//FormService rs = new TestFormService();
StringBuilder success = new StringBuilder("");
StringBuilder error = new StringBuilder("");
MessageSourceAccessor msa = getMessageSourceAccessor();
String deleted = msa.getMessage("general.deleted");
String notDeleted = msa.getMessage("general.cannot.delete");
String textForm = msa.getMessage("Form.form");
String noneDeleted = msa.getMessage("Form.nonedeleted");
if (formList != null) {
for (String p : formList) {
//TODO convenience method deleteForm(Integer) ??
try {
fs.purgeForm(fs.getForm(Integer.valueOf(p)));
if (!"".equals(success.toString())) {
success.append("<br/>");
}
success.append(textForm).append(" ").append(p).append(" ").append(deleted);
}
catch (APIException e) {
log.warn("Error deleting form", e);
if (!"".equals(error.toString())) {
error.append("<br/>");
}
error.append(textForm).append(" ").append(p).append(" ").append(notDeleted);
}
}
} else {
success.append(noneDeleted);
}
view = getSuccessView();
if (!"".equals(success.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString());
}
if (!"".equals(error.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString());
}
}
return new ModelAndView(new RedirectView(view));
}
示例5: onSubmit
import org.springframework.context.support.MessageSourceAccessor; //導入方法依賴的package包/類
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
String view = getFormView();
if (Context.isAuthenticated()) {
String[] programList = request.getParameterValues("programId");
ProgramWorkflowService ps = Context.getProgramWorkflowService();
StringBuilder success = new StringBuilder("");
StringBuilder error = new StringBuilder();
MessageSourceAccessor msa = getMessageSourceAccessor();
String deleted = msa.getMessage("general.deleted");
String notDeleted = msa.getMessage("general.cannot.delete");
String textProgram = msa.getMessage("Program.program");
String noneDeleted = msa.getMessage("Program.nonedeleted");
if (programList != null) {
for (String p : programList) {
try {
ps.purgeProgram(ps.getProgram(Integer.valueOf(p)));
if (!"".equals(success.toString())) {
success.append("<br/>");
}
success.append(textProgram);
success.append(" ");
success.append(p);
success.append(" ");
success.append(deleted);
}
catch (APIException e) {
log.warn("Error deleting program", e);
if (!"".equals(error.toString())) {
error.append("<br/>");
}
error.append(textProgram).append(" ").append(p).append(" ").append(notDeleted);
}
}
} else {
success.append(noneDeleted);
}
view = getSuccessView();
if (!"".equals(success.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString());
}
if (!"".equals(error.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString());
}
}
return new ModelAndView(new RedirectView(view));
}
示例6: onSubmit
import org.springframework.context.support.MessageSourceAccessor; //導入方法依賴的package包/類
/**
* The onSubmit function receives the form/command object that was modified by the input form
* and saves it to the db
*
* @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse, java.lang.Object,
* org.springframework.validation.BindException)
*/
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
BindException errors) throws Exception {
HttpSession httpSession = request.getSession();
String view = getFormView();
if (Context.isAuthenticated()) {
String[] conversionIdList = request.getParameterValues("conceptStateConversionId");
ProgramWorkflowService pws = Context.getProgramWorkflowService();
StringBuilder success = new StringBuilder("");
StringBuilder error = new StringBuilder("");
int numDeleted = 0;
MessageSourceAccessor msa = getMessageSourceAccessor();
String deleted = msa.getMessage("general.deleted");
String notDeleted = msa.getMessage("general.cannot.delete");
String textConversion = msa.getMessage("Program.conversion");
String noneDeleted = msa.getMessage("Program.conversion.nonedeleted");
if (conversionIdList != null) {
for (String id : conversionIdList) {
try {
pws.purgeConceptStateConversion(pws.getConceptStateConversion(Integer.valueOf(id)));
if (!"".equals(success.toString())) {
success.append("<br/>");
}
success.append(textConversion).append(" ").append(id).append(" ").append(deleted);
numDeleted++;
}
catch (APIException e) {
log.warn("Error deleting concept state conversion", e);
if (!"".equals(error.toString())) {
error.append("<br/>");
}
error.append(textConversion).append(" ").append(id).append(" ").append(notDeleted);
}
}
if (numDeleted > 3) {
success = new StringBuilder(numDeleted).append(" ").append(deleted);
}
} else {
success.append(noneDeleted);
}
view = getSuccessView();
if (!"".equals(success.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, success.toString());
}
if (!"".equals(error.toString())) {
httpSession.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, error.toString());
}
}
return new ModelAndView(new RedirectView(view));
}
示例7: handleRequest
import org.springframework.context.support.MessageSourceAccessor; //導入方法依賴的package包/類
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request)
throws Exception {
log.debug("entering 'handleRequest' method...");
String username = request.getParameter("username");
MessageSourceAccessor text = new MessageSourceAccessor(messageSource,
request.getLocale());
// ensure that the username has been sent
if (username == null) {
log.warn("Username not specified, notifying user that it's a required field.");
request.setAttribute(
"error",
text.getMessage("errors.required",
text.getMessage("user.username")));
return new ModelAndView("login");
}
log.debug("Processing Password Hint...");
// look up the user's information
try {
User user = userManager.getUserByUsername(username);
StringBuffer msg = new StringBuffer();
msg.append("Your password hint is: ")
.append(user.getPasswordHint());
msg.append("\n\nLogin at: ").append(RequestUtil.getAppURL(request));
message.setTo(user.getEmail());
String subject = '[' + text.getMessage("webapp.name") + "] "
+ text.getMessage("user.passwordHint");
message.setSubject(subject);
message.setText(msg.toString());
mailEngine.send(message);
saveMessage(
request,
text.getMessage("login.passwordHint.sent", new Object[] {
username, user.getEmail() }));
} catch (UsernameNotFoundException e) {
log.warn(e.getMessage());
saveError(request, text.getMessage("login.passwordHint.error",
new Object[] { username }));
} catch (MailException me) {
log.warn(me.getMessage());
saveError(request, me.getCause().getLocalizedMessage());
}
return new ModelAndView(new RedirectView(request.getContextPath()));
}