tags:

views:

19

answers:

1

Hi,

I have to break the date input in a form into 3 different parts, the day, month and year. At the moment whenever there is an error in all three fields, 3 error messages are displayed. I'm wondering if there is a way to group these error messages? So if one or more fields has an error only one error message will be displayed. Alternatively is there away to check the content of the message and i can render messages only if the other messages are null

Thanks for your time.

+1  A: 

The standard JSF API does't provide this functionality. You've to look for another solution. I at least see two basic solutions:

  1. Implement a custom converter/validator which intercepts on all the three fields and just don't convert/validate when at least one field of the group has an error. You can find an example in this answer.

  2. Group all messages in some custom structure yourself in a PhaseListener during beforePhase of RENDER_RESPONSE. This however decouples your code from default JSF message handling which may lead to maintenance trouble in long term.

More detail depends on the functional requirements and what you've as far, which is yet unclear. Leave a comment with more detail whenever you need more detail.

BalusC