<h:message for="foo"> 似乎不适用于 <section id="foo">
<h:message for="foo"> does not seem to work on <section id="foo">
我定义了这个:
<ui:define name="content">
<section id="documents">
....
<h:message for="documents" errorClass="errorc" />
</section>
这在上层模板的 <body><main>
标签内。
然后我的控制器会这样做:
} catch (MyException e) {
ctx.addMessage("documents", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Trying to raise an error", null));
}
但是h:message
中没有显示错误。我假设我错误地使用了目标 ID,但我不知道该怎么做。我试图将 h:message
移到该部分之外,但也不起作用。
我只能让它与 general h:messages with null client ID
一起使用
来自 <h:message>
documentation(强调我的):
for
Client identifier of the component for which to display messages.
<section>
标签是一个普通的 HTML 元素,而不是 JSF 组件。
使用例如<h:panelGroup layout="block">
组件让 JSF 生成 <div>
元素。
<h:panelGroup layout="block id="documents">
<h:message for="documents" ... />
</h:panelGroup>
或创建自定义组件生成 <section>
。
我定义了这个:
<ui:define name="content">
<section id="documents">
....
<h:message for="documents" errorClass="errorc" />
</section>
这在上层模板的 <body><main>
标签内。
然后我的控制器会这样做:
} catch (MyException e) {
ctx.addMessage("documents", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Trying to raise an error", null));
}
但是h:message
中没有显示错误。我假设我错误地使用了目标 ID,但我不知道该怎么做。我试图将 h:message
移到该部分之外,但也不起作用。
我只能让它与 general h:messages with null client ID
一起使用来自 <h:message>
documentation(强调我的):
for
Client identifier of the component for which to display messages.
<section>
标签是一个普通的 HTML 元素,而不是 JSF 组件。
使用例如<h:panelGroup layout="block">
组件让 JSF 生成 <div>
元素。
<h:panelGroup layout="block id="documents">
<h:message for="documents" ... />
</h:panelGroup>
或创建自定义组件生成 <section>
。