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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:08:36+00:00 2026-06-04T07:08:36+00:00

I have a simple request scoped entity / pojo which has a Enum and

  • 0

I have a simple request scoped entity / pojo which has a Enum and a String as properties.

public Enum Type
{
    None,
    Email,
    Fax;
}

@ManagedBean(name = "testEntity")
@RequestScoped
public class TestEntity
{
    private Type type; //Default = None
    private String address;

    //getter and setter
}

This Enum has a field ‘Email’ which identifies a e-mail address with a related address.
In JSF I now want to enable/disable a validator of a address InputText field regarding the currently selected type in a SelectOneMenu.

<h:form id="formId">
    <p:selectOneMenu id="type" value="#{testEntity.type}>
        <p:ajax event="change" update=":formId:address"/>
        <f:selectItem itemLabel="E-mail" itemValue="Email"/>
        <f:selectItem itemLabel="Fax" itemValue="Fax"/>
    </p:selectOneMenu>
    <p:inputText id="address" value="#{testEntity.address}">
        <f:validator validatorId="emailValidator" disabled="#{testEntity.type != 'Email'}"/>
    </p:inputText>
    <!-- button to call bean method with testEntity as param -->
</h:form>

It is not working the validator is never active but the ajax call is working since I can see the change value in other fields.

  • 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-04T07:08:37+00:00Added an answer on June 4, 2026 at 7:08 am

    That’s unfortunately not possible. The <f:xxx> tags are taghandlers (not UI components) which run during view build time, not during view render time. So if it’s disabled during building of the view, it’ll always be disabled until the view is recreated (e.g. by new request or a non-null navigation).

    You’d need to have a “global” validator which delegates further to the desired validator based on the type attribute.

    E.g.

    <p:inputText ... validator="#{testEntity.validateAddress}" />
    

    with

    public void validateAddress(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        if (type == Email) {
            context.getApplication().createValidator("emailValidator").validate(context, component, value);
        }
    }
    

    Update OmniFaces has recently added a new <o:validator> tag which should solve exactly this problem as follows:

    <o:validator validatorId="emailValidator" disabled="#{testEntity.type != 'Email'}"/>
    

    See the showcase example here.

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

Sidebar

Related Questions

I have a simple jquery/ajax request to the server which returns the structure and
I have a simple authorization page which intends the user to type login and
I have a very simple ajax request: $.get(url, data) .done(function () { }) .fail(function
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package in which On Error event handler I have created
I have simple code that does a head request for a URL and then
I have a very simple managed bean LOB which is used for reading existing
I have the following simple view main.xhtml , the request URL would be something
I have following two simple POJOs: class Person { String name Address address; //and

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.