I have code in a managed bean:
public void setTestProp(String newProp) {
FacesMessage yourFailure = new FacesMessage();
yourFailure.setDetail("Really you need to promise to never do that again!");
yourFailure.setSummary("Stop here, now!");
yourFailure.setSeverity(FacesMessage.SEVERITY_FATAL);
throw new ValidatorException(yourFailure);
}
and in the XPage:
<xp:messages id="messages1" layout="table" showSummary="false"
showDetail="true" globalOnly="false">
</xp:messages>
but I get as result message (nicely in the yellow box as expected, not in an error page):
Error setting property 'testProp' in bean of type com.ibm.sg.demo.Test: javax.faces.validator.ValidatorException: Stop here, now!
I would like to:
- not have the technical part
- see the summary
What do I miss?
The problem is that the property resolver catches all java.lang.Throwable from the get/set method of the managed beans. The “original” facesMessage is replaced with a new one (the previous message is appended).
You have three possibilities:
Hope this helps
Sven
EDIT:
How to add a validation method to your bean
a) Add a validation method to your bean
b) Add your validator to the field
(You can name the method whatever you want.)
This validator has not to be added to the faces-config.xml.