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 8136289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:42:52+00:00 2026-06-06T10:42:52+00:00

In my JSF application I am trying to put some conditions in my Command

  • 0

In my JSF application I am trying to put some conditions in my Command button update attribute so that on validation failure/Success I can control the components to update.

With reference to PrimeFaces: conditional update on validation I tried to to use

<p:commandLink process="@form" listener="#{foo}" 
  update="somethingElse" oncomplete="if (!args.validationFailed) $("#link").click();">
<p:commandLink style="display:none" id="link"
  update="something">

But I don’t know why this approach is not working for me.. click event of that particular component is not working for me.. I tried to execute the accepted answer for the same question , but I could not understand how that solve the purpose…

My purpose is to update conditionally depending on the result of the validation success or failure… Support I have 3 components X Y Z.. I am trying to do something like this..

<p:commandLink process="@form" listener="#{foo}" 
      update="if(Validation fail)updateSomething[e.g X and Y] **else** update somethingelse[e.g X  Y and Z]">

To be more precise if the validations fails then I want to update X and Y component only if validations succeed than I want to update X Y & Z components..

Kindly help me out..
Thanks in advance.

  • 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-06T10:42:53+00:00Added an answer on June 6, 2026 at 10:42 am

    The first problem is that the EL syntax which you’ve there is invalid. You’re closing the attribute value too soon by using " instead of ' in the JavaScript code. Either escape nested quotes with \" or just use ' instead.

    <p:commandLink process="@form" listener="#{foo}" update="somethingElse" 
        oncomplete="if (!args.validationFailed) $('#link').click();">
    

    The second possible problem is that the client ID of the <p:commandLink id="link"> is not "link" at all. It’s by default prepended with the ID of the parent <h:form> component. The client ID is the JSF-generated HTML element ID. Open the page in webbrowser, rightclick and View Source to see it yourself. It’ll look something like id="formId:link". You need to use exactly that ID in the jQuery selector.

    <p:commandLink process="@form" listener="#{foo}" update="somethingElse" 
        oncomplete="if (!args.validationFailed) $('#formId\\:link').click();">
    

    See also:

    • How to select JSF components using jQuery?

    An alternative is to perform the concrete job in the method behind listener="#{foo}" instead.

    if (!facesContext.isValidationFailed()) {
        RequestContext.getCurrentInstance().update("somethingElse");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying with limited success to code a JSF application. In one
I'm creating a JSF 2-application and I'm trying to use form validation in the
I was trying out a simple JSF application, in which I need to check
I'm trying to create an Hello World JSF application. I have a bean with
I am trying to deploy a JSF (Primefaces) application in JBOSS 7.1.0. I am
I have a JSF application that uses mostly Richfaces. I would like to introduce
I'm trying to build JSF application and I'm using hibernate as ORM solution. The
I'm trying to build a POC to migrate a heavy JSF application to a
I'm trying to move and old JSF v1.0 application from Sun One to Jboss
I'm developing a JSF 2.0 application on Glassfish v3 and i'm trying to handle

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.