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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:41:18+00:00 2026-06-16T19:41:18+00:00

I have a h:selectOneListbox which has the attribute required=true . Client side validation with

  • 0

I have a h:selectOneListbox which has the attribute required="true". Client side validation with a4j:ajax works fine.

If a valid selection is done, another panelgroup is rendered.

Example:

<h:selectOneListbox 
....
id="first" 
....
 required="true"
>
<a4j:ajax event="valueChange"  render="secondGroup" listener="#{myController.anotherMethodINeed}"/>
</h:selectOneListbox>

<!-- the other panel -->


<h:panelGroup id="secondGroup" layout="none">
     <h:panelGroup id="secondGroupCheck" layout="none" rendered="#{not empty model.first}">

     </h:panelGroup>
</h:panelGroup>

This also works.

Here’s the problem:

If the user now selects a illegal value on the first select box (like an empty one), then input is validated on client side. Hence the information never makes it to the model. After the first valid input, the panel is always rendered. There is no way to make it disappear again, since the server does not know of the change.

The only workaround I know is to make a custom validator for such a field. The validator sets then a flag if the panel needs to be rendered. This flag can then be used to decide if the panelgroup should be rendered.

Is there not a smarter way to do this?

I know that I can use something like rendered="#{not facesContext.validationFailed}" to check all the field, but I do not know a method to check just one 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-16T19:41:19+00:00Added an answer on June 16, 2026 at 7:41 pm

    If an UIInput component throws a ValidatorException during validations phase, then JSF will automatically call UIInput#setValid() with false. This thus means that you can use UIInput#isValid() in the view to check if the particular component has passed validation or not.

    You can use the binding attribute to bind an UIInput component to the view and then access all its properties the usual EL way.

    <h:selectOneListbox id="first" binding="#{first}" ... required="true">
        ...
        <a4j:ajax listener="#{myController.anotherMethodINeed}" render="secondGroup" />
    </h:selectOneListbox>
    
    <h:panelGroup id="secondGroup">
        <h:panelGroup id="secondGroupCheck" rendered="#{not empty model.first and first.valid}">
            ...
        </h:panelGroup>
    </h:panelGroup>
    

    By the way, the layout="none" is an invalid attribute for <h:panelGroup>, so I omitted it. Also, the event="valueChange" is the default already for <a4j|f:ajax> inside UIInput components, so I omitted it.

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

Sidebar

Related Questions

I have a p:selectOneListbox within an h:form but without the value attribute becuase I
Have a linking (or ref) table which has a dual primary key. Need to
I have JSF 1.1 page in which I have a <h:selectOneListbox . When I
Have a fun issue with sharepoint calendar view filtering. That code works fine: SPSecurity.RunWithElevatedPrivileges(delegate()
have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have deployed numerous report parts which reference the same view however one of them
Have a SQL problem, adding this model all works correctly, the problem is in
Have such user_session model: class UserSession < Authlogic::Session::Base logout_on_timeout true # default if false
Have a simple form that has a PictureBox in one location. I want to

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.