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


Java MessageResources类代码示例

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


MessageResources类属于org.apache.struts.util包,在下文中一共展示了MessageResources类的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: validate

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
@Override
   public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

ActionErrors errors = new ActionErrors();

MessageResources resources = MessageResources.getMessageResources(Constants.APP_RESOURCES);

if (StringUtils.isBlank(this.serverURL)) {
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage("error.mandatoryField", resources.getMessage("config.serverURL")));
}

if (StringUtils.isBlank(this.securitySalt)) {
    errors.add(ActionMessages.GLOBAL_MESSAGE,
	    new ActionMessage("error.mandatoryField", resources.getMessage("config.securitySalt")));
}

return errors;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AdminForm.java

示例3: 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

示例4: do_Save_Clicked

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
/** Event Handler for the 'Save' clicked event.
 * This will copy the values from the Form to the Component and then invoke the performSave() method on the component.
 * Finally it'll get the latest values for the labels.
 * @return the FormKey for this screen.
 */
public FormKey do_Save_Clicked() {
    FormKey fk = null;
    LabelEditorForm myForm = (LabelEditorForm) form;
    LabelEditorComponent myComp = (LabelEditorComponent) component;
    try {
        // Copy the values from Form to Component
        myForm.doValidate();

        // Create/Update the override file
        myComp.performSave(request, (MessageResources) request.getAttribute(Globals.MESSAGES_KEY));

        // Get the latest values
        fk = do_Refresh_Clicked();
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general" );
    }
    if (fk == null)
        fk = myComp.getLabelEditorFormKey();
    return fk;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:27,代码来源:LabelEditorAction.java

示例5: do_SyncToSource_Clicked

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
/** Event Handler for the 'SyncToSource' clicked event.
 * This will copy the values from the Form to the Component and then invoke the performSyncToSource() method on the component.
 * Finally it'll get the latest values for the labels.
 * @return the FormKey for this screen.
 */
public FormKey do_SyncToSource_Clicked() {
    FormKey fk = null;
    LabelEditorForm myForm = (LabelEditorForm) form;
    LabelEditorComponent myComp = (LabelEditorComponent) component;
    try {
        // Copy the values from Form to Component
        myForm.doValidate();

        // Sync the values in the override file to the source code
        myComp.performSyncToSource((MessageResources) request.getAttribute(Globals.MESSAGES_KEY));

        // Get the latest values
        fk = do_Refresh_Clicked();
    } catch (FrameworkException e) {
        log.error(null, e);
        myForm.raiseError(request, ActionMessages.GLOBAL_MESSAGE, "error.framework.general" );
    }
    if (fk == null)
        fk = myComp.getLabelEditorFormKey();
    return fk;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:27,代码来源:LabelEditorAction.java

示例6: execute

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
          HttpServletResponse response) throws Exception 
  {
MessageResources resources = ((MessageResources) request.getAttribute(Globals.MESSAGES_KEY));  

// Construimos criterios de busqueda
CambioEstadoMasivoForm formularioBusqueda = ( CambioEstadoMasivoForm ) form;

CriteriosBusquedaTramite criterios = UtilBantelFront.crearCriteriosBusquedaTramite(formularioBusqueda);

// Marcamos entradas con nuevo estado
TramiteBandejaDelegate delegate = DelegateUtil.getTramiteBandejaDelegate();
delegate.procesarEntradas(criterios,Character.toString(formularioBusqueda.getEstadoNuevo()), "Estado cambiado por gestor " + this.getPrincipal(request).getName());

// Indicamos que el cambio se ha realizado correctamente
request.setAttribute("message",resources.getMessage( getLocale( request ), "cambioEstadoMasivo.realizado"));
return mapping.findForward( "success" );
  }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:19,代码来源:CambioEstadoMasivoAction.java

示例7: execute

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

MessageResources resources = ((MessageResources) request.getAttribute(Globals.MESSAGES_KEY));

try {
	DetalleFuenteDatosForm detalleFuenteDatos = ( DetalleFuenteDatosForm ) form;
	FuenteDatosDelegate delegate = DelegateUtil.getFuenteDatosDelegate();
	delegate.altaFilaFuenteDatos(detalleFuenteDatos.getIdentificador());
	
	response.sendRedirect("detalleFuenteDatos.do?identificador=" + detalleFuenteDatos.getIdentificador());
	return null;
} catch (Exception ex) {
	String keyError = "fuenteDatos.errorPKNuevaFila";
	
	// Controlamos si es una excepcion de PK
	if (ExceptionUtils.getRootCauseMessage(ex).indexOf("PK-Exception") != -1) {
		keyError = "fuenteDatos.errorPK";
	}
	
	request.setAttribute("message",resources.getMessage( getLocale( request ), keyError));
	return mapping.findForward( "fail" );
}

  }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:27,代码来源:InsertarFilaFuenteDatosAction.java

示例8: execute

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
          HttpServletResponse response) throws Exception
  {
CambiarEstadoTramiteForm formulario 	= ( CambiarEstadoTramiteForm ) form;
TramiteBandejaDelegate tramiteDelegate 	= DelegateUtil.getTramiteBandejaDelegate();		
TramiteBandeja tramite 					= tramiteDelegate.obtenerTramiteBandeja( formulario.getCodigo() );

// Comprobamos que no haya habido un cambio de estado mientras tanto
MessageResources resources = ((MessageResources) request.getAttribute(Globals.MESSAGES_KEY));
if (tramite.getProcesada() != formulario.getEstadoOld()){
	request.setAttribute("message",resources.getMessage( getLocale( request ), "errors.estadoHaCambiado"));			
	return mapping.findForward( "fail" );
}

tramiteDelegate.procesarEntrada(tramite.getNumeroEntrada(),Character.toString(formulario.getEstado()));

// return mapping.findForward( "success" );

response.sendRedirect("detalleTramite.do?codigo="+formulario.getCodigo().longValue());
return null;

  }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:23,代码来源:CambiarEstadoTramiteAction.java

