Hi Heath

   Actually I am to a point where I can click the checkbox and not get the 
validation errors. But there are still problems as you mentioned.

    When the page first displayed the user sees only the checkbox (unchecked) 
and will not see any other input fields. So when I check the checkbox the 
hidden button is firing its action and the other input fields are being shown 
correctly. Looks fine to the user at this point, but I am seeing conversion 
errors on the server...


SEVERE: Cannot get type for expression 
'#{manageProfileFace.spouseHelper.newSpouse.title}'
javax.faces.el.PropertyNotFoundException: Base is null
        at 
net.sourceforge.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:529)
        at 
net.sourceforge.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:226)
        at 
net.sourceforge.myfaces.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:62)
        at 
net.sourceforge.myfaces.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:186)
        at 
net.sourceforge.myfaces.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:369)
          ....
          ....
          ....
Mar 23, 2005 9:43:05 AM 
net.sourceforge.myfaces.renderkit.html.HtmlRendererUtils internalRenderSelect
SEVERE: Error finding Converter for component with id frmChangeStatus:titles


I am getting similar errors for each of the dropdown lists (selectOneListBox) 
and radio button(selectOneRadio). This is when I first checked the checkbox. 

When I click the checkbox again to hide all the input controls... I see the 
following errors on the server for each input control... and I am seeing 
Conversion Errors on the browser window.

Mar 23, 2005 9:47:46 AM net.sourceforge.myfaces.el.ValueBindingImpl getType
SEVERE: Cannot get type for expression 
'#{manageProfileFace.spouseHelper.newSpouse.title}'
javax.faces.el.PropertyNotFoundException: Base is null
        at 
net.sourceforge.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:529)
        at 
net.sourceforge.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:226)
        at 
net.sourceforge.myfaces.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:62)
        at 
net.sourceforge.myfaces.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:186)
        at 
net.sourceforge.myfaces.renderkit.RendererUtils.getConvertedUIOutputValue(RendererUtils.java:534)
          ....
          ....

The browser window shows these error messages....

o - Conversion Error titles: Conversion error occurred.
o - Conversion Error firstName: Conversion error occurred.
o - Conversion Error Last Name: Conversion error occurred.
o - Conversion Error maidenName: Conversion error occurred.
o - Conversion Error suffixes: Conversion error occurred.
o - Conversion Error preferredName: Conversion error occurred.
o - Conversion Error homePage: Conversion error occurred.

You have mentioned about setting immediate for the checkbox, I have tried that 
but no difference. You have also mentioned about value change listeners. What 
are those for? Do they solve the conversion error issue ?

Please advice...

Thanks
Srikanth


-----Original Message-----
From: Srikanth Madarapu 
Sent: Wednesday, March 23, 2005 9:11 AM
To: MyFaces Discussion; [EMAIL PROTECTED]
Subject: RE: handling the required attributes


Hi Heath

  Yes I got javascript errors. So I modified my javascritpt code to use the 
correct id for getElementById (formId:buttonId). Now it is actually calling the 
action defined by the hidden button. But the problem is I still see the same 
behavior.

I have not quite understand by what you said...

" 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."

how can that be true, whether you submit the form with a hidden button or with 
a visible control you are submitting the form and the validation will run. What 
am I missing ?


Thanks
Srikanth

-----Original Message-----
From: Heath Borders [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 22, 2005 5:38 PM
To: MyFaces Discussion
Subject: Re: handling the required attributes


Well, I'm guessing that you actually got a javascript error, so
something actually did happen.

What happened was that the javascript code didn't work because the id
you gave to the commandButton is not the id it has on the client.

You should upgrade your MyFaces version so you can use Sean's forceId
attribute, which makes client-side scripting _vastly_ easier.


On Tue, 22 Mar 2005 17:35:12 -0500, Srikanth Madarapu
<[EMAIL PROTECTED]> wrote:
> Hi Heath
> 
> Thanks for the solution... it does sound complicated, but I am trying it.
> 
> I am using version 1.0.7 of my-faces.
> 
> I have changed the onclick event of the checkbox to call the click event of 
> the command button, nothing happened. Here is part my page....
> 
>                         <h:panelGrid id="remarriedOption" columns="2" >
>                                <seniorfaces:outputLabel for="remarried"
>                                    value="some text here ?" />
>                                <h:selectBooleanCheckbox id="remarried"
>                                    immediate="true"
>                                    
> onclick="document.getElementById('hiddenBtn').click();"
>                                    
> value="#{manageProfileFace.spouseHelper.remarried}" />
>                                <h:commandButton id="hiddenBtn" 
> style="display:none;"
>                                    
> action="#{manageProfileFace.spouseHelper.flagRemarried}" />
>                            </h:panelGrid>
> 
>                            <h:panelGrid id="remarriageInfo" columns="2"
>                                
> rendered="#{manageProfileFace.spouseHelper.remarried}"
>                                styleClass="dataTableBorderAlt"
>                                rowClasses="dataCellEven,dataCellOdd"
>                                
> columnClasses="cellAlignLeftFullWidth,cellAlignLeftFullWidth"
>                                cellpadding="0"
>                                cellspacing="1">
> 
>                                <seniorfaces:outputLabel for="firstName" 
> value="First Name" />
>                                <h:inputText id="firstName" 
> required="#{manageProfileFace.spouseHelper.remarried}"
>                                    
> value="#{manageProfileFace.spouseHelper.newSpouse.firstName}">
>                                    <f:validateLength maximum="20"/>
>                                </h:inputText>
> 
>                                <seniorfaces:outputLabel for="middleName" 
> value="Middle Name" />
>                                <h:inputText id="middleName" 
> value="#{manageProfileFace.spouseHelper.newSpouse.middleName}">
>                                    <f:validateLength maximum="20"/>
>                                </h:inputText>
> 
>                                <seniorfaces:outputLabel for="Last Name" 
> value="Last Name" />
>                                <h:inputText id="Last Name" 
> required="#{manageProfileFace.spouseHelper.remarried}"
>                                    
> value="#{manageProfileFace.spouseHelper.newSpouse.lastName}">
>                                    <f:validateLength maximum="30"/>
>                                </h:inputText>
>                        ....
>                        ....
> 
>                            </h:panelGrid>
> 
> the method "flagRemarried" will toggle the flag in the backing bean. Will the 
> getElementById work with version 1.0.7 ?  What am I missing here ?  When the 
> checkbox is clicked nothing is happening.
> 
> Please reply at your convenience. I am off for the day.
> 
> 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