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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:01:00+00:00 2026-06-16T04:01:00+00:00

Possible Duplicate: Why selectOneMenu Send ItemLabel to the converter? I have a JSF page

  • 0

Possible Duplicate:
Why selectOneMenu Send ItemLabel to the converter?

I have a JSF page with two p:selectOneMenu on it which both represent pretty simple entities.

ListType entity:

@Entity
@Table( name = "LISTTYPES" )
@NamedQueries
(
    {
        @NamedQuery( name  = "...",
                     query = "SELECT lty " +
                             "FROM ListType lty " +
                             "WHERE lty.name = :name "),
    }
)
public class ListType implements ClientDependent, Serializable
{
    @Id
    @Column( name = "LISTTYPE_ID" )
    private Long               id;

    @Basic( optional = false )
    @Column( name = "LIST_NO" )
    private Long               nbr;

    @Basic( optional = false )
    @Column( name = "LIST_NAME" )
    private String             name;

    @Column( name = "LIST_DESC" )
    private String             description;

    ...
}

MonitoringReason entity:

@Entity
@Table( name = "MONITORINGREASONS" )
@NamedQueries
(
    {
        @NamedQuery( name  = "...",
                     query = "SELECT mtr " +
                             "FROM MonitoringReason mtr " +
                             "WHERE mtr.code = :code"),
    }
)
public class MonitoringReason implements Serializable
{
    @Id
    @Column( name = "MONITORINGREASON_ID" )
    private Long               id;

    @Basic( optional = false )
    @Column( name = "MONITORINGREASON_NO" )
    private String             code;

    @Basic( optional = false )
    @Column( name = "MONITORINGREASON_NAME" )
    private String             name;

    @Basic( optional = false )
    @Column( name = "MONITORINGREASON_DESC" )
    private String             description;

    ...
}

Simple entities. Note, I omitted the equals + hashCode methods, which both entities implement correctly.

Here’s some example data:

List type data:

LISTTYPE_ID  LIST_NO  LIST_NAME           LIST_DESC
      1         3       'WL'        'Watch List'
      0         4       'RL'        'Restricted List'
      2         5       'Emb'       'Embargo'
      7         7       'NRL'       'Not Recommended List'
   5009        14       'GWL'       'Global Watch List'
   5010        15       'GRL'       'Global Restricted List'
   5011        16       'PIL'       'Permanent Insider List'

Monitoring reason data:

MONITORINGREASON_ID  MONITORINGREASON_NO  MONITORINGREASON_NAME  MONITORINGREASON_DESC
        3                   'Ah'           'Ad-Hoc'              'Ad-Hoc'
        6                   'Al'           'Autom. Liste'        'Automatische Liste'
        4                   'Be'           'Beobachtung'         'Beobachtung'
        7                   'CLC'          'Limit Changes'       'Limit Changes'
        1                   'Fus'          'Fusion'              'Fusion'
        5                   'Li'           'Liste'               'Liste'
        2                   'Res'          'Research'            'Research Unternehmen'

The named queries on the entities above are for finding the entities by the converters:

ListTypeConverter.java:

@Named
@RequestScoped
public class ListTypeConverter implements Converter
{
    @Inject
    @SeamLogger
    private Logger log;

    @Inject
    private SessionHelper sessionHelper;

    @Inject
    private ListTypeService listTypeService;

    @Override
    public Object getAsObject( FacesContext ctx, UIComponent comp, String identifier )
    {
        this.log.info( getClass().getSimpleName() + ".getAsObject: " + identifier );

        if ( identifier == null )
        {
            return null;
        }

        ListType listType = this.listTypeService.findByClientIdAndName( this.sessionHelper.getLoginUser().getClientId(), identifier );

        this.log.info( "Returning " + listType.getName() +  "!" );

        return listType;
    }

    ...
}

MonitoringReasonConverter.java:

@Named
@RequestScoped
public class MonitoringReasonConverter implements Converter
{
    @Inject
    @SeamLogger
    private Logger log;

    @Inject
    private SessionHelper sessionHelper;

    @Inject
    private MonitoringReasonService monitoringReasonService;

    @Override
    public Object getAsObject( FacesContext ctx, UIComponent comp, String identifier )
    {
        this.log.info( getClass().getSimpleName() + ".getAsObject: " + identifier );

        if ( identifier == null )
        {
            return null;
        }

        MonitoringReason monitoringReason = this.monitoringReasonService.findByClientIdAndCode( this.sessionHelper.getLoginUser().getClientId(), identifier );

        this.log.info( "Returning " + monitoringReason.getName() +  "!" );

        return monitoringReason;
    }

    ...
}

As you can see, two simple CDI converters, which are almost copies. The only difference is that list types are queried by name and monitoring reasons are queried by code. (see named queries, I checked that the correct ones are called by the services)

