Hello,
Je tente de récupérer mon texte d'un message bundle en lui passant des valeurs {0} et {1}
Dans le code je le fais de cette manière
Ou la méthode de récupération de la clef du message bundle est la suivante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 /** * Gets the libelle of the Jalons */ public String getLibelle() { LOG.debug("GET LIBELLE : " + Utils.getMessageResourceString("milestones", jalons.getClef() + ".libelle", new String [] {jalons.getDate(), jalons.getDecision()}, FacesContext.getCurrentInstance().getViewRoot().getLocale())); return Utils.getMessageResourceString("milestones", jalons.getClef() + ".libelle", new String [] {jalons.getDate(), jalons.getDecision()}, FacesContext.getCurrentInstance().getViewRoot().getLocale()); }
Mais lorsque j'affiche le résultat les variables ne sont pas substitués
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 public static String getMessageResourceString(String bundleName, String key, Object params[],Locale locale){ String text = null; ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale, getCurrentClassLoader(params)); try{ text = bundle.getString(key); } catch(MissingResourceException e){ text = "?? key " + key + " not found ??"; } if(params != null){ MessageFormat mf = new MessageFormat(text, locale); text = mf.format(params, new StringBuffer(), null).toString(); LOG.debug("getMessageResourceString (WITH PARAM " + text); } return text; }
Une idée ?
Partager