aspose file tools
The moose likes JSF and the fly likes Error handling JSF Form Divisions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Error handling JSF Form Divisions" Watch "Error handling JSF Form Divisions" New topic
Author

Error handling JSF Form Divisions

Ramesh Kumar
Ranch Hand

Joined: Dec 28, 2004
Posts: 33
Hello,

I have different divisions in my JSF page like (Patient Info one divison, Surgery info one division). Both divisions are there on the same form. I want to validate only one division at a time while sumbit.

What I mean is
1) Validate Pation Info Section only when user clicks save on patient Info
2) Validate Surgery Info only when user clicks save on Surgery Info

Now it is showing errors related to both sections.

Please help me.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You should place each form in its own h:form.


Code depot of a Java EE / JSF developer | JSF / Eclipse / Tomcat kickoff tutorial | DAO kickoff tutorial | I ♥ Unicode
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14456
    
    7

JSF forms are built on the HTML FORM infrastructure and therefore subject to the same basic rules. In HTML, each FORM is considered individually. When you click on the form's submit button, only data defined within that form is transmitted to the server - consequently, server-side validation is only possible for the items within that form.

In other words, not only is the behavior you're describing the default behavior, you don't even have a choice. That's how it's going to behave. And, correspondingly, if someone clicks a submit button on one form that responds with a new page, data entered in other forms on the original page will be discarded when the old page is replaced with the new page.

These days you can alter that sort of behavior by using client-side logic such as JavaScript/AJAX. Not only can you explicitly code JavaScript to peek outside forms, some of the new JSF tag libraries generate their own outside-peeking code. What they actually do is modify the DOM structure of the submit in order to include data that wasn't in the original DOM representation of the HTML form. Of course, the server has to be expecting this sort of behavior, but that's usually not hard to allow for.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://jrebel.com/download
 
subject: Error handling JSF Form Divisions
 
Similar Threads
JSF validation components !!
setting values of a bean
Multiple forms with one action class
Troubles with rich:modalPanel
Form Validation and Delete using struts