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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:19:21+00:00 2026-05-18T08:19:21+00:00

i have a simple problme. I need to catch when a user enter an

  • 0

i have a simple problme.
I need to catch when a user enter an empty string in a form and display the appropriate error message.
I’m trying with jsf required attribute, but if the user enter ” ” a string like that the validation go next without error.
I had try Spring annotation @NotNull and Hibernate @NotEmpty, but nothing solve the problem.
Any idea?

  • 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-18T08:19:21+00:00Added an answer on May 18, 2026 at 8:19 am

    I’m not sure about the Spring part, but in Hibernate you can use @NotBlank annotation for this:

    @NotBlank
    private String value;
    

    Or, you could create a JSF converter for String.class which does the job:

    package com.example;
    
    import javax.faces.component.EditableValueHolder;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import javax.faces.convert.FacesConverter;
    
    @FacesConverter(forClass=String.class)
    public class EmptyToNullConverter implements Converter {
    
        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
            if (value == null || value.trim().isEmpty()) {
                if (component instanceof EditableValueHolder) {
                    ((EditableValueHolder) component).setSubmittedValue(null);
                }
                return null;
            }
            return value;
        }
    
        public String getAsString(FacesContext facesContext, UIComponent component, Object value) {
            return (value == null) ? null : value.toString();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big problem with very simple code. I need to get a
For a few days a have some problem. I need to show simple ProgressBar
I trying to improve my skills using Try Catch blocks and better error handling.
I have a likely simple problem that I need help with. I have two
I have made a simple form with one textField and command, I want to
i'm trying to write a simple code for my project if user types walk
I have a huge array of ints that I need to sort. The catch
I have a simple little email app that allows a user to pick certain
Hi I'm trying to create a simple registration form with ajax validation. I've got
I have a very simple UI and i need to constantly run a check

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.