2 Replies Latest reply on Aug 21, 2008 9:38 PM by guy bashan

    s:convertEntity not working properly

    guy bashan Apprentice

      Hi,


      I am having a strange problem with convertEntity. My page is loaded properly, but when I am viewing the source of the page I see that the generated ids for each option tag does not match the ids in my database. Currently I have in my database 3 items. The ids are: 1,2,3. In the dropdow, the generated ids are: 0,1,2.


      Here is the dropdown code:
                           


      <t:selectOneMenu id="channel" value="#{upload.selectedChannel}" required="true" forceId="true"
                                   immediate="true">
                    <a4j:support event="onchange" reRender="subChannel" />
                    <s:selectItems value="#{upload.channels}"
                                   var="channel"
                                   label="#{channel.name}"
                                   noSelectionLabel="-- Select Channel --"/>
                     <s:convertEntity />
                  </t:selectOneMenu>
      





      Here is the generated html with the wrong ids:




      <select id="formUpload:channel" name="formUpload:channel" size="1">      <option value="org.jboss.seam.ui.NoSelectionConverter.noSelectionValue">-- Select Channel --</option>
      
              <option value="0">News/Events</option>
              <option value="1">Product Reviews</option>
              <option value="2">How To</option>
      </select>




        • 1. Re: s:convertEntity not working properly
          Samuel Mendenhall Apprentice

          The generated ids won't match up unless you make them, see: http://in.relation.to/Bloggers/SselectItemsCustomisingTheValue for how to do this.

          • 2. Re: s:convertEntity not working properly
            guy bashan Apprentice

            Thanks, I got the point.


            I wrote this class:


            @Name("org.jboss.seam.ui.entityIdentifierStore")
            @Scope(ScopeType.PAGE)
            public class CustomEntityIdentifierStore extends EntityIdentifierStore
            {
              public String put(Identifier identifier, Object entity)
              {
                if (entity instanceof Channel)
                {
                  Channel channel = (Channel)entity;
                  return "channel:" + channel.getChannelId();
                }
                else
                {
                  return super.put(identifier, entity);
                }
              }
            
             public Identifier get(String key)
             {
                if (key.startsWith("channel"))
                {
                  String id = key.substring(7, key.length());
                  return new EntityIdentifier(Channel.class, new Integer(id));
                }
                else
                {
                  return super.get(key);
                }
              }
            }
            



            But it seems like Seam doesn't take it, cause it doesn't stop in breakpoints.
            In addition when navigating to this page I get the exception (which obviously caused since component is not taken...):


            org.hibernate.TransientObjectException: The instance was not associated with this session
                 at org.hibernate.impl.SessionImpl.getIdentifier(SessionImpl.java:1375)
                 at org.hibernate.search.impl.FullTextSessionImpl.getIdentifier(FullTextSessionImpl.java:525)
                 at org.jboss.seam.persistence.HibernateSessionProxy.getIdentifier(HibernateSessionProxy.java:236)
                 at org.jboss.seam.framework.HibernateEntityIdentifier.<init>(HibernateEntityIdentifier.java:13)
                 at org.jboss.seam.ui.converter.entityConverter.HibernateEntityLoader.createIdentifier(HibernateEntityLoader.java:39)
                 at org.jboss.seam.ui.converter.entityConverter.AbstractEntityLoader.put(AbstractEntityLoader.java:50)
                 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 org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
                 at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
                 at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:38)
                 at org.jboss.seam.util.Work.workInTransaction(Work.java:41)
                 at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:32)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
                 at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                 at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
                 at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
                 at org.jboss.seam.ui.converter.entityConverter.HibernateEntityLoader_$$_javassist_7.put(HibernateEntityLoader_$$_javassist_7.java)
                 at org.jboss.seam.ui.converter.EntityConverter.getAsString(EntityConverter.java:77)
                 at org.jboss.seam.ui.converter.PrioritizableConverter.getAsString(PrioritizableConverter.java:67)
                 at org.jboss.seam.ui.converter.ConverterChain.getAsString(ConverterChain.java:123)
                 at org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:521)
                 at org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.getConvertedStringValue(RendererUtils.java:532)
                 at org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.renderSelectOptions(HtmlRendererUtils.java:410)
                 at org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:315)
                 at org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.renderMenu(HtmlRendererUtils.java:267)
                 at org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:59)
                 at org.apache.myfaces.renderkit.html.ext.HtmlMenuRenderer.encodeEnd(HtmlMenuRenderer.java:60)
                 at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
                 at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
                 at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
                 at org.jboss.seam.ui.renderkit.ValidateAllRendererBase.doEncodeChildren(ValidateAllRendererBase.java:33)
                 at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
                 at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
                 at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                 at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                 at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
                 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
                 at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
                 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                 at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:164)
                 at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
                 at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
                 at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417)
                 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                 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.MultipartFilter.doFilter(MultipartFilter.java:85)
                 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:141)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                 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.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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
                 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
                 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
                 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:447)
                 at java.lang.Thread.run(Thread.java:619)