当前位置: 首页>>代码示例>>Java>>正文


Java MessageResources.getMessage方法代码示例

本文整理汇总了Java中org.apache.struts.util.MessageResources.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java MessageResources.getMessage方法的具体用法?Java MessageResources.getMessage怎么用?Java MessageResources.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.struts.util.MessageResources的用法示例。


在下文中一共展示了MessageResources.getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMessage

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/**
 * Look up and return a message string, based on the specified parameters.
 *
 * @param key Message key to be looked up and returned
 * @param args Replacement parameters for this message
 */
public String getMessage(String key, Object args[]) {

    MessageResources resources = getMessageResources();

    if (resources == null)
        return null;

    // Return the requested message
    if (args == null)
        return resources.getMessage(
            RequestUtils.getUserLocale(request, null),
            key);
    else
        return resources.getMessage(
            RequestUtils.getUserLocale(request, null),
            key,
            args);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ConfigHelper.java

示例2: findMessage

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/**
 * Gets the message for the input key from the resources. It will also perform token replacement.
 * @param resources The underlying resource bundle to look at.
 * @param locale The requested message Locale.
 * @param key The key of the the message to be looked up.
 * @param args An array of arguments to be added to the message.
 * @return the message with the tokens replaced.
 */
public static String findMessage(MessageResources resources, Locale locale, String key, Object[] args) {
    // Get the message
    if (log.isDebugEnabled())
        log.debug("Looking up the ResourceBundle for the key - " + key);
    
    if (key == null)
        return null;
    
    String message = null;
    if (args == null)
        message = resources.getMessage(locale, key);
    else
        message = resources.getMessage(locale, key, args);
    
    // now perform token replacement
    if (message != null)
        message = replaceTokens(resources, locale, message);
    
    return message;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:29,代码来源:MessageHelper.java

示例3: getMessage

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/**
 * Gets the <code>Locale</code> sensitive value based on the key passed in.
 * @param messages The Message resources
 * @param locale The locale.
 * @param key Key used to lookup the message
 */
public static String getMessage(
    MessageResources messages,
    Locale locale,
    String key) {
    String message = null;

    if (messages != null) {
        message = messages.getMessage(locale, key);
    }

    return (message == null) ? "" : message;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:Resources.java

示例4: getArgValues

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/**
 * Gets the message arguments based on the current 
 * <code>ValidatorAction</code> and <code>Field</code>.
 * @param application the servlet context
 * @param request the servlet request
 * @param defaultMessages Default message resources
 * @param locale the locale
 * @param args The arguments for the message
 */
private static String[] getArgValues(
    ServletContext application,
    HttpServletRequest request,
    MessageResources defaultMessages,
    Locale locale,
    Arg[] args) {

    if (args == null || args.length == 0) {
        return null;
    }

    String[] values = new String[args.length];
    for (int i = 0; i < args.length; i++) {
        if (args[i] != null) {
            if (args[i].isResource()) {

                MessageResources messages = defaultMessages;
                if (args[i].getBundle() != null) {
                    messages = getMessageResources(application, request, args[i].getBundle());
                }
                values[i] = messages.getMessage(locale, args[i].getKey());

            } else {

                values[i] = args[i].getKey();

            }
        }
    }

    return values;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:43,代码来源:Resources.java

示例5: initLookupMap

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/**
 * This is the first time this Locale is used so build the reverse lookup Map.
 * Search for message keys in all configured MessageResources for
 * the current module.
 */
private Map initLookupMap(HttpServletRequest request, Locale userLocale) {
    Map lookupMap = new HashMap();
    this.keyMethodMap = this.getKeyMethodMap();

    ModuleConfig moduleConfig =
            (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);

    MessageResourcesConfig[] mrc = moduleConfig.findMessageResourcesConfigs();

    // Look through all module's MessageResources
    for (int i = 0; i < mrc.length; i++) {
        MessageResources resources = this.getResources(request, mrc[i].getKey());

        // Look for key in MessageResources
        Iterator iter = this.keyMethodMap.keySet().iterator();
        while (iter.hasNext()) {
            String key = (String) iter.next();
            String text = resources.getMessage(userLocale, key);

            // Found key and haven't added to Map yet, so add the text
            if ((text != null) && !lookupMap.containsKey(text)) {
                lookupMap.put(text, key);
            }
        }
    }

    return lookupMap;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:LookupDispatchAction.java

示例6: getUserID

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/** Get the user id from the shared session */
   public Long getUserID(HttpServletRequest request) {
// set up the user details
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
if (user == null) {
    MessageResources resources = getResources(request);
    String error = resources.getMessage(NoticeboardConstants.ERR_MISSING_PARAM, "User");
    logger.error(error);
    throw new NbApplicationException(error);
}
return new Long(user.getUserID().longValue());
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:NbLearnerAction.java

示例7: getUserDTO

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
private UserDTO getUserDTO(HttpServletRequest request) {
// set up the user details
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
if (user == null) {
    MessageResources resources = getResources(request);
    String error = resources.getMessage(NoticeboardConstants.ERR_MISSING_PARAM, "User");
    logger.error(error);
    throw new NbApplicationException(error);
}
return user;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:NbLearnerStarterAction.java

示例8: getUser

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/** Get the user from the shared session */
   public UserDTO getUser(HttpServletRequest request) {
// set up the user details
HttpSession ss = SessionManager.getSession();
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
if (user == null) {
    MessageResources resources = getResources(request);
    String error = resources.getMessage(NoticeboardConstants.ERR_MISSING_PARAM, "User");
    logger.error(error);
    throw new NbApplicationException(error);
}
return user;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:NbAuthoringAction.java

示例9: getBackButton

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
public static String getBackButton(HttpServletRequest request, int nrBackSteps, String name, String title, String accessKey, String style, String clazz, String backType, String backId) {
	MessageResources rsc = getResources(request);
	if (rsc!=null && rsc.getMessage(name)!=null) {
		name = rsc.getMessage(name);
	}
	synchronized (request.getSession()) {
		Vector backList = getBackList(request.getSession());
		if (backList.size()<nrBackSteps) return "";
		String[] backItem = (String[])backList.elementAt(backList.size()-nrBackSteps);
		if (backItem[1]!=null)
			title = title.replaceAll("%%", backItem[1]);
		String backUrl = backItem[0];
		if (backId!=null && backType!=null) {
			if (backUrl.indexOf('?')>0)
				backUrl += "&backType="+backType+"&backId="+backId+"#back";
			else
				backUrl += "?backType="+backType+"&backId="+backId+"#back";
		}
		return "<input type='button'"+
			" value='"+name+"' "+
			(accessKey==null?"":" accesskey=\""+accessKey+"\"")+
			(style==null?"":" style=\""+style+"\"")+
			(clazz==null?"":" class=\""+clazz+"\"")+
			" title=\""+title+"\""+
			" onClick=\"document.location='back.do?uri="+encodeURL(backUrl)+"'"+
			
			";\""+
			"/>";
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:31,代码来源:BackTracker.java

示例10: getMessage

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/**
 * <p> Return the localized message for the specified key, otherwise
 * return <code>null</code>. </p>
 *
 * @param key Message key
 */
public String getMessage(String key) {
    MessageResources resources = getMessageResources();

    if (resources == null) {
        return null;
    }

    return resources.getMessage(RequestUtils.getUserLocale(request, null),
        key);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:17,代码来源:ConfigHelper.java

示例11: getArgValues

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/**
 * Gets the message arguments based on the current <code>ValidatorAction</code>
 * and <code>Field</code>.
 *
 * @param application     the servlet context
 * @param request         the servlet request
 * @param defaultMessages Default message resources
 * @param locale          the locale
 * @param args            The arguments for the message
 */
private static String[] getArgValues(ServletContext application,
    HttpServletRequest request, MessageResources defaultMessages,
    Locale locale, Arg[] args) {
    if ((args == null) || (args.length == 0)) {
        return null;
    }

    String[] values = new String[args.length];

    for (int i = 0; i < args.length; i++) {
        if (args[i] != null) {
            if (args[i].isResource()) {
                MessageResources messages = defaultMessages;

                if (args[i].getBundle() != null) {
                    messages =
                        getMessageResources(application, request,
                            args[i].getBundle());
                }

                values[i] = messages.getMessage(locale, args[i].getKey());
            } else {
                values[i] = args[i].getKey();
            }
        }
    }

    return values;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:40,代码来源:Resources.java

示例12: execute

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		if(!securityInfoManager.hasPrivilege(LoggedInInfo.getLoggedInInfoFromSession(request), "_report", "r", null)) {
  		  throw new SecurityException("missing required security object (_report)");
  	  	}
		
		RptInitializeFrequencyOfRelevantTestsCDMReportForm frm = (RptInitializeFrequencyOfRelevantTestsCDMReportForm) form;
		request.getSession().setAttribute("RptInitializeFrequencyOfRelevantTestsCDMReportForm", frm);
		MessageResources mr = getResources(request);
		ArrayList<String> reportMsg = new ArrayList<String>();
		ArrayList<String> headings = new ArrayList<String>();
		RptMeasurementsData mData = new RptMeasurementsData();
		String[] patientSeenCheckbox = frm.getPatientSeenCheckbox();
		String startDateA = frm.getStartDateA();
		String endDateA = frm.getEndDateA();
		int nbPatient = 0;

		if (!validate(frm, request)) {
			return (new ActionForward(mapping.getInput()));
		}

		addHeading(headings, request);
		if (patientSeenCheckbox != null) {
			nbPatient = mData.getNbPatientSeen(startDateA, endDateA);
			String msg = mr.getMessage("oscarReport.CDMReport.msgPatientSeen", Integer.toString(nbPatient), startDateA, endDateA);
			MiscUtils.getLogger().debug(msg);
			reportMsg.add(msg);
			reportMsg.add("");
		}
		getFrequenceOfTestPerformed(frm, reportMsg, request);

		String title = mr.getMessage("oscarReport.CDMReport.msgFrequencyOfRelevantTestsBeingPerformed");
		request.setAttribute("title", title);
		request.setAttribute("messages", reportMsg);
		return mapping.findForward("success");
	}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:37,代码来源:RptInitializeFrequencyOfRelevantTestsCDMReportAction.java

示例13: addHeading

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
private ArrayList<String> addHeading(ArrayList<String> headings, HttpServletRequest request) {
	MessageResources mr = getResources(request);
	String hd = mr.getMessage("oscarReport.CDMReport.msgFrequency");
	MiscUtils.getLogger().debug(hd);
	headings.add(hd);
	hd = mr.getMessage("oscarReport.CDMReport.msgPercentage");
	MiscUtils.getLogger().debug(hd);
	headings.add(hd);
	return headings;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:11,代码来源:RptInitializeFrequencyOfRelevantTestsCDMReportAction.java

示例14: getMessage

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
/**
 * Gets the <code>Locale</code> sensitive value based on the key passed
 * in.
 *
 * @param application     the servlet context
 * @param request         the servlet request
 * @param defaultMessages The default Message resources
 * @param locale          The locale
 * @param va              The Validator Action
 * @param field           The Validator Field
 */
public static String getMessage(ServletContext application,
    HttpServletRequest request, MessageResources defaultMessages,
    Locale locale, ValidatorAction va, Field field) {
    Msg msg = field.getMessage(va.getName());

    if ((msg != null) && !msg.isResource()) {
        return msg.getKey();
    }

    String msgKey = null;
    String msgBundle = null;
    MessageResources messages = defaultMessages;

    if (msg == null) {
        msgKey = va.getMsg();
    } else {
        msgKey = msg.getKey();
        msgBundle = msg.getBundle();

        if (msg.getBundle() != null) {
            messages =
                getMessageResources(application, request, msg.getBundle());
        }
    }

    if ((msgKey == null) || (msgKey.length() == 0)) {
        return "??? " + va.getName() + "." + field.getProperty() + " ???";
    }

    // Get the arguments
    Arg[] args = field.getArgs(va.getName());
    String[] argValues =
        getArgValues(application, request, messages, locale, args);

    // Return the message
    return messages.getMessage(locale, msgKey, argValues);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:49,代码来源:Resources.java

示例15: execute

import org.apache.struts.util.MessageResources; //导入方法依赖的package包/类
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		if(!securityInfoManager.hasPrivilege(LoggedInInfo.getLoggedInInfoFromSession(request), "_report", "r", null)) {
	  		  throw new SecurityException("missing required security object (_report)");
	  	  	}
		
		RptInitializePatientsMetGuidelineCDMReportForm frm = (RptInitializePatientsMetGuidelineCDMReportForm) form;
		request.getSession().setAttribute("RptInitializePatientsMetGuidelineCDMReportForm", frm);
		MessageResources mr = getResources(request);
		RptMeasurementsData mData = new RptMeasurementsData();
		String[] patientSeenCheckbox = frm.getPatientSeenCheckbox();
		String startDateA = frm.getStartDateA();
		String endDateA = frm.getEndDateA();

		ArrayList reportMsg = new ArrayList();

		if (!validate(frm, request)) {
			MiscUtils.getLogger().debug("the form is invalid");
			return (new ActionForward(mapping.getInput()));
		}

		if (patientSeenCheckbox != null) {
			int nbPatient = mData.getNbPatientSeen(startDateA, endDateA);
			String msg = mr.getMessage("oscarReport.CDMReport.msgPatientSeen", Integer.toString(nbPatient), startDateA, endDateA);
			MiscUtils.getLogger().debug(msg);
			reportMsg.add(msg);
			reportMsg.add("");
		}

		getMetGuidelinePercentage(frm, reportMsg, request);
		//getPatientsMetAllSelectedGuideline(db, frm, reportMsg, request);

		String title = mr.getMessage("oscarReport.CDMReport.msgPercentageOfPatientWhoMetGuideline");
		request.setAttribute("title", title);
		request.setAttribute("messages", reportMsg);

		return mapping.findForward("success");
	}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:39,代码来源:RptInitializePatientsMetGuidelineCDMReportAction.java


注:本文中的org.apache.struts.util.MessageResources.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。