Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8487861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:22:15+00:00 2026-06-10T21:22:15+00:00

I’m having an issue with some server side validation and I can’t tell if

  • 0

I’m having an issue with some server side validation and I can’t tell if this is the expected behavior in XPages or if I’m missing something simple here.

I have a field that has a computed validation formula – basically, it becomes required when a viewScope variable gets set.

My submit button sets the viewScope and does a full refresh.

I would expect the form to be submitted, the validation formula gets evaluated, and if it fails the validation failure would be displayed. But when I click my submit button the form is submitted without error. If I click it again, validation fails as expected.

To illustrate my issue I created a simple example:

<xp:inputText id="inputText1" required="#{javascript:viewScope.validate}">
    <xp:this.validators>
        <xp:validateRequired message="This field is required."></xp:validateRequired>
    </xp:this.validators>
</xp:inputText>
&#160;
<xp:button value="Submit" id="button1">
    <xp:eventHandler event="onclick" submit="true"
        refreshMode="complete" immediate="false" save="true">
        <xp:this.action><![CDATA[#{javascript:viewScope.validate=true;}]]></xp:this.action>

        <xp:this.script><![CDATA[dojo.attr(dojo.byId("#{id:inputText1}"),"aria-required","true")]]></xp:this.script>
    </xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:message id="message1" for="inputText1"></xp:message>

As you can see, I also tried adding the aria-required attribute with csjs within the button in the hopes it would initiate validation.

If validation is working as expected are there any suggestions for getting dynamic validation like this to function properly? I know I can do something with querySave on the data source (I excluded a data source from the example for simplicity) but was hoping there is a simpler solution than that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:22:17+00:00Added an answer on June 10, 2026 at 9:22 pm

    It looks like the problem is misunderstanding the lifecycle. You’re specifying whether the field is required in a viewScope variable. When the page is first loaded, the viewScope is false, so the field is not required. After you submit, the viewScope variable is set, the page rendered again. Only now does the field become required, but it is only required the next time the form is submitted.

    If you want the field to be required, you’ll need the required property to be evaluated to true and passed to the browser before the form is submitted.

    There are a number of alternatives for the functionality you’re trying to manage, running SSJS and failing if certain criteria are met.

    One is to use the validator property rather than calculating the required property. The validator allows you to run code but you will need to use this.getSubmittedValue() to check the field’s value – the validator runs earlier in the lifecycle before the submittedValue is passed to the value property.

    The second option is to put the validation in the Submit button. You can use facesContext.addMessage(). If you google xpages facesContext addMessage there are plenty of examples of how to do it. Then do “return false” to abort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.