tag:blogger.com,1999:blog-7110614371420404415.post1514276611002701307..comments2023-05-10T23:34:14.549-06:00Comments on Discussions and Tutorials on Software Development: Running actions despite validation errorsAnonymoushttp://www.blogger.com/profile/12230997086550680222noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-7110614371420404415.post-31301059385734580302009-07-05T06:35:10.759-06:002009-07-05T06:35:10.759-06:00Hey Andrew,
I've been working of a solution f...Hey Andrew,<br /><br />I've been working of a solution for this problem myself.<br /><br />What I found was that the real problem is the required attribute. When there is real invalid data in the form, validation should fail and it would actually be a bad thing if your action should execute.<br /><br />My solution was a custom UICommand which simply switches the required=true to required=false on all fields in the form during the validation phase. This gives you best of both worlds; first, a pretty good validated model (only required is bypassed) and a guarantee that the action is executed.<br /><br />See: http://code.google.com/p/jsf-nonvalidating-command/Jan-Kees van Andelhttps://www.blogger.com/profile/17021653712422024056noreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-85943846202497954852006-06-22T01:12:00.000-06:002006-06-22T01:12:00.000-06:00Hi, i had a similar problem that i could solve wit...Hi, i had a similar problem that i could solve with your solution. Thanx a lot for this posting!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-69134402787907027732007-03-07T05:22:00.000-07:002007-03-07T05:22:00.000-07:00This could be what I'm looking for however, the co...This could be what I'm looking for however, the code you've posted has duplicate method names and can't compile. What should the correct code be?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-41264894626373222902007-04-05T16:46:00.000-06:002007-04-05T16:46:00.000-06:00You definitely get a digg for that, I am sure I wi...You definitely get a digg for that, I am sure I will need that one day, although it doesn't quite fit my current issue..<br><br>Thanks for posting this!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-10814946756418777772007-05-03T18:30:00.000-06:002007-05-03T18:30:00.000-06:00Could you please post a war file with your entire ...Could you please post a war file with your entire project? Using this code snippet, I can't get the action & actionListener methods on the UICommand component (HTMLCommandButton in my case) to fire when wrapped with the custom validationAction component, even though the debugger stops in the validationAction component's queueEvent method, and the HTMLCommandButton is the event.getSource(). It's like the validationAction component is masking out the action/actionListener methods of the child component. I did have to code a tld file for the validationAction component (I don't know how to make Facelets "see" a "naked" component named my:validationAction without some tag information). Your war file could point me in the right direction. Thanks for pioneering an outstanding technique to help manage the (somewhat unwieldy) JSF lifecycle ??Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-68593207157652051992007-05-04T09:11:00.000-06:002007-05-04T09:11:00.000-06:00What you see is what you get. I didn't end up usin...What you see is what you get. I didn't end up using this technique, so I don't have any more code to share than is already in this blog. I'm not sure why you are not seeing it working. The code doesn't do anything special, so what happens is all JSF core: (1) queueEvent is called during processDecodes of the HtmlCommandButton by either the button or its renderer. (2) My code changes the phase ID of the event. (3) UIViewRoot calls broadcast to the component of the event (the command button).<br><br>Now the only way for the event to not fire is if the events get cleared before the right phase. That would mean it was aborted.<br><br>I would recommend using a debugger to debug into UIViewRoot and step through the event broadcasting (the lifecycle too)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-54310033675963765402007-07-27T07:23:00.000-06:002007-07-27T07:23:00.000-06:00Hi,Thanks for this tip.However, there is a problem...Hi,<br><br>Thanks for this tip.<br><br>However, there is a problem here:<br>With your component, my action on the table is indeed executed, but also all other validations of the form.<br>Thus, if I have a mandatory field that is empty, when I click on "Delete a row" button, the row will be removed, but a message will be displayed (in case I use <h:messages/> component, of course).<br><br>Another solution is to use Ajax4JSF framework:<br>On my table, I create this button:<br><a4j:commandButton bypassUpdates="true" reRender="myDataTableId" .../><br><br>With this code, the action on the table will be executed, and my table will be updated. In fact, it is not perfect as the validation of fields will also be performed, but the messages will not be displayed to the user as only the datatable is rerendered by Ajax4JSF.<br><br>Thanks anyway for your tip.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-87676086385575478572007-08-23T06:23:00.000-06:002007-08-23T06:23:00.000-06:00Hi,Your solution saved me from throwing my PC thro...Hi,<br><br>Your solution saved me from throwing my PC through the windows ;-)<br><br>Thanks a lot!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-23951738703929650812007-08-23T09:10:00.000-06:002007-08-23T09:10:00.000-06:00Glad to help. FYI, it is always good to keep "Wind...Glad to help. FYI, it is always good to keep "Windows" far away from computers.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-69087566476456506582008-08-12T15:12:00.000-06:002008-08-12T15:12:00.000-06:00Hi Andrew,This is something very similar to what I...Hi Andrew,<br><br>This is something very similar to what I've been struggling with. Thanks for the idea. But, because I'm fairly new to JSF, I've got a question about the 'my:validateAction' tag. How did you link the 'my' namespace to your UIValidationActionPhase class?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-87375281939543359222008-08-12T16:36:00.000-06:002008-08-12T16:36:00.000-06:00@Steve - I would recommend a JSF tutorial on creat...@Steve - I would recommend a JSF tutorial on creating components.<br><br>Facelets documentation has information on creating taglib.xml files. For JSP, you need to create a tag class and a TLD file.<br><br>You can try MyFaces code (see the tomahawk demo for example), or use a demo app like faces goodies:<br><a href="http://code.google.com/p/facesgoodies/" rel="nofollow">http://code.google.com/p/facesgoodies/</a>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7110614371420404415.post-41667972427003011202008-08-13T13:40:00.000-06:002008-08-13T13:40:00.000-06:00Hi Andrew,Thanks for the hints. It's working now ...Hi Andrew,<br><br>Thanks for the hints. It's working now and seems to be a fix for our issue. This has been a good learning experience.<br><br>SteveAnonymousnoreply@blogger.com