Changeset 446


Ignore:
Timestamp:
04/02/12 17:01:12 (12 years ago)
Author:
vmipsl
Message:

getMessage récup du texte ds messages.properties

Location:
tapas
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tapas/common/implementation/com/ether/EtherHelper.java

    r423 r446  
    1717import java.util.ArrayList; 
    1818import java.util.List; 
     19import java.util.Locale; 
    1920import java.util.Random; 
     21import java.util.ResourceBundle; 
    2022 
    2123/** 
     
    226228        } 
    227229    } 
     230 
     231    /** 
     232     * This method return the text corresponding to the code in the files messages**.properties 
     233     * 
     234     * @param code 
     235     * @param locale 
     236     * @return 
     237     */ 
     238    public static String getMessage( @NotNull final String code, @Nullable final Locale locale ) 
     239    { 
     240        ResourceBundle bundle = ResourceBundle.getBundle( "messages", Locale.ENGLISH ); 
     241        if( null != locale ) 
     242            bundle = ResourceBundle.getBundle( "messages", locale ); 
     243 
     244        return bundle.getString( code ); 
     245    } 
     246 
    228247} 
  • tapas/web/src/com/ether/Controller.java

    r445 r446  
    3333     * @throws WebException 
    3434     */ 
    35     //@ControllerMethod(view = VIEW_FORM_TAPAS, loginMandatory = true, defaultView = VIEW_INDEX) 
    36     @ControllerMethod(view = VIEW_FORM_TAPAS, loginMandatory = false, defaultView = VIEW_INDEX) 
     35    @ControllerMethod(view = VIEW_FORM_TAPAS, loginMandatory = true, defaultView = VIEW_INDEX) 
    3736    public JSONObject viewForm() 
    3837            throws WebException 
  • tapas/web/src/com/ether/ControllerEther.java

    r445 r446  
    7474    } 
    7575 
    76     /** 
    77      * This method return the text from the files messages**.properties 
    78      * 
    79      * @param code 
    80      * @return 
    81      */ 
    82     public String getMessage( @NotNull final String code ) 
    83     { 
    84         final String webInfPath = getServletContext().getRealPath( "WEB-INF" ); 
    85         return WebHelper.getMessage( webInfPath, code ); 
    86     } 
    87  
    8876    @Override 
    8977    @Nullable 
     
    9785 
    9886            request.setCharacterEncoding( UTF8Charset.getEncoding() ); 
    99 //            String message = getMessage( "bo.fulltitle" ); 
    10087 
    10188            // Get method to call 
  • tapas/web/src/com/ether/WebHelper.java

    r445 r446  
    88import org.jetbrains.annotations.NotNull; 
    99import org.jetbrains.annotations.Nullable; 
    10 import org.springframework.context.MessageSource; 
    11 import org.springframework.context.support.ClassPathXmlApplicationContext; 
    1210 
    1311import javax.servlet.ServletOutputStream; 
     
    132130    } 
    133131 
    134     /** 
    135      * This method return the text from the files messages**.properties 
    136      * 
    137      * @param code 
    138      * @return 
    139      */ 
    140     public static String getMessage( @NotNull final String webInfPath, @NotNull final String code ) 
    141     { 
    142         final MessageSource resources = new ClassPathXmlApplicationContext( webInfPath + "/classes/servlet-context.xml" ); 
    143         final String message = resources.getMessage( code, null, "Default", null ); 
    144         return message; 
    145     } 
    146  
    147132    public static final int STATUS_CODE_SERVICE_EXCEPTION = 500; 
    148133    public static final String PROPERTIES_FILE = "tapas.properties"; 
Note: See TracChangeset for help on using the changeset viewer.