Bonjour,

j'ai une classe FacesUtils qui me permet de mettre à disposition des méthodes pour mes pages JSF, notamment pour le context et l'adresse du serveur, celles-ci sont déclarées en static :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
    public static String getServerURL(){
        StringBuffer serverURL = new StringBuffer();
        HttpServletRequest httpRequest = (HttpServletRequest) getExternalContext().getRequest();
        String serverName = httpRequest.getServerName();
        int serverPort  = httpRequest.getServerPort();
        String protocol = httpRequest.getScheme();
        serverURL.append(protocol);
	                serverURL.append("://");
 	                serverURL.append(serverName);
 	                if (serverPort != 0) {
 	                    if (("http".equals(protocol) && serverPort != 80)
 	                            || ("https".equals(protocol) && serverPort != 443)) {
 	                        serverURL.append(':');
 	                        serverURL.append(serverPort);
 	                    }
 	                }
 	                serverURL.append('/');
        return serverURL.toString();
    }
 
 
    public static String getContextPath(){        
         return getExternalContext().getRequestContextPath();
    }
 
    public static String getAppPath(){
        if(StringUtils.isNotEmpty(getServerURL())&& StringUtils.isNotEmpty(getContextPath())){
          return getServerURL()+getContextPath();
        }
        return "test";
    }
Ces méthodes fonctionnent parfaitement mais je n'arrive pas récupérer les valeurs dans un pages JSF via les expressions de langages #{facesutils.contextPath}...

Une idée?

Merci d'avance