1 Reply Latest reply on Feb 5, 2009 6:19 PM by Giuseppe Raspanti

    selectOneMenu doesn't handle entities in list page

    Giuseppe Raspanti Newbie
      Hello.
      Hi have an application based on jboss-4.2.3.GA and jboss-seam-2.1.1.GA.
      I'm trying to filter the results of a EntityQuery with a selectOneMenu but every time I activate the search I get an uncaught exception. The edit page works well and has no problem with the selectOneMenu. The enumerated selectOne has no problem in the list page too. Only the list regarding the entity TipologiaDocumento has proplems.
      The exception is:

      18:12:06,471 WARN  [SeamPhaseListener] uncaught exception, passing to exception handler
      javax.el.ELException: java.lang.IllegalArgumentException: argument type mismatch
              at javax.el.BeanELResolver.setValue(BeanELResolver.java:116)
              at javax.el.CompositeELResolver.setValue(CompositeELResolver.java:68)
              at com.sun.faces.el.FacesCompositeELResolver.setValue(FacesCompositeELResolver.java:100)
              at org.jboss.el.parser.AstPropertySuffix.setValue(AstPropertySuffix.java:73)
              at org.jboss.el.parser.AstValue.setValue(AstValue.java:84)
              at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249)
              at org.jboss.seam.core.Expressions$1.setValue(Expressions.java:117)
              at org.jboss.seam.navigation.Pages.applyConvertedValidatedValuesToModel(Pages.java:860)
              at org.jboss.seam.navigation.Pages.postRestore(Pages.java:459)
              at org.jboss.seam.jsf.SeamPhaseListener.postRestorePage(SeamPhaseListener.java:546)
              at org.jboss.seam.jsf.SeamPhaseListener.afterRestoreView(SeamPhaseListener.java:392)
              at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:228)
              at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:194)
              at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
              at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)
              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
              at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
              at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at javax.el.BeanELResolver.setValue(BeanELResolver.java:108)
              ... 58 more
      18:12:06,499 ERROR [CachedConnectionValve] Application error: Faces Servlet did not complete its transaction


      I already use a converter. I tried with the seam one:
      <h:selectOneMenu value="#{documentoList.documento.tipologiaDocumento}" id="tipologiaDocumento">
      <s:selectItems value="#{tipologiaDocumentoList}" var="lst" label="#{lst}" noSelectionLabel="Nessuna Selezione"/>
      <s:convertEntity/>
      </h:selectOneMenu>

      or passing the seam converter on the selectOneMenu:
      <h:selectOneMenu value="#{documentoList.documento.tipologiaDocumento}" id="tipologiaDocumento" converter="${entityConverter}">
      <s:selectItems value="#{tipologiaDocumentoList}" var="lst" label="#{lst}" noSelectionLabel="Nessuna Selezione"/>
      </h:selectOneMenu>

      or passing my own converter:
      <h:selectOneMenu value="#{documentoList.documento.tipologiaDocumento}" id="tipologiaDocumento" converter="${listConverter}">
      <s:selectItems value="#{tipologiaDocumentoList}" var="lst" label="#{lst}" noSelectionLabel="Nessuna Selezione"/>
      </h:selectOneMenu>

      The converter is:

      @Name("listConverter")
      @BypassInterceptors
      @org.jboss.seam.annotations.faces.Converter
      public class ListConverter implements Converter
      {
        public ListConverter()
        {
          System.out.println("listConverter!!!!");
        }
       
        @Logger
        Log log;
       
        @Transactional
        public Object getAsObject(FacesContext context, UIComponent comp, String value) throws ConverterException
        {
          ValueExpression expr = comp.getValueExpression("value");
         
          Class entityType = expr == null ? null : expr.getType(context.getELContext());
          if (entityType != null)
          {
            log.info("value: #0, myType: #1", value, entityType.getName());
           
            EntityManager entityManager = ((EntityManager) Component.getInstance("entityManager"));
            Object o = entityManager.find(entityType, new Long(value));
            log.info("value: #0, myType: #1", value, o);
            return o;
           
          }
          log.info("value: #0, null type", value);

          throw new ConverterException("Unable to find selectItems.");
        }

        @Transactional
        public String getAsString(FacesContext context, UIComponent component, Object object) throws ConverterException
        {
          TipologiaDocumento tipologiaDocumento = (TipologiaDocumento) object;
          return tipologiaDocumento == null ? null : tipologiaDocumento.getId().toString();
        }
      }

      Other code is the following:

      @Name("documentoList")
      public class DocumentoList  extends EntityQuery<Documento>

        private static final String[] RESTRICTIONS = {
          "n.idDocumentoSPIGA = #{documentoList.documento.idDocumentoSPIGA}",
          "n.protocolloSPIGA = #{documentoList.documento.protocolloSPIGA}",
          "n.dataProtocolloSPIGA = #{documentoList.documento.dataProtocolloSPIGA}",
          "n.provenienza = #{documentoList.documento.provenienza}",
          "n.tipologiaDocumento = #{documentoList.documento.tipologiaDocumento}",
          "lower(n.oggettoRiferimento) like lower( concat('%',concat(#{documentoList.documento.oggettoRiferimento},'%')))",
        };
       
        public static final String EJBQL = "select n from Documento n";

        public DocumentoList() {
          setEjbql(EJBQL);
          setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
          setMaxResults(10);   
        }

        @Override
        public List<Documento> getResultList()
        {
          List<Documento> l = null;
          try
          {
            log.info("getResultList: Count: #0", getResultCount());
            l = super.getResultList();
            log.info("getResultList.... after");
          }
          catch(Throwable th)
          {
            log.error(th);
          }
          return l;
        }
       
        @Logger
        Log log;
       
        private Documento documento = new Documento();
       
        public Documento getDocumento()
        {
          return documento;
        }

        @Factory("provenienze")
        public Provenienza [] getProvenienze()
        {
          return Provenienza.values();
        } 
      }

      and my beans:
      @Entity
      @Name("documento")
      @Table(name="fm_doc", uniqueConstraints={@UniqueConstraint(columnNames={"id_doc_spiga"})})
      public class Documento implements Serializable
      {
        private Long id;

        private String idDocumentoSPIGA;

        private String protocolloSPIGA;

        private Date dataProtocolloSPIGA;

        private Provenienza provenienza;
       
        private String oggettoRiferimento;
       
        private Date dataDiProduzioneInternaAmm;

        private Date dataDiTrasmissioneDalSoggEst;

        private Date dataDiRicezioneDaParteDelSoggEst;

        private boolean dataContenutaInDoc;

        private TipologiaDocumento tipologiaDocumento;

        @Id
        @GeneratedValue(strategy=GenerationType.AUTO)
        public Long getId()
        {
          return id;
        }
       
        public void setId(Long id)
        {
          this.id = id;
        }
        
        @Column(name="id_doc_spiga")
        @Pattern(regex="\\d*")
        public String getIdDocumentoSPIGA()
        {
          return idDocumentoSPIGA;
        }

        public void setIdDocumentoSPIGA(String idDocumentoSPIGA)
        {
          this.idDocumentoSPIGA = idDocumentoSPIGA;
        }

        @Column(name="prot_spiga")
        @NotNull
        public String getProtocolloSPIGA()
        {
          return protocolloSPIGA;
        }

        public void setProtocolloSPIGA(String protocolloSPIGA)
        {
          this.protocolloSPIGA = protocolloSPIGA;
        }

        @Column(name="d_prot_spiga")
        @NotNull
        public Date getDataProtocolloSPIGA()
        {
          return dataProtocolloSPIGA;
        }

        public void setDataProtocolloSPIGA(Date dataProtocolloSPIGA)
        {
          this.dataProtocolloSPIGA = dataProtocolloSPIGA;
        }
       
        @Column(name="provenienza")
        @Enumerated
        @NotNull
        public Provenienza getProvenienza()
        {
          return provenienza;
        }
       
        public void setProvenienza(Provenienza provenienza)
        {
          this.provenienza = provenienza;
        }
       
        @Column(name="oggetto_riferimento")
        public String getOggettoRiferimento()
        {
          return oggettoRiferimento;
        }
       
        public void setOggettoRiferimento(String oggettoRiferimento)
        {
          this.oggettoRiferimento = oggettoRiferimento;
        }
       
        @Column(name="d_prod_int_amm")
        public Date getDataDiProduzioneInternaAmm()
        {
          return dataDiProduzioneInternaAmm;
        }

        public void setDataDiProduzioneInternaAmm(Date dataDiProduzioneInternaAmm)
        {
          this.dataDiProduzioneInternaAmm = dataDiProduzioneInternaAmm;
        }

        @Column(name="d_tx_from_ext_sogg")
        public Date getDataDiTrasmissioneDalSoggEst()
        {
          return dataDiTrasmissioneDalSoggEst;
        }

        public void setDataDiTrasmissioneDalSoggEst(Date dataDiTrasmissioneDalSoggEst)
        {
          this.dataDiTrasmissioneDalSoggEst = dataDiTrasmissioneDalSoggEst;
        }

        @Column(name="d_rx_from_ext_sogg")
        public Date getDataDiRicezioneDaParteDelSoggEst()
        {
          return dataDiRicezioneDaParteDelSoggEst;
        }

        public void setDataDiRicezioneDaParteDelSoggEst(Date dataDiRicezioneDaParteDelSoggEst)
        {
          this.dataDiRicezioneDaParteDelSoggEst = dataDiRicezioneDaParteDelSoggEst;
        }

        @Column(name="data_in_doc")
        public boolean isDataContenutaInDoc()
        {
          return dataContenutaInDoc;
        }

        public void setDataContenutaInDoc(boolean dataContenutaInDoc)
        {
          this.dataContenutaInDoc = dataContenutaInDoc;
        }

        @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
        @JoinColumn(name = "tipo_doc_id")
        public TipologiaDocumento getTipologiaDocumento()
        {
          return tipologiaDocumento;
        }

        public void setTipologiaDocumento(TipologiaDocumento tipologiaDocumento)
        {
          this.tipologiaDocumento = tipologiaDocumento;
        }
       
        @Override
        public String toString()
        {   
          return "Protocollo: " + getProvenienza().getDesc() + ", " + getProtocolloSPIGA() + " del " + FD.Data.format(getDataProtocolloSPIGA());
        }
       
        public enum Provenienza
        {
          I("Ingresso"), U("Uscita");
         
          Provenienza(String desc)
          {
            this.desc = desc;
          }

          public String getDesc()
          {
            return desc;
          }

          private String desc;
        }
      }

      and:

      @Entity
      @Name("tipologiaDocumento")
      @Table(name="fm_tipo_doc", uniqueConstraints={@UniqueConstraint(columnNames={"n_tipologia", "n_sottotipologia"})})
      public class TipologiaDocumento implements Serializable
      {
        private Long id;
       
        private String numTipologia;

        private String tipologia;
       
        private String numSottoTipologia;
       
        private String sottoTipologia;

        @Id
        @GeneratedValue(strategy=GenerationType.AUTO)   
        public Long getId()
        {
          return id;
        }
       
        public void setId(Long id)
        {
          this.id = id;
        }

        @Column(name="n_tipologia")
        @Length(min=1,max=2)
        public String getNumTipologia()
        {
          return numTipologia;
        }
       
        public void setNumTipologia(String tipologia)
        {
          numTipologia = tipologia;
        }

        @Column(name="n_sottotipologia")
        @Length(max=2)
        public String getNumSottoTipologia()
        {
          return numSottoTipologia;
        }

        public void setNumSottoTipologia(String idSottoTipologia)
        {
          this.numSottoTipologia = idSottoTipologia;
        }
       
        public String getTipologia()
        {
          return tipologia;
        }

        public void setTipologia(String tipologia)
        {
          this.tipologia = tipologia;
        }

        public String getSottoTipologia()
        {
          return sottoTipologia;
        }

        public void setSottoTipologia(String sottoTipologia)
        {
          this.sottoTipologia = sottoTipologia;
        }
       
        @Override
        public String toString()
        {
          StringBuffer sb = new StringBuffer();
          sb.append(numTipologia).append(". ").append(tipologia);
          if(numSottoTipologia != null)
            sb.append(" .").append(numSottoTipologia).append(". ").append(sottoTipologia);
          return sb.toString();
        }
      }



      I read some previous post and my opinion is that the problem is during the rendering phase because hibernate is able to complete correctly as I overridden the getResultList and I can see the results. The ListConverter works too.

        • 1. Re: selectOneMenu doesn't handle entities in list page
          Giuseppe Raspanti Newbie

          Sorry for my english and the format of my previous post.


          Solved. I had to specify the converter twice.
          The first time in the <h:selectOneMenu> line and the second one in the pages.xml.
          The sources are here:
          documentoList.xhtml


          ....
          <s:decorate template="layout/display.xhtml">
          <ui:define name="label">Tipologia Documento</ui:define>
          <h:selectOneMenu value="#{documentoList.documento.tipologiaDocumento}" id="tipologiaDocumento" converter="${listConverter}" style="width:250px">
          <s:selectItems value="#{tipologiaDocumentoList}" var="lst" label="#{lst}" noSelectionLabel="Nessuna Selezione"/>
          </h:selectOneMenu>
          </s:decorate>
          ....
          



          and documentoList.page.xhtml


          <?xml version="1.0" encoding="UTF-8"?>
          <page xmlns="http://jboss.com/products/seam/pages"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.1.xsd">
          
             <param name="firstResult" value="#{documentoList.firstResult}"/>
             <param name="sort" value="#{documentoList.orderColumn}"/>
             <param name="dir" value="#{documentoList.orderDirection}"/>
          
             <param name="from"/>
             <param name="tipologiaDocumento" value="#{documentoList.documento.tipologiaDocumento}" converter="${listConverter}"/>
             <param name="provenienza" value="#{documentoList.documento.provenienza}"/>
             <param name="protocolloSPIGA" value="#{documentoList.documento.protocolloSPIGA}"/>   
             <param name="dataProtocolloSPIGA" value="#{documentoList.documento.dataProtocolloSPIGA}" converter="#{dateConverter}"/>
             <param name="oggettoRiferimento" value="#{documentoList.documento.oggettoRiferimento}"/>
          
          </page>
          



          Previoulsy I tried to override equals() and hashcode() but this doesn't aid.


          The problem seems to be at org.jboss.seam.navigation.Param.java. The method:



          public String getStringValueFromModel(FacesContext facesContext)




          does not look at the page and goes directly to pages.xml to find the converter.
          I don't know if its right but looking to the documentation I never get the idea that you need to specify the converter twice. If it is so, please, update the documentation.