1 2 Previous Next 18 Replies Latest reply on Nov 18, 2006 1:59 PM by gavin.king

    Problems using Ajax4jsf to Seam Hibernate3 sample app

    smartbinary

      Hello,

      I've recently worked to get the latest versions of Ajax4jsf, Seam, Hibernate-core, and Hibernate-Annotations running the Seam Hibernate3 Booking sample...persisting to an Oracle 10gR2 DB. Everything is running fine until I try to add some Ajax4jsf functionality in. I've noticed others posting Ajax4jsf w/Seam related questions here...so here's another :-)

      Here's an example of what I'm running into: I'm working with the main.xhtml file and have replaced the standard jsf command buttons with the a4j:command buttons -- with a reRender to an a4j:outputPanel.

      The system processes command button requests fine, but I always get a full-page redraw (instead of the desired redraw of the targeted a4j:outputPanel). If I add a , it reports that the system is always doing an extra redirect after the post -- potentially leading to the full page redraw?

      Here is the updated Seam booking main.xhtml page:

      <!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:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
      template="template.xhtml">

      <!-- content -->
      <ui:define name="content">

      <h:form>
      <h:messages globalOnly="true"/>
      <h1>Search Hotels</h1>

      <h:inputText value="#{hotelBooking.searchString}" style="width: 165px;" /> 
      <a4j:commandButton value="Find Hotels" action="#{hotelBooking.find}" styleClass="button" reRender="hotelFrm"/> 
      <a4j:commandButton value="Clear Results" action="#{hotelBooking.clear}" styleClass="button" reRender="hotelFrm"/> 

      </h:form>


      <a4j:outputPanel id="hotelFrm">

      <h:form>
      <h:outputText value="No Hotels Found" rendered="#{hotels != null and hotels.rowCount==0}"/>
      <h:dataTable value="#{hotels}" var="hot" rendered="#{hotels.rowCount>0}">
      <h:column>
      <f:facet name="header">Name</f:facet>
      #{hot.name}
      </h:column>
      <h:column>
      <f:facet name="header">Address</f:facet>
      #{hot.address}
      </h:column>
      <h:column>
      <f:facet name="header">City, State</f:facet>
      #{hot.city}, #{hot.state}
      </h:column>
      <h:column>
      <f:facet name="header">Zip</f:facet>
      #{hot.zip}
      </h:column>
      <h:column>
      <f:facet name="header">Action</f:facet>
      <h:commandLink action="#{hotelBooking.selectHotel}">View Hotel</h:commandLink>
      </h:column>
      </h:dataTable>
      </h:form>



      <h1>Current Hotel Bookings</h1>


      <h:form>
      <h:outputText value="No Bookings Found" rendered="#{bookings.rowCount==0}"/>
      <h:dataTable value="#{bookings}" var="book" rendered="#{bookings.rowCount>0}">
      <h:column>
      <f:facet name="header">Name</f:facet>
      #{book.hotel.name}
      </h:column>
      <h:column>
      <f:facet name="header">Address</f:facet>
      #{book.hotel.address}
      </h:column>
      <h:column>
      <f:facet name="header">City, State</f:facet>
      #{book.hotel.city}, #{book.hotel.state}
      </h:column>
      <h:column>
      <f:facet name="header">Check in date</f:facet>
      <h:outputText value="#{book.checkinDate}">
      <f:convertDateTime type="date"/>
      </h:outputText>
      </h:column>
      <h:column>
      <f:facet name="header">Check out date</f:facet>
      <h:outputText value="#{book.checkoutDate}">
      <f:convertDateTime type="date"/>
      </h:outputText>
      </h:column>
      <h:column>
      <f:facet name="header">Confirmation number</f:facet>
      #{book.id}
      </h:column>
      <h:column>
      <f:facet name="header">Action</f:facet>
      <h:commandLink action="#{bookingList.cancel}">Cancel</h:commandLink>
      </h:column>
      </h:dataTable>
      </h:form>

      </a4j:outputPanel>
      </ui:define>

      <!-- sidebar -->
      <ui:define name="sidebar">
      </ui:define>

      </ui:composition>


      -----

      Any advice is MUCH appreciated.


      Regards,

      Todd

        • 1. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
          smartbinary

          Oh...one more thing...this is running under WebLogic 9.1.

          • 2. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
            smartbinary

            The problem was the command button action was associated to a method returning a navigation rule ... from HotelBookingAction.java:

             @Begin(join=true)
             public String find()
             {
             hotel = null;
             String searchPattern = searchString==null ? "%" : '%' + searchString.toLowerCase().replace('*', '%') + '%';
             hotels = bookingDatabase.createQuery("from Hotel where lower(name) like :search or lower(city) like :search or lower(zip) like :search or lower(address) like :search")
             .setParameter("search", searchPattern)
             .setMaxResults(50)
             .list();
            
             return "main";
             }
            


            I overloaded that method for use with an action listener:

             @Begin(join=true)
             public void find(ActionEvent actionEvent)
             {
             this.find();
             }
            


            And updated the A4J tag ... from main.xhtml:

            <a4j:commandButton value="Find Hotels" actionListener="#{hotelBooking.find}" styleClass="button" reRender="hotelFrm"/> 
            


            All is well now ... JSF+Facelets+A4J+Seam+Hibernate (jFASH) ... no "springs" attached :D

            --
            THX TO CLEM fom the mailing list for the recommendation:
            https://ajax4jsf.dev.java.net/servlets/ReadMsg?list=users&msgNo=1087


            Regard,

            Todd

            • 3. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
              gavin.king

              All you guys who are getting Seam + Ajax4JSF working together:

              I would *love* to get a copy of an example app that shows this combination working. Please submit something to JIRA or email it to me.

              • 4. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                smartbinary

                Hi Gavin...plz check ur email...

                • 5. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                  pbrewer_uk

                  Hi Todd,

                  I'm just starting to look at integrating Seam and ajax4jsf. It would be great if you could email me a working example of the two working together (or better still add a wiki entry). My email address is peter (at) iblocks.co.uk.

                  Thanks in advance for saving alot of head scratching,

                  Cheers, Peter.

                  • 6. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                    smartbinary

                    FYI: I've completed this prototype and have submitted it via JIRA for consideration of inclusion in the Seam examples.

                    See: http://jira.jboss.org/jira/browse/JBSEAM-388


                    --
                    Regards,

                    Todd Smart
                    Smart Binary, LLC
                    Partner & Sr. Consultant
                    todd.smart@smartbinary.com
                    c941.538.1814 - f727.214.9121

                    • 7. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                      gavin.king

                      Great, thanks!

                      • 8. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app

                        Hello Todd,
                        I am trying to get your example working on jboss-4.0.4.GA-jems. I have placed the libs ajax libs in tomcat/jsf-libs folder and could get the home page at the following link http://localhost:8080/seam-hibernate/home.seam.


                        However, i am not able to register an account as i have the following error at the page register.seam:

                        java.lang.IllegalArgumentException: Component _id37 must be embedded in an form
                         at org.apache.myfaces.shared_impl.renderkit.html.HtmlButtonRendererBase.buildOnClick(HtmlButtonRendererBase.java:173)
                         at org.apache.myfaces.shared_impl.renderkit.html.HtmlButtonRendererBase.encodeEnd(HtmlButtonRendererBase.java:120)
                         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.FaceletViewHandler.renderView(FaceletViewHandler.java:554)
                         at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:101)
                         at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
                         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.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
                         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.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
                         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                         at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:67)
                         at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:223)
                         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:595)
                        



                        Could you also tell me if the ajax libs are in the correct folder?? I am still not sure if they need to be there as mentioned in the following blog: http://www.michaelyuan.com/blog/2006/09/11/use-ajax4jsf-with-seam-facelets/

                        Thnx in advance....


                        Regards,
                        Yogesh
                        M-ITC LTD

                        • 9. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                          smartbinary

                          Hello Yogesh,

                          Unfortunately, I did not get a chance to run this system under the JBoss AS. I used the provided build script for Tomcat. The system has been tested under Tomcat 5.5 and WebLogic 9.1.

                          I believe you may indeed want to follow Michael's directions in that blog entry. I will be hard-pressed to try to get the system running under JBoss today, but will work on it as time permits.


                          Regards,

                          Todd

                          • 10. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                            smartbinary

                            Hmmm....trying to work on the sample for deployment to JBoss AS, but can't seem to deploy the Seam Hibernate Example w/o a class not found exception.

                            I used the JEMS installation for Beta 2 ... have JDK 1.5 starting the app server ... however, I get the following when I try to deploy the example app:

                            16:56:01,299 INFO [Server] JBoss (MX MicroKernel) [4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)] Started in 12s:871ms
                            16:56:56,183 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=hibernateDatasource' to JNDI na
                            me 'java:hibernateDatasource'
                            16:56:56,729 INFO [TomcatDeployer] deploy, ctxPath=/seam-hibernate, warUrl=.../tmp/deploy/tmp62564jboss-seam-hibernate-exp.war/
                            16:56:57,056 INFO [ServletContextListener] Welcome to Seam 1.0.1.GA
                            16:56:57,072 INFO [Initialization] reading components.xml
                            16:56:57,134 INFO [Initialization] reading properties from: /seam.properties
                            16:56:57,134 INFO [Initialization] reading properties from: /jndi.properties
                            16:56:57,134 INFO [Initialization] initializing Seam
                            16:56:57,212 INFO [Component] Component: org.jboss.seam.core.init, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Init
                            16:56:57,384 INFO [Component] Component: org.jboss.seam.core.pages, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Pages
                            16:56:57,399 INFO [Component] Component: events, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Events
                            16:56:57,415 INFO [Component] Component: org.jboss.seam.core.manager, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.core.Manager
                            16:56:57,446 INFO [Component] Component: switcher, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.Switcher
                            16:56:57,446 INFO [Component] Component: redirect, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Redirect
                            16:56:57,462 INFO [Component] Component: httpError, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.HttpError
                            16:56:57,462 INFO [Component] Component: userPrincipal, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.UserPrincipal
                            16:56:57,477 INFO [Component] Component: isUserInRole, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.IsUserInRole
                            16:56:57,493 INFO [Component] Component: conversation, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.Conversation
                            16:56:57,509 INFO [Component] Component: conversationList, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationList
                            16:56:57,509 INFO [Component] Component: conversationStack, scope: PAGE, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationStack
                            16:56:57,524 INFO [Component] Component: facesContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.FacesContext
                            16:56:57,524 INFO [Component] Component: pageContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.PageContext
                            16:56:57,555 INFO [Component] Component: eventContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.EventContext
                            16:56:57,555 INFO [Component] Component: sessionContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.SessionContext
                            16:56:57,571 INFO [Component] Component: statelessContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.StatelessContext
                            16:56:57,571 INFO [Component] Component: applicationContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ApplicationContext
                            16:56:57,571 INFO [Component] Component: conversationContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.ConversationContext
                            16:56:57,587 INFO [Component] Component: businessProcessContext, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.BusinessProcessConte
                            xt
                            16:56:57,587 INFO [Component] Component: locale, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Locale
                            16:56:57,602 INFO [Component] Component: messages, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.Messages
                            16:56:57,602 INFO [Component] Component: interpolator, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.Interpolator
                            16:56:57,618 INFO [Component] Component: facesMessages, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.FacesMessages
                            16:56:57,634 INFO [Component] Component: resourceBundle, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.ResourceBundle
                            16:56:57,649 INFO [Component] Component: localeSelector, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.core.LocaleSelector
                            16:56:57,649 INFO [Component] Component: uiComponent, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.core.UiComponent
                            16:56:57,665 INFO [Component] Component: org.jboss.seam.remoting.messaging.subscriptionRegistry, scope: APPLICATION, type: JAVA_BEAN, class: org.jbos
                            s.seam.remoting.messaging.SubscriptionRegistry
                            16:56:57,665 INFO [Component] Component: pojoCache, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.PojoCache
                            16:56:57,665 INFO [Component] Component: org.jboss.seam.debug.introspector, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.debug.Introspector
                            16:56:57,712 INFO [Component] Component: org.jboss.seam.debug.contexts, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.debug.Contexts
                            16:56:57,712 INFO [Component] Component: bookingDatabase, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.core.ManagedHibernateSession
                            16:56:57,727 INFO [Component] Component: org.jboss.seam.core.hibernate, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Hibernate
                            16:56:57,727 INFO [Component] Component: org.jboss.seam.core.microcontainer, scope: APPLICATION, type: JAVA_BEAN, class: org.jboss.seam.core.Microcon
                            tainer
                            16:56:57,743 INFO [Scanner] scanning: /C:/jboss-4.0.4.GA/server/default/tmp/deploy/tmp62564jboss-seam-hibernate-exp.war/WEB-INF/lib/jboss-seam-hibern
                            ate.jar
                            16:56:57,758 INFO [Component] Component: bookingList, scope: SESSION, type: JAVA_BEAN, class: org.jboss.seam.example.hibernate.BookingListAction
                            16:56:57,790 INFO [Component] Component: logout, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.example.hibernate.LogoutAction
                            16:56:57,805 INFO [Component] Component: login, scope: STATELESS, type: JAVA_BEAN, class: org.jboss.seam.example.hibernate.LoginAction
                            16:56:57,805 INFO [Component] Component: hotelBooking, scope: CONVERSATION, type: JAVA_BEAN, class: org.jboss.seam.example.hibernate.HotelBookingActi
                            on
                            16:56:57,821 INFO [Component] Component: changePassword, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.example.hibernate.ChangePasswordAction
                            16:56:57,836 INFO [Component] Component: user, scope: SESSION, type: ENTITY_BEAN, class: org.jboss.seam.example.hibernate.User
                            16:56:57,852 INFO [Component] Component: register, scope: EVENT, type: JAVA_BEAN, class: org.jboss.seam.example.hibernate.RegisterAction
                            16:56:57,852 INFO [Component] Component: hotel, scope: CONVERSATION, type: ENTITY_BEAN, class: org.jboss.seam.example.hibernate.Hotel
                            16:56:57,868 INFO [Component] Component: booking, scope: CONVERSATION, type: ENTITY_BEAN, class: org.jboss.seam.example.hibernate.Booking
                            16:56:58,414 ERROR [AbstractKernelController] Error installing to Described: name=Naming state=Not Installed
                            java.lang.ClassNotFoundException: org.jnp.server.SingletonNamingServer
                            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
                            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
                            at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactoryImpl.getTypeInfo(IntrospectionTypeInfoFactoryImpl.java:216)
                            at org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory.getTypeInfo(IntrospectionTypeInfoFactory.java:47)
                            at org.jboss.classadapter.plugins.reflect.ReflectClassAdapterFactory.getClassAdapter(ReflectClassAdapterFactory.java:61)
                            at org.jboss.kernel.plugins.config.AbstractKernelConfig.getBeanInfo(AbstractKernelConfig.java:59)
                            at org.jboss.kernel.plugins.config.AbstractKernelConfigurator.getBeanInfo(AbstractKernelConfigurator.java:64)
                            at org.jboss.kernel.plugins.config.AbstractKernelConfigurator.getBeanInfo(AbstractKernelConfigurator.java:76)
                            at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$DescribeAction.installAction(KernelControllerContextActions.java:227)
                            at org.jboss.kernel.plugins.dependency.KernelControllerContextActions$KernelControllerContextAction.install(KernelControllerContextActions.jav
                            a:147)
                            at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
                            at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:226)
                            at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:593)
                            at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:346)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:438)
                            at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:379)

                            I haven't used the JBoss App Server in over 5-years, so would hate to just start plugging JARs in :-).

                            Any advice?


                            Regards,

                            Todd

                            • 11. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                              smartbinary

                              Plz disregard...figured it out.

                              • 12. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                                smartbinary

                                FYI:

                                I've updated the system such that it will now build/deploy/run under JBoss v4.0.4.GA. The updates are posted here:

                                http://jira.jboss.org/jira/browse/JBSEAM-388


                                Regards,

                                Todd

                                • 13. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app
                                  gavin.king

                                  Great, I need to check it out.

                                  • 14. Re: Problems using Ajax4jsf to Seam Hibernate3 sample app

                                    Hello Todd,
                                    Thnx for helping out with the Ajax Implementation on JBoss. I have managed to get it working with command buttons....I am now trying to implement the example found at http://livedemo.exadel.com/a4j-dropDownBoxes/


                                    My SFSB is as follows:

                                    
                                    @Stateful
                                    @Scope(ScopeType.SESSION)
                                    @Name("AjaxBean")
                                    public class AjaxBean implements AjaxBeanLocal{
                                    
                                     private static final Log log = LogFactory.getLog(AjaxBean.class);
                                    
                                    
                                     private String property;
                                    
                                     private String property_text;
                                    
                                    
                                     public String getProperty_text() {
                                     return property_text;
                                    }
                                    
                                    
                                     public void setProperty_text(String property_text) {
                                     this.property_text = property_text;
                                     }
                                    
                                    
                                    
                                     public String getProperty() {
                                     return property;
                                     }
                                    
                                    
                                    
                                     public void setProperty(String property) {
                                     this.property = property;
                                     }
                                    
                                     public void setProperty(){
                                     log.debug("Setting Property to PropertyText");
                                     this.property = this.getProperty_text();
                                     }
                                    
                                    
                                     @Remove @Destroy
                                     public void destroy(){
                                    
                                     }
                                    
                                    
                                    }
                                    
                                    



                                    My XHTML page is as follows:

                                    
                                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                                     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                                    <html 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:a4j="https://ajax4jsf.dev.java.net/ajax"
                                     xmlns:h="http://java.sun.com/jsf/html">
                                    
                                    <body>
                                    <f:loadBundle basename="messages" var="msg"/>
                                    <ui:composition template="/WEB-INF/layout/template.xhtml">
                                    
                                     <ui:define name="header">
                                     <ui:include src="/WEB-INF/layout/header.xhtml" />
                                     </ui:define>
                                    
                                     <ui:define name="body">
                                    
                                    <f:view>
                                     <a4j:region selfRendered="true">
                                     <a4j:form>
                                     <a4j:status startStyle="font-color:red" stopText="Ready" startText="Request under process"/>
                                    
                                    
                                     <h:panelGroup style="display:block" id="menuValue" styleClass="px10">
                                     This is a Test #{AjaxBean.property}
                                     </h:panelGroup>
                                    
                                    
                                    
                                     <h:panelGroup id="selectMenu">
                                     <h:selectOneMenu value="#{AjaxBean.property}">
                                     <f:selectItem itemValue="car" itemLabel="Car" />
                                     <f:selectItem itemValue="motorcycle" itemLabel="Motorcycle" />
                                    
                                     <a4j:support event="onchange" action="#{AjaxBean.setProperty}"
                                     reRender="menuValue" />
                                     </h:selectOneMenu>
                                     </h:panelGroup>
                                    
                                     </a4j:form>
                                     </a4j:region>
                                    </f:view>
                                     </ui:define>
                                    
                                     <ui:define name="footer">
                                     <ui:include src="/WEB-INF/layout/footer.xhtml" />
                                     </ui:define>
                                    
                                    </ui:composition>
                                    </body>
                                    </html>
                                    
                                    





                                    When i change the value in the drop down menu, i whole page is re-rendered and only the following line is displayed:

                                    <span id="ajax-update-ids"
                                    



                                    And this is the stack trace in my log file:



                                    
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView RenderChildren() components for AJAX request
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxRendererUtils] Calculate absolute ID for component _id5 as :_id5
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView encodeChild component for AJAX request with at path : ID _id5
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView encodeChild component for AJAX request with at path : ID _id7
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView encodeChild component for AJAX request with at path :_id7: ID _id8
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] Render Ajax Area component with ID :_id7:menuValue
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView encodeChild component for AJAX request with at path :_id7: ID selectMenu
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView encodeChild component for AJAX request with at path :_id7: ID _id10
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView encodeChild component for AJAX request with at path :_id7: ID _id13
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView encodeChild component for AJAX request with at path :_id7: ID _id11
                                    2006-10-09 14:44:33,578 DEBUG [org.ajax4jsf.framework.renderer.AjaxContainerRenderer] AjaxView encodeChild component for AJAX request with at path :_id7: ID _id12
                                    2006-10-09 14:44:33,578 ERROR [org.apache.myfaces.lifecycle.PhaseListenerManager] Exception in PhaseListener RENDER_RESPONSE(6) beforePhase.
                                    java.lang.NullPointerException
                                     at com.sun.facelets.FaceletViewHandler.writeState(FaceletViewHandler.java:722)
                                     at org.ajax4jsf.framework.renderer.AjaxRendererUtils.writeState(AjaxRendererUtils.java:850)
                                     at org.ajax4jsf.framework.renderer.AjaxRendererUtils.encodeAreas(AjaxRendererUtils.java:740)
                                     at org.ajax4jsf.framework.renderer.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:128)
                                     at org.ajax4jsf.ajax.UIAjaxRegion.encodeAjax(UIAjaxRegion.java:210)
                                     at org.ajax4jsf.framework.ajax.AjaxContext.renderAjaxRegion(AjaxContext.java:256)
                                     at org.ajax4jsf.framework.ajax.AjaxRegionBrige.broadcast(AjaxRegionBrige.java:315)
                                     at org.ajax4jsf.ajax.UIAjaxRegion.broadcast(UIAjaxRegion.java:87)
                                     at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:274)
                                     at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastAjaxEvents(AjaxViewRoot.java:290)
                                     at org.ajax4jsf.framework.renderer.AjaxRenderPhaseListener.processAjaxRender(AjaxRenderPhaseListener.java:150)
                                     at org.ajax4jsf.framework.renderer.AjaxRenderPhaseListener.beforePhase(AjaxRenderPhaseListener.java:134)
                                     at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:70)
                                     at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:373)
                                     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.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
                                     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.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
                                     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                                     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                                     at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:67)
                                     at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:223)
                                     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:595)
                                    
                                    
                                    



                                    Any hint of whats wrong in my code ??

                                    Thnx for your help


                                    Yogesh
                                    M-ITC LTD
                                    http://www.m-itc.net

                                    1 2 Previous Next