7 Replies Latest reply on Jan 4, 2007 9:26 AM by Ben Catherall

    HelloWorld-Ajax with Facelets

    Andreas Franke Apprentice

      Hello,

      running the helloworld4 example with .jsp from JBoss Seam Book was successful.

      Here the code:

      ManagerAction.java

      int MAX_RESULTS_RETURNED = 10;
       String [] popularNames = new String [] {
       "Gavin King", "Thomas Heute", "Michael Yuan",
       "Norman Richards", "Bill Burke", "Marc Fleury"
       };
       public void suggestName (FacesContext context,
       String partialName, CompletionResult result) {
      
       System.out.println("Auto Complete method is called");
      
       int totalNum = 0;
       if (partialName.length() > 0) {
       for (int i=0; i<popularNames.length; i++) {
       if (popularNames.toLowerCase().indexOf(partialName.toLowerCase())!=-1
       && totalNum < MAX_RESULTS_RETURNED) {
      
       result.addItem(popularNames);
       totalNum++;
       }
       }
       } else {
       for (int i=0; i<MAX_RESULTS_RETURNED &&
       i<popularNames.length; i++) {
       result.addItem(popularNames);
       }
       }
      
       }


      hello.jsp
      <h:form>
      
      <h:panelGrid columns="2">
       <h:outputText value="Your Name" />
       <h:panelGroup>
       <ui:autoComplete
       size="15" id="name"
       completionMethod="#{manager.suggestName}"
       value="#{greeter.name}"
       required="false" />
       <h:message for="name" />
       </h:panelGroup>


      Now, when I use Facelets for a similar example with same Bean-Code I receive the Error:
      ELException: /hello2.xhtml: Bean: org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$73f8c9e7, property: suggestName
      11:29:38,603 ERROR [STDERR] 21.12.2006 11:29:38 com.sun.facelets.FaceletViewHandler handleRenderException
      SCHWERWIEGEND: Error Rendering View[/hello2.xhtml]
      javax.el.ELException: /hello2.xhtml: Bean: org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$73f8c9e7, property: suggestName
       at com.sun.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:53)
       at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
       at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:433)
       at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChildren(RendererUtils.java:419)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlGroupRendererBase.encodeEnd(HtmlGroupRendererBase.java:75)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
       at org.apache.myfaces.shared_impl.renderkit.RendererUtils.renderChild(RendererUtils.java:442)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:216)
       at org.apache.myfaces.shared_impl.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:98)
       at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:242)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:239)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:580)
       at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:32)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:46)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:619)
      


      here the code from hello.xhtml
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       template="layout/template.xhtml"
       xmlns:bp="http://java.sun.com/blueprints/ui/14">
      
      <ui:define name="body">
      
       <h1>hello2</h1>
       <p>Generated form page</p>
      
       <h:messages globalOnly="true" styleClass="message"/>
      
       <h:form id="hello2">
       <div class="dialog">
       <h:panelGrid columns="2">
       <h:outputText value="Your name"/>
       <h:panelGroup>
       <bp:autoComplete
       size="15" id="name"
       completionMethod="#{hello.suggestName}"
       value="#{hello.value}"
       required="false" />
       <h:message for="name"></h:message>
       </h:panelGroup>
       </h:panelGrid></div>
       </h:form>
      
      </ui:define>
      
      </ui:composition>
      


      The suggestName method is declared in Hello.java interface and HelloBean.java

      What I have ToDo to get this running with Facelets?