10 Replies Latest reply on May 8, 2009 6:59 AM by Nick Belaevski

    rich:suggestionbox - onobjectchange

    Ingo Wurzer Newbie

      Hi,

      i want to render a div outside the suggestionbox if i change the object (like scrolling details). so I think I will have to use the onobjectchange method.

      But if I use this with "usingSuggestObjects=false" nothing happens.
      If I use it with "usingSuggestObjects=true" I get following Error:

      javax.faces.FacesException: javax.faces.FacesException: Error in conversion Java Object to JavaScript

      Thanks for help!!

      ingo

        • 1. Re: rich:suggestionbox - onobjectchange
          Ilya Shaikovsky Master

           

          But if I use this with "usingSuggestObjects=false" nothing happens.

          as designed.

          If I use it with "usingSuggestObjects=true" I get following Error:


          provide the code for page and data objects. Can't reproduce under 3.3.1 SNAPSHOT.

          • 2. Re: rich:suggestionbox - onobjectchange
            Nick Belaevski Master

            Hello Ingo,

            Please check server logs and tell us exact what error occurred.

            • 3. Re: rich:suggestionbox - onobjectchange
              Ingo Wurzer Newbie

              Here is the code...

              Thanks for your response!

              ingo


              page-code
              
              <script type="text/javascript">//<![CDATA[
               function processObjectsChange(suggestionBox) {
               var items = suggestionBox.getSelectedItems();
               if (items && items.length > 0) {
               var html = 'test test"
               $('myDiv').innerHTML = html;
               } else {
               $('myDiv').innerHTML = "empty";
               }
               }
               //]]></script>
              
               <h:form>
               <h:inputText id ="locationinput" value="#{_searchLocationController.location.name}" />
               <rich:suggestionbox for="locationinput"
               minChars="3"
               suggestionAction="#{_searchLocationController.autoCompleteResults}"
               var="item"
               reRender="lala"
               nothingLabel="hab nix gefunden"
               onobjectchange="processObjectsChange()"
               usingSuggestObjects="true"
               >
               <h:column>
               <h:outputText value="#{item.name}" />
               </h:column>
               <h:column>
               <h:outputText value="#{item.address.zip} #{item.address.city}" />
               </h:column>
              
               </rich:suggestionbox>
              
               <h:panelGrid columns="1" id="lala" >
              
               <div id="myDiv"></div>
              
               </h:panelGrid>
              
               </h:form>
              
              
              "Search" Method:
              
               public List<Location> autoCompleteResults(Object sugg) {
               List<Location> searchResults = new ArrayList<Location>();
               if ((sugg != null) && StringUtils.isNotEmpty((String)sugg)) {
               _location.setName((String)sugg + "*");
               super.doSearch();
               searchResults = super.getSearchResults();
               }
               return searchResults;
               }
              
              Location Object:
              
              @Entity
              @Table(name="LOCATION")
              @Name("location")
              @Indexed(index="locations")
              public class Location extends DomainObject implements Searchable, Serializable {
              
               private static final long serialVersionUID = 1L;
              
               @Column(name = "NAME", nullable = false, unique = false)
               @Length(min=2, max=255)
               @Field(index=Index.TOKENIZED)
               private String _name;
              
               @Column(name = "DESCRIPTION", nullable = true, unique = false)
               @Length(max=8000)
               private String _description;
              
               @Column(name = "LOCATIONTYPE", nullable = false, unique = false)
               @Enumerated(value=EnumType.ORDINAL)
               @Field(index=Index.TOKENIZED)
               private LocationType _locationType;
              
               @Embedded
               @IndexedEmbedded
               private Address _address = new Address();
              
               @ManyToOne(optional= false, fetch = FetchType.LAZY)
               @JoinColumn(name = "CREATEDBY", nullable = false, unique = false)
               private Member _createdBy;
              
               @Column(name = "CREATEDAT", nullable = false, unique = false)
               @Temporal(TemporalType.TIMESTAMP)
               private Date _createdAt;
              
              ....
              
              
              And here is the exception:
              
              
              javax.faces.FacesException: Error in conversion Java Object to JavaScript
               at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:140)
               at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:85)
               at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:105)
               at org.ajax4jsf.renderkit.AJAXDataSerializer.asString(AJAXDataSerializer.java:40)
               at org.ajax4jsf.renderkit.AjaxRendererUtils.encodeAreas(AjaxRendererUtils.java:783)
               at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:125)
               at org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:677)
               at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:548)
               at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
               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:196)
               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.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:179)
               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: javax.faces.FacesException: Error in conversion Java Object to JavaScript
               at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:140)
               at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:135)
               ... 56 more
              Caused by: java.lang.NoSuchMethodException: Property 'handler' has no getter method in class 'class com.consapro.planer.domain.member.Member_$$_javassist_1'
               at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1318)
               at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:762)
               at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:837)
               at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426)
               at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:135)
               ... 57 more
              
              


              • 4. Re: rich:suggestionbox - onobjectchange
                Ilya Shaikovsky Master

                Caused by: java.lang.NoSuchMethodException: Property 'handler' has no getter method in class 'class
                com.consapro.planer.domain.member.Member_$$_javassist_1'

                • 5. Re: rich:suggestionbox - onobjectchange
                  Ingo Wurzer Newbie

                  Mhm - but I do not understand the message!?


                  here is the code for Member/AbstractMember/Domainobject

                  @Entity
                  @Table(name="MEMBER")
                  public class Member extends AbstractMember {
                  
                   private static final long serialVersionUID = 1L;
                  
                   @Column(name = "TEMPORARY", nullable = false, unique = false)
                   private boolean _temporary = false;
                  
                   public boolean isTemporary() {
                   return _temporary;
                   }
                  
                   public void setTemporary(boolean temporary) {
                   this._temporary = temporary;
                   }
                  }
                  
                  @MappedSuperclass
                  public abstract class AbstractMember extends DomainObject {
                  
                   private static final long serialVersionUID = 1L;
                  
                   @Column(name = "MEMBERNAME", nullable = false, unique = false)
                   @NotEmpty
                   @Length(min=3, max=15)
                   private String _membername;
                  
                   @Column(name = "PASSWORD", nullable = false, unique = false)
                   @NotEmpty
                   @Length(min=3, max=15)
                   private String _password;
                  
                   @Column(name = "EMAIL", nullable = false, unique = true)
                   @NotEmpty
                   @Email
                   private String _email;
                  
                   @Temporal(TemporalType.TIMESTAMP)
                   @Column(name = "REGISTRATIONDATE", nullable = false, unique = false)
                   private Date _registrationDate;
                  
                   @Column(name= "ENABLED", nullable = false, unique = false)
                   private Boolean _enabled;
                  
                   @Column(name = "ROLE", nullable = false, unique = false)
                   private int _role;
                  
                  ... followed by getters/setters
                  
                  public abstract class DomainObject implements Serializable {
                  
                   private static final long serialVersionUID = 1L;
                  
                   @Id
                   @GeneratedValue(strategy = IDENTITY)
                   @Column(name = "ID", unique = true, nullable = false)
                   @DocumentId
                   private Long _id;
                  
                   @Version
                   @Column(name = "VERSION", nullable = false)
                   @NotNull
                   protected int _version;
                  
                   @Transient
                   protected boolean _dirty;
                  
                   public Long getId() {
                   return _id;
                   }
                  ...
                  
                  


                  • 6. Re: rich:suggestionbox - onobjectchange
                    Ingo Wurzer Newbie

                    Ok now I get another exception:
                    I removed the lazy loading within the Location -> Member.

                    Now I get ...
                    But the file/folder is there

                    javax.faces.FacesException: Error in conversion Java Object to JavaScript
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:140)
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:85)
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:105)
                     at org.ajax4jsf.renderkit.AJAXDataSerializer.asString(AJAXDataSerializer.java:40)
                     at org.ajax4jsf.renderkit.AjaxRendererUtils.encodeAreas(AjaxRendererUtils.java:783)
                     at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:125)
                     at org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:677)
                     at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:548)
                     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
                     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:196)
                     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.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:179)
                     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: javax.faces.FacesException: Error in conversion Java Object to JavaScript
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:140)
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:135)
                     ... 56 more
                    Caused by: javax.faces.FacesException: Error in conversion Java Object to JavaScript
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:140)
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:135)
                     ... 57 more
                    Caused by: javax.faces.FacesException: Error in conversion Java Object to JavaScript
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:140)
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:135)
                     ... 58 more
                    Caused by: javax.faces.FacesException: Error in conversion Java Object to JavaScript
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:140)
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:135)
                     ... 59 more
                    Caused by: java.lang.reflect.InvocationTargetException
                     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.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:2155)
                     at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1323)
                     at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:762)
                     at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:837)
                     at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426)
                     at org.ajax4jsf.javascript.ScriptUtils.toScript(ScriptUtils.java:135)
                     ... 60 more
                    Caused by: java.io.FileNotFoundException: C:\development\jboss\jboss-4.2.2.GA\server\default\deploy\com.consapro.planer-ear.ear (Access denied)
                     at java.io.FileInputStream.open(Native Method)
                     at java.io.FileInputStream.<init>(FileInputStream.java:106)
                     at org.jboss.net.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:105)
                     at java.net.URLConnection.getContent(URLConnection.java:688)
                     at java.net.URL.getContent(URL.java:1023)
                     ... 70 more
                    


                    • 7. Re: rich:suggestionbox - onobjectchange
                      Ingo Wurzer Newbie

                      Hi @all,

                      I found that the problem only exists if I have a "enum" inside the Domainobject.

                      Maybe the StringUtils class cannot work with it.

                      So the "problem" is -> private LocationType _locationType;

                      Any ideas??

                      • 9. Re: rich:suggestionbox - onobjectchange
                        Ingo Wurzer Newbie

                        Oh yes - thats it!

                        Yes - I'am using the RF 3.2.2 ...

                        • 10. Re: rich:suggestionbox - onobjectchange
                          Nick Belaevski Master

                          Please try 3.3.0/3.3.1.CR3