This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Form Level Error Messages In JSF  RSS feed

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am looking for form based error message in JSF. I have different 3 different <h:form> tags in a single jsp for 3 different sections. (I am using 3 forms becuase all three forms are independent. And having individual save functionality which checks for JSF validations if click on Save. If I use single form when i click on Save of fisrt form fires Rrquired Validations of Second Form, which is not desirable).

My form structure is like following.
<f:view>
  <h:form
   SECTION1>
  </h:form>

  <h:form
   SECTION2>
  </h:form>

  <h:form
   SECTION3>
  </h:form>
</f:view>

I Have some form level messages to show (HTML form level not page level). I am using following code to show message

FacesContext context = FacesContext.getCurrentInstance();
FacesMessage msg = new FacesMessage();
msg.setSummary(pSummary);
msg.setDetail(pDetail);
msg.setSeverity(pSeverity);
context.addMessage(null, msg);

Error message is showing in all the forms. In any way can I show form level mesages?.


 
Bartender
Posts: 19726
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only one Messages collection for any given JSF page view. The best you can do is to provide supply a component ID to your messages as you construct them and set up the messages tags in the forms to only display messages that have that ID.
 
Ramesh Kumar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

I solved my issue using h:message at each form and setting for attribute of that to Form Name.

In the controller I am using the componentId of the form to assign messages to respective form message.

- Ramesh
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!