0

I have defined this:

   <ui:define name="content">
        <section id="documents">
....
            <h:message for="documents" errorClass="errorc" />
        </section>

This is inside a <body><main> tags in the upper template.

Then my controller does this:

} catch (MyException e) {
            ctx.addMessage("documents", new FacesMessage(FacesMessage.SEVERITY_ERROR, "Trying to raise an error", null));
        }

But the error is not shown in the h:message. I assume I am using wrongly the target ID, but I don't know how to do it. I have tried to move the h:message outside the section but doesn't work either.

I could only make it work with general h:messages with null client ID

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user1156544
  • 1,725
  • 2
  • 25
  • 51

1 Answers1

1

From the <h:message> documentation (emphasis mine):

for

Client identifier of the component for which to display messages.

The <section> tag is a plain HTML element, not a JSF component.

Use e.g. <h:panelGroup layout="block"> component to let JSF generate a <div> element.

<h:panelGroup layout="block id="documents">

    <h:message for="documents" ... />
</h:panelGroup>

Or create a custom component generating <section>.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555