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

The Archive Base Latest Questions

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

I’m trying to display just one for two Fields that are required. At the

  • 0

I’m trying to display just one for two Fields that are required.
At the moment there are two error messages if both fields are empty. I want to achieve that there is just one message if both or just one field is empty.

The code looks like this:

<x:inputText
    value="#{bean.proxyUrl}"
    id="idProxyUrl"
    required="true"
    />
<x:outputText value=":" />
<x:inputText
    value="#{bean.proxyPort}"
    id="idProxyPort"
    required="true"
    />
<x:message for="idProxyUrl" errorClass="errorMessage" style="margin-left: 10px;" />
<x:message for="idProxyPort" errorClass="errorMessage" style="margin-left: 10px;" />

What can I do about it, that I only get one message no matter if one or both of the fields are empty.

  • 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-12T02:44:28+00:00Added an answer on June 12, 2026 at 2:44 am

    You can specify a special validator for the second component that checks the SubmittedValue of the first one. I did something similar for a PasswordValidator that checked the corresponding Confirm Password field.

    @FacesValidator("passwordValidator")
    public class PasswordValidator implements Validator {    
    
        @Override
        public void validate(FacesContext context, UIComponent component,
                Object value) throws ValidatorException {
    
    
            String password = (String) value;
    
    
            UIInput confirmComponent = (UIInput) component.getAttributes().get("confirm");
            String confirm = (String) confirmComponent.getSubmittedValue();
    
            if (password == null || password.isEmpty() || confirm == null || confirm.isEmpty()) {
                FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Please confirm password", null);
                throw new ValidatorException(msg);
            }
    
    
            if (!password.equals(confirm)) {
                confirmComponent.setValid(false); 
                FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "The entered passwords do not match", null);
                throw new ValidatorException(msg);
            }
    
    
        }
    

    The reason why you must check for the Submitted Value of the other component is because the validator is called during the Process Validations phase of the lifecycle. None of the Submitted Values are applied until after this phase has been completed and every submitted value has passed validation.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.