If you make an action immediate, it means that it won't run validation
on any of the fields.  If you make a field immediate, it means that
its validation will run, even if an action is immediate.

Does that help?

On Wed, 23 Mar 2005 10:41:28 -0500, Srikanth Madarapu
<[EMAIL PROTECTED]> wrote:
> The solution is working, but I don't know why and how. Can you please explain 
> me ?
> 
> Why not the checkbox not working, even if I set it's immediate to true ?  Is 
> it related to making the controls hidden or visible ?
> 
> Thanks
> Srikanth
> 
> -----Original Message-----
> From: Srikanth Madarapu
> Sent: Wednesday, March 23, 2005 10:33 AM
> To: 'MyFaces Discussion'; '[EMAIL PROTECTED]'
> Subject: RE: handling the required attributes
> 
> Hi Heath
> 
>  Thanks a lot for the idea. Your solution ( actually only part of it ) is 
> working for me. I have added the hidden button with an action. The checkbox 
> is not bound to any attribute in the backing bean. I have set immediate to 
> true for the checkbox and the hidden button. And it is working. I have not 
> added any other code. Without setting the immediate for the hidden button I 
> was still getting validation errors but was able to hide or show the detail 
> panel. After setting the immediate to true for the hidden button I am not 
> getting the validation errors either.
> 
>  I am not done implementing the actual business logic yet, but I hope I will 
> not see any other errors that you were expecting.
> 
> Thanks
> Srikanth
> 
> -----Original Message-----
> From: Heath Borders [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 22, 2005 5:02 PM
> To: MyFaces Discussion
> Subject: Re: handling the required attributes
> 
> Just to preface, this solution is a bit complicated.
> 
> First, you shouldn't do a form submit when the user clicks the
> checkbox.  You should create an immediate commandButton and set its
> style to "display: none;".  This will hide it from the user, but still
> allow you to use it to generate ActionEvents.
> 
> When the user clicks the checkbox, you do a
> "document.getElementById('myCommandButton').click();", which will
> submit the form using your commandButton.
> 
> This will allow the user to uncheck the checkbox without having validation 
> run.
> 
> However, now you will have other problems:
> All UIInputs on the form will not be validated, so none of their
> values will get push to the models.  You can solve this problem by
> making the UIInputs you want to go through to the models (probably
> just your checkbox) immediate as well.  This will get them through
> their process validators phase.  Additionally, you have to register a
> ValueChangeListener on those UIInputs that will call the UIInput's
> updateModelValues() method.
> 
> Finally, you have to traverse the JSF tree and clean all the
> submittedValues/values from all UIInputs, or else they will not
> properly pull from their models on the fresh request.
> 
> I said it would be complicated :-)
> 
> On Tue, 22 Mar 2005 16:13:50 -0500, Srikanth Madarapu
> <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> >  I have a page with a check box and few input fields in a panelGrid. The 
> > panelGrid is rendered based on whether the checkbox is selected or not. 
> > Initially when the page is rendered the checkbox is not selected and the 
> > panel is not rendered, when the checkbox is selected,  the form will be 
> > submitted with onclick="submit();" , and the panel is rendered.
> >
> > The panel has couple of required fields. After the panel is rendered, the 
> > user may want to uncheck the checkbox, in which case the form will be 
> > submitted again. If the user unchecks the checkbox without entering any 
> > data in the required fields, the validation errors are generated, but the 
> > user want to turn off the panel and the user need not enter any data in the 
> > required fields.
> >
> > But because whenever the form is submitted the frame work will check for 
> > required fields and throw validation errors. How can I bypass this 
> > validation, I want to allow the user to uncheck the checkbox without 
> > entering any values in the required fields.
> >
> > The only way I can think of enforcing the required fields is to validate 
> > the data when the form is submitted and not use the required attribute for 
> > those required fields.
> >
> > TIA.
> > -Srikanth Madarapu
> >
> >
> 
> --
> -Heath Borders-Wing
> [EMAIL PROTECTED]
> 


-- 
-Heath Borders-Wing
[EMAIL PROTECTED]

Reply via email to