示例9: setMessage

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
/**
   * establece un mensaje multiidioma que sera obtenido del fichero sistra-front-messages.properties
   * @param request
   * @param messageKey
   * @param tipoMensaje
   */
  private static void setMessage( HttpServletRequest request, String messageKey, int tipoMensaje, Object args[],ParametrosMensaje param, String exceptionMessage )
  {
  	MensajeFront mensaje = new MensajeFront();
//mensaje.setTipo( MensajeFront.TIPO_ERROR );
//mensaje.setMensaje( "EJBException in method: public abstract void javax.ejb.EJBLocalObject.remove()" );
mensaje.setTipo( tipoMensaje );
//MessageResources resources = this.getResources( request );
MessageResources resources = ((MessageResources) request.getAttribute(Globals.MESSAGES_KEY));
mensaje.setMensaje( resources.getMessage( getLocale( request ), messageKey, args ) );
mensaje.setMensajeExcepcion(exceptionMessage);
request.setAttribute( Constants.MENSAJE_KEY, mensaje );
if (param != null) {
	request.setAttribute( Constants.MENSAJE_PARAM, param );
}else{
	request.setAttribute( Constants.MENSAJE_PARAM, new ParametrosMensaje() );
}		
  }
 
开发者ID:GovernIB,项目名称:sistra,代码行数:24,代码来源:TramiteRequestHelper.java

示例10: getArgs

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
/**
 * Gets the message arguments based on the current <code>ValidatorAction</code>
 * and <code>Field</code>.
 *
 * @param actionName action name
 * @param messages   message resources
 * @param locale     the locale
 * @param field      the validator field
 */
public static String[] getArgs(String actionName,
    MessageResources messages, Locale locale, Field field) {
    String[] argMessages = new String[4];

    Arg[] args =
        new Arg[] {
            field.getArg(actionName, 0), field.getArg(actionName, 1),
            field.getArg(actionName, 2), field.getArg(actionName, 3)
        };

    for (int i = 0; i < args.length; i++) {
        if (args[i] == null) {
            continue;
        }

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

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

示例11: execute

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
/**
    * Process the specified HTTP request, and create the corresponding HTTP
    * response (or forward to another web component that will create it).
    * Return an <code>ActionForward</code> instance describing where and how
    * control should be forwarded, or <code>null</code> if the response has
    * already been completed.
    *
    * @param mapping The ActionMapping used to select this instance
    * @param actionForm The optional ActionForm bean for this request (if any)
    * @param request The HTTP request we are processing
    * @param response The HTTP response we are creating
    *
    * @exception IOException if an input/output error occurs
    * @exception ServletException if a servlet exception occurs
    */
   public ActionForward execute(ActionMapping mapping,
			 ActionForm form,
			 HttpServletRequest request,
			 HttpServletResponse response)
throws IOException, ServletException {

// Extract attributes we will need
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
HttpSession session = request.getSession();
User user = (User) session.getAttribute(Constants.USER_KEY);

// Process this user logoff
if (user != null) {
    if (debug)
        servlet.log("LogoffAction: User '" + user.getUsername() +
                    "' logged off in session " + session.getId());
} else {
    if (debug)
        servlet.log("LogoffActon: User logged off in session " +
                    session.getId());
}
session.removeAttribute(Constants.USER_KEY);
session.invalidate();

ActionErrors errors = new ActionErrors ();
errors.add("message",
	new ActionError("logoff.success"));
saveErrors(request, errors);

// Forward control to the specified success URI
return (mapping.findForward("logoff"));

   }
 
开发者ID:NCAR,项目名称:joai-project,代码行数:50,代码来源:LogoffAction.java

示例12: 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

示例13: getArgs

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
/**
 * Gets the message arguments based on the current 
 * <code>ValidatorAction</code> and <code>Field</code>.
 * @param actionName action name
 * @param messages message resources
 * @param locale the locale
 * @param field the validator field
 */
public static String[] getArgs(
    String actionName,
    MessageResources messages,
    Locale locale,
    Field field) {

    String[] argMessages = new String[4];

    Arg[] args =
        new Arg[] {
            field.getArg(actionName,0),
            field.getArg(actionName,1),
            field.getArg(actionName,2),
            field.getArg(actionName,3)};

    for (int i = 0; i < args.length; i++) {
        if (args[i] == null) {
            continue;
        }

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

    }

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

示例14: 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

示例15: present

import org.apache.struts.util.MessageResources; //导入依赖的package包/类
/**
 * Return true if a message string for the specified message key
 * is present for the specified Locale.
 *
 * @param pageContext The PageContext associated with this request
 * @param bundle Name of the servlet context attribute for our
 *  message resources bundle
 * @param locale Name of the session attribute for our user's Locale
 * @param key Message key to be looked up and returned
 * @return true if a message string for message key exists
 * @exception JspException if a lookup error occurs (will have been
 *  saved in the request already)
 */
public boolean present(
        PageContext pageContext,
        String bundle,
        String locale,
        String key)
        throws JspException {

    MessageResources resources =
            retrieveMessageResources(pageContext, bundle, true);

    Locale userLocale = getUserLocale(pageContext, locale);

    return resources.isPresent(userLocale, key);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:TagUtils.java


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