This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Sep 13, 2013, 6:38 PM
17 Posts

what is causing validation to run when my xpage is loading?

  • Category: Other Domino Designer Tooling
  • Platform: Windows
  • Release: 9.0
  • Role: Developer
  • Tags:
  • Replies: 8

Not sure what I did, but every time I load a particular xpage, it's doing SSJS field validation. What is causing this to happen?

Sep 14, 2013, 8:41 PM
453 Posts
I think you need to set the disableValidators

For example you might set the disableValidators to true if the document is not being saved. So you would have a validator of say type validateRequired on a field but it will fire when the control is refreshed, but not saved (ie you have done a partial refresh on a panel to update the display), but if you only want the validation under certain conditions ie on save then set the disableValidators to true or false.

So in the disableValidators you could do something like this

(@IsDocBeingSaved() ) ? false : true;

now your validators will only fire on a save.

Hope this helps.

Sep 16, 2013, 11:54 AM
17 Posts
I never had this problem before

Thanks Bill. There are about 50 fields that have validation on them. I've been working on this xpage (form) for a while, and it never did SSJS validation when the page is loading before.

I can't imagine that I need to write formulas for all my validated fields now.

I don't really understand why it is doing a refresh now upon loading.

Sep 17, 2013, 4:31 PM
453 Posts
How are you validating the control content

I just finished working on a control with validation on it, and under certain conditions it was part of a partial update and it would fire the validation, but the validation was not appropriate at that time. I only wanted the validation to take place if the document was being saved so used the @IsDocBeingSaved in the disableValidators property. Of course the code in the disablevalidators could be much more complex and check other controls etc.

So if your validators started to work on a partial refresh then as far as I am aware that is what is supposed to happen. This was the same case in a Notes Field on a form.

Sep 17, 2013, 6:19 PM
17 Posts
It doesn't validate when I am saving now.

I'm trying to use your formula (@IsDocBeingSaved() ) ? false : true; in the disableValidators property. It does indeed stop validation on that field when the page loads, but it doesn't run the validation when the doc is being saved.

I"m using the checkbox on the Validator tab. Should I not being doing validation that way in order for this to work?

Thanks for your help!

Sep 17, 2013, 8:51 PM
453 Posts
What I have done

Under the All Properties find the data section and expand it, then go to validators and add a validaterequired and enter the failure message. then go to the diasablevalidators and enter the formula @IsDocBeingSaved.

This works for me. If you look at the source there is no difference between checking the box on the Validation tab and entering it in the All Properties. However, you must go to the All Properties to do the disablevalidators.

Would be better if each validator had an enable/disable property rather than enable/disable all validators. This would allow some validators to stay active while others are disabled, but that is not the case.

Sep 18, 2013, 3:28 PM
17 Posts
I'm following you, but...

...still not working

    <xp:inputText
                                value="#{document1.ProjectTitle}" id="ProjectTitle"
                                styleClass="fld" style="width:230px"
                                disableValidators="#{javascript:@IsDocBeingSaved}">

                                <xp:this.validators>
                                    <xp:validateRequired
                                        message="Please enter a Project Title.">
                                    </xp:validateRequired>
                                </xp:this.validators>
                            </xp:inputText>

 

 Again, it does ignore the validation when the page loads, but it isn't running the validation when the page saves.

Could it have to do with HOW I am saving? I have a button of type "button", and Save is set to false. Then I use Events to do some other actions, like update fields, SAVE IT, and send an email.

 

Sep 19, 2013, 5:35 PM
453 Posts
I think the comparison is wrong

@IsDocBeingSaved returns true if teh document is being Saved and false otherwise

disableValidators disables the validators if true and allows them to fire if false 

so this returns true when the docuemnt is being saved

   disableValidators="#{javascript:@IsDocBeingSaved}">

I think what you need is to negate @IsDocBeingSaved:

   disableValidators="#{javascript:!@IsDocBeingSaved}">

Sep 19, 2013, 6:50 PM
17 Posts
I had tried negating the formula

I had tried negating it, but it fires when loading and when saving ; it just doesn't seem to understand that a Save is not happening when loading.

 

If I can't figure this out. I'm either going to have to build this without Xpages, which it is probably too late for, or validate every single field with CCJS, which should only cost me day.

I just don't understand why it is firing any validation upon loading. Someone suggesed to go read the JSF manual or something, but I'm developed this entire application just fine using xpages, which is new to me, and all of a sudden one small showstopper of a problem I can't get past.

 

I really appreciate your time. If you or anyone else think of any other suggestions, let me know.


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal