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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:50:25+00:00 2026-05-26T01:50:25+00:00

I have just created a NetBeans project with JSF 2.0 and I have a

  • 0

I have just created a NetBeans project with JSF 2.0 and I have a problem with f:validateRequired. The bean

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean
@RequestScoped
public class TestBean {
    private String value;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String action() {
        return "test";
    }
}

and the page

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Test</title>
        <h:outputStylesheet name="css/stylesheet.css" />
    </h:head>
    <h:body>
        <h:form>
            <div id="content">
                Value:
                <h:message for="test" />
                <h:inputText value="#{testBean.value}" id="test">
                    <f:validateRequired />
                </h:inputText>
                <br/>
                <h:commandButton action="#{testBean.action}" value="Action" />
            </div>
        </h:form>
    </h:body>
</html>

seems to be allright, but the h:message isn’t there until I supply the requered=”true” attribute on the inputText. What I am missing? Why the validation does not occure whithout the requered=”true” attribute?

  • 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-05-26T01:50:26+00:00Added an answer on May 26, 2026 at 1:50 am

    I figured the answer: fields with empty input are not validated at all by default. If you wish to validate such field you have to set required=true. See UIInput.validateValue() JavaDoc

    You can enable the validation of empty fields by setting the javax.faces.VALIDATE_EMPTY_FIELDS context parameter to true. See JavaDoc. After doing that the example above works as expected.

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

Sidebar

Related Questions

So I have a django project I just created called 'coolprojectsite' the directory structure
I've just upgraded to NetBeans 7.1 from 7.0. On opening a JSF managed bean
I have just created a AdHoc distribution provisioning profile for the app id 49776ZQRBG.com.gfeed.ride
I have just created a report in Report Manager using a Stored Procedure which
i have just created a drum app. The user taps on the individual buttons
I have just created a GIT on a folder. I now want to add
I have just created 2 pointers which has undefined behavior and try to invoke
Just starting out in asp.net. Have just created a login.aspx page in my site
Not a question but i dont have a blog and i have just created
I'm trying to debug the MSBuild Customtask, that I have just created, but for

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.