我有这堂课:
@Getter
@Setter
public class Notification implements Serializable{
private String color;
private String message; //contains an error code
private Boolean active;
}
然后我有这两个文件:
宣布:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<locale-config>
<default-locale>fr</default-locale>
<supported-locale>fr</supported-locale>
<supported-locale>en</supported-locale>
</locale-config>
<resource-bundle>
<base-name>com.cogepat.template</base-name>
<var>msg</var>
</resource-bundle>
</application>
</faces-config>
这是我的问题:现在我有一个包含“红色”,“ERRdon”的通知对象,为真。 我如何在JSF代码中打印对应于“ERRdon”的字符串?
Usualy我会做
<h:outputText value="#{msg.ERRdon}:" />
但是我不能这样做。
<h:outputText class="rt" value="#{msg[BeanName.n.message]}" />
正在运作
答案 0 :(得分:0)
我有这个片段用于从包中发送jsf消息,我希望它有效:
public static void addNewFacesMessageFromBundle(FacesContext facesContext,
FacesMessage.Severity severity, String clientId, String key, Object[] summaryArgs,
Object[] detailArgs) {
String bundleName = facesContext.getApplication().getMessageBundle();
Locale locale = facesContext.getViewRoot().getLocale();
if (bundleName == null) {
bundleName = Constantes.DEFAULT_CUSTOM_FACES_MESSAGE_BUNDLE_NAME;
}
ResourceBundle bundle = ResourceBundle.getBundle(bundleName, locale);
String summary = bundle.getString(key);
String detail = bundle.getString(key + "_detail");
summary = MessageFormat.format(summary, summaryArgs);
detail = MessageFormat.format(detail, detailArgs);
JsfUtils.addNewFacesMessage(facesContext, clientId, severity, summary, detail);
}