Simply create a new FacesMessage and add it with the following FacesContext method:
public abstract void addMessage(String clientId, javax.faces.application.FacesMessage message);


Hint: Don't forget to pass the whole clientId (full semicolon separated "path") of your component, not only the componentId.

HTH,
Manfred



E. Lefty Kreouzis wrote:
Hi,

I am trying to develop a simple web application.
This application fills in a form and tries to insert it into a table.
Sometimes the insert doesn't work because of an integrity constraint
error (duplicate value, foreign key error etc).
My question is this: in the insert method how can I report the error in
such a way that <h:message > and/or <h:messages> will pick it up and
report it as if it were a validation error?

FacesMessage instances are created in the Validator and/or Converter
classes and then thrown as exceptions. The JSF framework then catches
the exception unravels the message and somehow associates it with the
correct UIInput component so that the <h:message> and <h:messages> tags
can retrieve them and display them.

But I can't find how to associate a FacesMessage with a particular
component.

Any and all help will be much appreciated,

Thank you in advance

Lefty Kreouzis


Reply via email to