They are used from a JSF page like:

<p:selectOneMenu id="list-type"
                 value="#{complianceCaseManager.selectedListType}"
                 converter="#{listTypeConverter}">
    <f:selectItems value="#{listTypeManager.selectableListTypes}"
                   var="ltp"
                   itemValue="#{ltp}"
                   itemLabel="#{ltp.description}" />
    <p:ajax process="@this" update="@form" />
</p:selectOneMenu>

<p:selectOneMenu id="monitoring-reason"
                 value="#{complianceCaseManager.selectedMonitoringReason}"
                 converter="#{monitoringReasonConverter}">
    <f:selectItems value="#{monitoringReasonManager.selectableMonitoringReasons}"
                   var="mtr"
                   itemValue="#{mtr}"
                   itemLabel="#{mtr.name}" />
    <p:ajax process="@this" update="@form" />
</p:selectOneMenu>

OK, same here, basically the same copied code. The only difference is that list types use itemLabel="#{ltp.description}" and monitoring reasons use itemLabel="#{mtr.name}" as UI labels.

What happens now is not what I had expected to happen:

The list type and monitoring reason converters both get the name as identifier from JSF. This isn’t a problem for the list type converter as it uses a query with the name to find the respective entity. This happens when executing a selection change:

2012-12-18 22:51:23,923 [http-thread-pool-8181(5)] INFO  de.company.project.ListTypeConverter     - ListTypeConverter.getAsObject: RL
2012-12-18 22:51:23,927 [http-thread-pool-8181(5)] INFO  de.company.project.ListTypeConverter     - Returning RL!

However, when using the monitoring reason select, the following is logged:

2012-12-18 22:52:02,091 [http-thread-pool-8181(2)] INFO  de.company.project.MonitoringReasonConverter     - MonitoringReasonConverter.getAsObject: Fusion
2012-12-18 22:52:02,100 [http-thread-pool-8181(2)] ERROR de.company.project.MonitoringReasonService       - Monitoring reason not found for client ID = 1 with code Fusion
javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.throwNoResultException(EJBQueryImpl.java:1307)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:778)
    at de.company.project.MonitoringReasonService.findByClientIdAndCode(MonitoringReasonService.java:92)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
    at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:42)
    at sun.reflect.GeneratedMethodAccessor7832.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
    at sun.reflect.GeneratedMethodAccessor7831.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89)
    at $Proxy2626.findByClientIdAndCode(Unknown Source)
    at de.company.project.__EJB31_Generated__MonitoringReasonService__Intf____Bean__.findByClientIdAndCode(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
    at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:110)
    at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
    at de.company.project.MonitoringReasonService$Proxy$_$$_Weld$Proxy$.findByClientIdAndCode(MonitoringReasonService$Proxy$_$$_Weld$Proxy$.java)
    at de.company.project.MonitoringReasonConverter.getAsObject(MonitoringReasonConverter.java:63)
    at de.company.project.MonitoringReasonConverter$Proxy$_$$_WeldClientProxy.getAsObject(MonitoringReasonConverter$Proxy$_$$_WeldClientProxy.java)
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:171)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValue(MenuRenderer.java:201)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:318)
    at org.primefaces.component.selectonemenu.SelectOneMenuRenderer.getConvertedValue(SelectOneMenuRenderer.java:55)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
    .
    .
    .

Qs:

  1. Why is the name property taken to be used for both in the conversion process?
  2. What determines that the name property should be used for the getAsObject method string value and not – as I had always assumed – the property passed into itemLabel="..."? How do you get control??
  3. Where in the JSF spec is that information hidden? (if it’s not PrimeFaces doing some overriding here)
  • 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-16T04:01:01+00:00Added an answer on June 16, 2026 at 4:01 am

    I think this will be the problem of Converter. I found a question similar to this, check this it may help.Why selectOneMenu Send ItemLabel to the converter?

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

Sidebar

Related Questions

Possible Duplicate: Split A4 PDF page into two A5 and back again I have
Possible Duplicate: Trying to get tables next to each other horizontal I have two
Possible Duplicate: Python urllib2 Progress Hook I have a script which uploads a file
Possible Duplicate: RegEx match open tags except XHTML self-contained tags I have a HTML
Possible Duplicate: primefaces selectOneMenu doesn’t working when it should my setPropertyActionListener is not setting
Possible Duplicate: Why does ‘sizeof’ give wrong measurement? I have a structure called CBUFFER_PEROBJECT:
Possible Duplicate: JavaScript Variable Scope I have a JavaScript function for HTML select options
Possible Duplicate: nth-child for every two table rows I'm trying to work my way
Possible Duplicate: Best way to determine if two path reference to same file in
Possible Duplicate: Why does ReSharper want to use 'var' for everything? I have ReSharper

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.