Changeset 406


Ignore:
Timestamp:
03/09/12 16:31:28 (12 years ago)
Author:
vmipsl
Message:

gestion langues fr/en

Location:
tapas
Files:
1 deleted
9 edited
3 copied

Legend:

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

    r376 r406  
    11package com.ether; 
     2 
     3import com.ether.annotation.ControllerMethod; 
     4import org.jetbrains.annotations.NotNull; 
     5import org.jetbrains.annotations.Nullable; 
    26 
    37import java.lang.reflect.Method; 
    48import java.util.ArrayList; 
    59import java.util.List; 
    6  
    7 import org.jetbrains.annotations.NotNull; 
    8 import org.jetbrains.annotations.Nullable; 
    9  
    10 import com.ether.annotation.ControllerMethod; 
    1110 
    1211public class MethodDescription 
     
    1615        _method = method; 
    1716        _view = annotation.view(); 
     17        _defaultView = annotation.defaultView(); 
    1818        _isJsonResult = annotation.jsonResult(); 
     19        _isLoginMandatory = annotation.loginMandatory(); 
     20        _isRequestMandatory = annotation.requestMandatory(); 
     21        _isBackofficeMethod = annotation.backofficeMethod(); 
    1922        _params = new ArrayList<ParamDescription>(); 
    2023    } 
     
    3437    { 
    3538        return _view; 
     39    } 
     40 
     41    public void setView( @NotNull final String view ) 
     42    { 
     43        _view = view; 
     44    } 
     45 
     46    @Nullable 
     47    public String getDefaultView() 
     48    { 
     49        return _defaultView; 
     50    } 
     51 
     52    public void setDefaultView( @Nullable final String defaultView ) 
     53    { 
     54        _defaultView = defaultView; 
    3655    } 
    3756 
     
    6483    } 
    6584 
     85    public Boolean isLoginMandatory() 
     86    { 
     87        return _isLoginMandatory; 
     88    } 
     89 
     90    public void setLoginMandatory( final Boolean loginMandatory ) 
     91    { 
     92        _isLoginMandatory = loginMandatory; 
     93    } 
     94 
     95    public Boolean isRequestMandatory() 
     96    { 
     97        return _isRequestMandatory; 
     98    } 
     99 
     100    public void setRequestMandatory( final Boolean requestMandatory ) 
     101    { 
     102        _isRequestMandatory = requestMandatory; 
     103    } 
     104 
     105    public Boolean isBackofficeMethod() 
     106    { 
     107        return _isBackofficeMethod; 
     108    } 
     109 
     110    public void setBackofficeMethod( final Boolean backofficeMethod ) 
     111    { 
     112        _isBackofficeMethod = backofficeMethod; 
     113    } 
     114 
    66115    @NotNull 
    67116    private Method _method; 
    68117    @NotNull 
    69118    private String _view; 
     119    @Nullable 
     120    private String _defaultView; 
    70121    private Boolean _isJsonResult; 
    71122    @Nullable 
    72123    private List<ParamDescription> _params; 
     124    private Boolean _isLoginMandatory; 
     125    private Boolean _isRequestMandatory; 
     126    private Boolean _isBackofficeMethod; 
    73127} 
  • tapas/common/implementation/com/ether/annotation/ControllerMethod.java

    r376 r406  
    11package com.ether.annotation; 
     2 
     3import org.jetbrains.annotations.NotNull; 
     4import org.jetbrains.annotations.Nullable; 
    25 
    36import java.lang.annotation.ElementType; 
     
    69import java.lang.annotation.Target; 
    710 
    8 import org.jetbrains.annotations.NotNull; 
    9  
    1011@Retention(RetentionPolicy.RUNTIME) 
    1112@Target(ElementType.METHOD) 
    1213public @interface ControllerMethod 
    1314{ 
    14         @NotNull 
    15     String view() default ""; 
     15    @NotNull String view() default ""; 
    1616 
    17         @NotNull 
    1817    boolean jsonResult() default false; 
     18 
     19    boolean loginMandatory() default false; 
     20 
     21    boolean requestMandatory() default false; 
     22 
     23    boolean backofficeMethod() default false; 
     24 
     25    @Nullable String defaultView() default ""; 
    1926} 
  • tapas/web/project/formTapas.jsp

    r402 r406  
    1 <%@ page import="com.ether.Context" %> 
    21<%@ page import="com.ether.WebException" %> 
    32<%@ page contentType="text/html;charset=UTF-8" language="java" %> 
     
    2928        <div id="errors"></div> 
    3029 
    31         <BR/> 
    32         <%=Context.getPageURI( request )%><BR/> 
    33         <%=Context.getRelativePageURI( request )%><BR/> 
    34         <%=Context.getRelativePath( request )%><BR/> 
    35         <%=Context.getWebroot( request )%><BR/> 
    36         <%=request.getQueryString()%><BR/> 
    37         <%=request.getContextPath()%><BR/> 
    38         <%=request.getPathInfo()%><BR/> 
    39         <%=request.getServletPath()%><BR/> 
    40         <%=request.getRequestURL()%><BR/> 
    41  
    42  
    4330        <script type="text/javascript"> 
    4431            var tapasTexts = $A( "" ); 
    45  
    4632            tapasTexts["label.submitButton"] = '<spring:message code="label.submitButton"/>'; 
    4733            tapasTexts["<%=WebException.WebCode.ERROR_JSON_TAPAS_IS_NULL%>"] = "<spring:message code="error.ERROR_JSON_TAPAS_IS_NULL"/>"; 
    48  
    4934 
    5035            var interfaceTapas = new InterfaceTapas(); 
  • tapas/web/resources/templates/templateEther.jsp

    r404 r406  
    124124    var templateTexts = $A( "" ); 
    125125    templateTexts["label.home"] = '<spring:message code="label.home"/>'; 
    126     templateTexts["label.language.to.fr"] = '<spring:message code="label.language.to.fr"/>'; 
    127     templateTexts["label.language.to.en"] = '<spring:message code="label.language.to.en"/>'; 
     126    templateTexts["label.language.to.switch"] = '<spring:message code="label.language.to.switch"/>'; 
     127    templateTexts["label.language.value.to.switch"] = '<spring:message code="label.language.value.to.switch"/>'; 
    128128    templateTexts["label.mail"] = '<spring:message code="label.mail"/>'; 
    129129    templateTexts["label.map"] = '<spring:message code="label.map"/>'; 
  • tapas/web/resources/templates/templateEther_script.jsp

    r404 r406  
    1 <%@ page import="com.ether.Context" %> 
    2  
    31<script type="text/javascript"> 
    42    var InterfaceTemplate = Class.create( { 
     
    1210 
    1311            /** *********** VARIABLES *********** **/ 
    14             this.isLanguageFr = <%=Context.getLangue(request).equals( "fr" )%>; 
    1512            // TODO : vérifier cette adresse de webmaster !!!! 
    1613            this.webmaster = "rboipsl@ipsl.jussieu.fr"; 
     
    2421        { 
    2522            var mailButton = new Button( {value:templateTexts["label.mail"], parent:this.containerTools, id:"button_mail", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickMail, this )} ); 
    26  
    27 //        var valueLanguage = templateTexts["label.language.fr"]; 
    28 //        if( this.isLanguageFr ) 
    29 //            valueLanguage = templateTexts["label.language.en"]; 
    30  
    31             <%--var languageButton = new Button( {value: templateTexts["label.language.<%=Context.getLocale( request )%>"], parent:this.containerTools, id:"button_language", className: "red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} );--%> 
    32             var languageButton = new Button( {value:templateTexts["label.language.to.<%=Context.getLocale( request )%>"], parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} ); 
     23            var languageButton = new Button( {value:templateTexts["label.language.to.switch"], parent:this.containerTools, id:"button_language", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickLanguage, this )} ); 
    3324            var homeButton = new Button( {value:templateTexts["label.home"], parent:this.containerTools, id:"button_home", className: "red_button", classNameText:"red_button_text", onClick:this.onClickHome} ); 
    3425        }, 
    3526 
    3627        // REQUESTS ******************************************************** 
     28        requestChangeLocale: function() 
     29        { 
     30            $.ajax( { 
     31                url: "project?methodName=setLocale&language=" + templateTexts["label.language.value.to.switch"], 
     32                success:function() 
     33                { 
     34                    location.reload(); 
     35                } 
     36            } ); 
     37        }, 
     38 
     39        // HANDLES ******************************************************** = retours ajax 
     40        handleChangeLocale: function( result ) 
     41        { 
     42            var bob = jQuery.parseJSON( result ).result; 
     43            alert( bob ); 
     44        }, 
    3745 
    3846        // EVENTS ******************************************************** 
     
    4452        onClickLanguage: function() 
    4553        { 
    46             this.path = "<%=request.getContextPath()%>"; 
    47             this.webmaster = "<%=Context.getWebmaster(request)%>"; 
    48  
    49             alert( "<%=request.getQueryString()%>||<%=Context.getRelativePath( request )%>||<%=Context.getRelativePageURI(request)%>" ); 
    50  
    51             this.relativePageUri = <%=request.getQueryString() != null%> ? "<%=Context.getRelativePath( request )%>?<%=request.getQueryString()%>" : "<%=Context.getRelativePageURI(request)%>"; 
    52  
    53             alert( this.relativePageUri + " " +<%=Context.isFrench(request)%> ); 
    54             if( <%=Context.isFrench(request)%> ) 
    55                 document.location.href = this.path + this.relativePageUri + "&language=en"; 
    56             else 
    57                 document.location.href = this.path + this.relativePageUri + "&language=fr"; 
     54            this.requestChangeLocale(); 
    5855        }, 
    5956 
  • tapas/web/src/com/ether/Controller.java

    r402 r406  
    3535    @ControllerMethod(view = VIEW_FORM_TAPAS) 
    3636    public Map<String, Object> viewForm() 
    37             throws WebException 
    38     { 
     37            throws WebException{ 
    3938        return new HashMap<String, Object>(); 
    4039    } 
  • tapas/web/src/com/ether/ControllerEther.java

    r402 r406  
    3737        extends AbstractController 
    3838{ 
     39    /** 
     40     * This method is used to change Locale with the framework Spring 
     41     * 
     42     * @throws WebException 
     43     */ 
     44    @ControllerMethod() 
     45    public void setLocale() 
     46            throws WebException 
     47    { 
     48    } 
     49 
    3950    @Override 
    4051    @Nullable 
     
    8192            // Parse parameters 
    8293            final Object[] params = buildParams( methodDescription, request ); 
     94 
     95            if( methodDescription.isRequestMandatory() ) 
     96                params[params.length - 1] = request; 
    8397 
    8498            final Object result; 
  • tapas/web/src/messages_en.properties

    r404 r406  
    11inWork=Work in progress.. 
    22language=English 
    3 label.language.to.en=French 
    4 label.language.to.fr=English 
    5 label.language=Language 
     3label.language.to.switch=French 
     4label.language.value.to.switch=fr 
    65 
    76app.title=Tapas 
  • tapas/web/src/messages_fr.properties

    r404 r406  
    11inWork=Page en cours de construction.. 
    22language=Français 
    3 label.language.to.en=Français 
    4 label.language.to.fr=Anglais 
    5 label.language=Langue 
     3label.language.to.switch=Anglais 
     4label.language.value.to.switch=en 
    65 
    76app.title=Tapas 
Note: See TracChangeset for help on using the changeset viewer.