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

  • SEARCH
  • Home
  • 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 8678495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:44:10+00:00 2026-06-12T20:44:10+00:00

I am trying to attach normal bean validation to the blur event on a

  • 0

I am trying to attach normal bean validation to the blur event on a programmatically generated Primefaces UIComponent.

If I manually create the component using xhtml, which works fine, it looks like this:

<p:inputText id="customerName" value="#{editCustomerBean.name}" label="Name">
    <p:ajax async="true" event="blur" update="customerName, customerNameMsg" />
</p:inputText>

Unfortunately I need to generate this component on the fly because of some dynamic attributes that will be populated based on runtime data. The code I wrote to try and exactly replicate this component:

UIInput input = new InputText();

AjaxBehavior ajax = new AjaxBehavior();
ajax.setAsync(true);
ajax.setUpdate("customerName, customerNameMsg");
input.addClientBehavior("blur", ajax);
input.setId("customerName");
input.setValueExpression("value", expressionFactory.createValueExpression(elContext, "#{editCustomerBean.name}", String.class));

When I generate this component in this way, I see a request sent to the server on the blur event, but no validation takes place. The request which is posted looks identical to that which is sent when I specify the component in xhtml:

javax.faces.partial.ajax=true&javax.faces.source=mainForm%3AcustomerName&javax.faces.partial.execute=mainForm%3AcustomerName&javax.faces.partial.render=mainForm%3AcustomerName+mainForm%3AcustomerNameMsg&javax.faces.behavior.event=blur&javax.faces.partial.event=blur&mainForm%3AcustomerName=&javax.faces.ViewState=8176624577669857830%3A-4154840965136338204

I have seen similar questions posted on this website and the Primefaces forums, but it usually involves attaching a listener method to the AjaxBehavior, which is not what I am trying to do here. I would like the behavior to be the same as the tag when no listener is specified, which is to validate the field.

  • 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-12T20:44:12+00:00Added an answer on June 12, 2026 at 8:44 pm

    Turns out I was barking up the wrong tree looking at the ajax component. I realized today that my components were not being validated on submit either. It turns out that when you create your JSF components dynamically, you need to manually register the BeanValidator with the component. Thanks to victor herrera for his response to this question: https://stackoverflow.com/a/7055586/1535568

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

Sidebar

Related Questions

I am trying to attach a click event to a check box using JavaScript.
I'm trying to attach a simple focus/blur event listener via the .live() jQuery method
I am trying to attach my mdf files to SQL server (using windows XP)
I'm trying to attach an event handler to the load event of a link
I am trying to attach files in my RoR app. I am using Rails
I have been trying to attach a handler to the resize event in one
I am trying to attach files to a pdf document using iText. Files can
I'm trying to attach a function directly to a change event in jQuery, but
I am trying to attach an event to a separate onhover trigger. But I
I am trying to attach a file from from my website using pulling from

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.