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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:04:46+00:00 2026-06-04T01:04:46+00:00

I have this SelectOneMenu: <h:selectOneMenu value=#{orderController.requestVO.requestSituation}> <f:converter converterId=ComboConverter/> <f:selectItems value=#{orderController.requestSituation} var=requestSituation itemLabel=#{requestSituation.description} itemValue=#{requestSituation} />

  • 0

I have this SelectOneMenu:

<h:selectOneMenu value="#{orderController.requestVO.requestSituation}">
    <f:converter converterId="ComboConverter"/>
    <f:selectItems value="#{orderController.requestSituation}" var="requestSituation"
                                                   itemLabel="#{requestSituation.description}" itemValue="#{requestSituation}" />
</h:selectOneMenu>

The requestSituation is a ArrayList filled with RequestSituationVO
It is populated correctly, generating this HTML:

<select name="j_idt14:j_idt20" size="1">
        <option value="13">Pedido Recusado</option>
    <option value="11">Pedido Validado</option>
    <option value="12" selected="selected">Pedido Confirmado</option>
    <option value="12" selected="selected">Pedido Faturado</option>
</select>

I have this Converter and here is where I’m confused, I’ve read a lot and I know what it has to do but not how it works.

Here it is:

@FacesConverter(value = "ComboConverter", forClass = RequestSituationVO.class)
public class ComboConverter implements Converter
{

    private static RequestSituationVO requestSituationVO = new RequestSituationVO();

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value)
    {
        requestSituationVO.setId(Integer.valueOf(value));
        requestSituationVO = (RequestSituationVO) new RequestSituationBO().getRequestSituation(requestSituationVO).toArray()[0];
        return (RequestSituationVO) requestSituationVO;
    }

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

When I submit my page, I think the SelectOneMenu will automatically set the value for the requestSituation method from requestVO. But when I submit, I get a message Value not valid referencing to my SelectOneMenu.

What I need is to set the selected value on my RequestSituationVO so I can send it to the Business method.

  • 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-04T01:04:47+00:00Added an answer on June 4, 2026 at 1:04 am

    Your converter is fine. You would otherwise have gotten a conversion error something like

    Conversion Error setting value ‘com.example.RequestSituationVO@hashcode’ for ‘null Converter’

    You’ve a validation error. This particular one will be thrown when the Object#equals() test of the selected item hasn’t returned true for any of the available items in the list. JSF is checking that to prevent attacks by tampered requests. This can in your particular case have the following causes:

    • The equals() method of the RequestSituationVO class is missing or broken.
    • The #{orderController.requestSituation} has incompatibly changed in between the request of displaying the form and the request of processing the form submit.

    I think that it’s the former. Given the fact that your RequestSituationVO has an Integer id property which uniquely identifies the object, this should do:

    @Override
    public boolean equals(Object other) {
        return (other instanceof RequestSituationVO) && (id != null)
            ? id.equals(((RequestSituationVO) other).id)
            : (other == this);
    }
    
    @Override
    public int hashCode() {
        return (id != null)
            ? (this.getClass().hashCode() + id.hashCode())
            : super.hashCode();
    }
    

    If the equals() method is not the problem, then it’s the latter cause. This can be solved by making sure that the #{orderController.requestSituation} returns exactly the same list during displaying the form and processing the form submit. This can be achieved by placing the bean in the view scope and not doing the business logic in the getter at all. Or if it actually represents applicationwide data, you could refactor it to a separate application scoped bean.

    See also

    • Our selectOneMenu wiki page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this menu: <h:selectOneMenu value=#{ApplicationController.settings['SessionTTL']}> <f:selectItem itemValue=60 itemLabel=1 hour /> <f:selectItem itemValue=30 itemLabel=30
I have problems with SelectOneMenu. I write this: <h:selectOneMenu id=listaEstados styleClass=comboboxStyle value=#{detalleSistemaBean.sistema.indEstado} immediate=true> <f:selectItems
i have a selectOneMenu with selectitems. if i use <f:selectItem itemValue=3 itemLabel=#{hrBundle['phoneType3']}/> it works
Here is my jsp: <h:selectOneMenu value=#{member.dependentName} onchange=this.form.submit() immediate=true valueChangeListener=#{member.getDependentAddress}> <f:selectItems value=#{member.dependentList} /> </h:selectOneMenu> <h:inputText
I have a selectOneMenu that displays some different stuff categories: <h:selectOneMenu value=#{searchController.selectedCategory}> <f:selectItems value=#{searchController.formatedCategories()}
here is an example : <h:outputLabel for=category1 value=Cateogry/> <h:selectOneMenu id =category1 value=#{articleManageBean.categoryId1} converter=categoryConverter> <f:selectItems
I have this selectOneMenu that asks for something, the default value is empty, because
I have a IceFaces-form and several input fields. Let's say I have this: <ice:selectOneMenu
I have a custom converter to select a Country in a SelectOneMenu component: File:
Hi i have created a custom converter in jsf for combo box using h:selectOneMenu,

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.