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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:44:54+00:00 2026-05-16T22:44:54+00:00

I am setting up a form using JSF (I’m pretty new at this) and

  • 0

I am setting up a form using JSF (I’m pretty new at this) and I am getting a Validation Error: Value is not valid message on one of the fields. This field is actually a separate object (as I will show below) that has a custom converter.

Here is what I have (with non-relevant code removed):

I have a Citation class:

@ManagedBean(name="citation")
public class Citation {
    private int id;
    private Status status;

    // getters and setters
}

I also have a Status class that you see referenced in the Citation class:

@ManagedBean(name="status")
public class Status {
    private int id;
    private String name;

    // getters and setters

    public List<Status> getAllStatuses() {
        Session session = HibernateUtil.getCurrentSession();
        session.beginTransaction();
        session.clear();

        Query query = session.createQuery("from Status");
        List<Status> statuses = query.list();

        try {
            session.getTransaction().commit();
        } catch (HibernateException e) {
            // TODO: handle exception
            session.getTransaction().rollback();
        }

        return statuses;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;
        if (!(obj instanceof Status)) return false;

        if (this.id == ((Status)obj).getId()) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return this.name.hashCode();
    }
}

Then for my form, I have:

<h:selectOneMenu id="citation_status" value="#{citation.status}">
    <f:selectItems value="#{status.allStatuses} var="s" itemValue="#{s.id}" itemLabel="#{s.name}" />
</h:selectOneMenu>
<h:message for="citation_status" />

Lastly, for my converter, I have:

@FacesConverter(forClass=Status.class)
public class StatusConverter implements Converter {
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        // uses Hibernate to get the Status object (using a breakpoint in Eclipse, I have verified that this works)
        // I can post this code if needed, but just trying to keep it short :)
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        return String.valueOf(((Status) value).getId());
    }
}

Now when I get to my form and submit, I get the Validation Error next to the Status. I’m pretty new at this and thanks to @BalusC, I’m this far along.

Any help is greatly appreciated.

  • 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-16T22:44:54+00:00Added an answer on May 16, 2026 at 10:44 pm

    Validation Error: Value is not valid

    In case of <h:selectOneMenu>, you will get this when error whenever the selected item does not match any of the items available in the list. I.e. selectedItem.equals(selectItem) has never returned true for any of the items.

    Since it’s apparently a custom object (the Status class), did you implement its Object#equals() (and #hashCode()) properly? You can if necessary let the IDE (Eclipse/Netbeans) autogenerate them.

    See also:

    • Overriding equals and hashCode in Java
    • How to implement equals() in beans/entities

    Update: after having a closer look at your code, it turns out that you’re actually submitting #{s.id} instead of #{s} (the whole Status object). Fix the itemValue accordingly and it should work (if equals() is still doing its job properly).

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

Sidebar

Related Questions

I am setting up a dns lookup form using dns_get_record. I set it up
How to set the classpath using a java program without setting it form command
The Setting: The program in question tries to post form data via an AJAX
JSF is setting the ID of an input field to search_form:expression . I need
If I am setting the Text property of a Form from a non-UI thread,
Setting up an integration server, I’m in doubt about the best approach regarding using
When setting up a new virtual directory for hosting a SOAP web service in
I am displaying a new Form from one process by passing the Show method
I've been trying to set the value of a hidden field in a form
How can I refresh or reload a form using JQuery? I am filling my

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.