4 Replies Latest reply on Jan 4, 2012 7:45 AM by maserati

    RichFaces connection problem to databases

    maserati

      Hello,

       

      I have a page that contains a tab (Oracle, Teradata), each tab is the connection settings, but when I click connect, nothing is happening, while the methods of connections are good (I tested before moving to RichFaces)

       

      Login.xhtml

       

      <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="http://richfaces.org/a4j"  
                        xmlns:rich="http://richfaces.org/rich">   
          <style>   
          .rich-tab-inactive {   
              cursor: pointer;   
          }   
          .rich-tabpanel-content {   
              border-width: 1px 1px 1px 1px;   
              background-color: transparent;   
          }   
          </style>   
          <p>   
          Here is an example of default tab panel with 3 tabs.   
          <rich:tabPanel headerAlignment="right" switchType="client">   
              <rich:tab label="ORACLE">   
                  <h:panelGrid columns="2">   
                      <h:outputText value="Host"></h:outputText>   
                      <h:inputText value="#{ManagedBeanO.host}"></h:inputText>   
                      <h:outputText value="Port"></h:outputText>   
                      <h:inputText value="#{ManagedBeanO.port}"></h:inputText>   
                      <h:outputText value="User"></h:outputText>   
                      <h:inputText value="#{ManagedBeanO.user}"></h:inputText>   
                      <h:outputText value="Password"></h:outputText>   
                      <h:inputSecret value="#{ManagedBeanO.mdp}"></h:inputSecret>   
                      <h:outputText value="Base Name"></h:outputText>   
                      <h:inputText value="#{ManagedBeanO.baseName}"></h:inputText>   
                  </h:panelGrid>   
                  <h:commandButton value="Connect" action="Connect"></h:commandButton>   
              </rich:tab>   
              <rich:tab label="TERADATA">   
                  <h:panelGrid columns="2">   
                      <h:outputText value="Host"></h:outputText>   
                      <h:inputText value="#{ManagedBeanT.host}"></h:inputText>   
                      <h:outputText value="User"></h:outputText>   
                      <h:inputText value="#{ManagedBeanT.user}"></h:inputText>   
                      <h:outputText value="Password"></h:outputText>   
                      <h:inputSecret value="#{ManagedBeanT.mdp}"></h:inputSecret>   
                  </h:panelGrid>   
                  <h:commandButton value="Connect" action="Connect"></h:commandButton>   
              </rich:tab>   
          
          </rich:tabPanel>   
          </p>   
          
      </ui:composition>  
      
      
      

       

      Login.xhtml page is linked (in faces-config.xml) with welcome.xhtml page that contains a method called getConnection

       

      welcome.xhtml

       

      <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="http://richfaces.org/a4j"  
                        xmlns:rich="http://richfaces.org/rich"  
                        template="/WEB-INF/templates/BasicTemplate.xhtml">   
          <ui:define name="content">   
              <h:outputLabel value="Welcome #{ManagedBeanO.connectedUser}"></h:outputLabel>   
          </ui:define>   
      </ui:composition>  
      
      

      For example, if the userchoose the ORACLE tab, and click connect, how am I going to call the getConnection located in ManagedBeanO (Oracle) and the same question if the user use Teradata tab.

       

      Thank you in advance

        • 1. Re: RichFaces connection problem to databases
          iabughosh

          welcome to the community EL,

          you are not definig h:form in your page, use h:head and h:form in your page or your template (preferred in your page).

           

          regards.

          • 2. Re: RichFaces connection problem to databases
            maserati

            I have now this message when I click on connect

             

            javax.servlet.ServletException
                 javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
                 org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
                 org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
                 org.ajax4jsf.Filter.doFilter(Filter.java:175)
            
            • 3. Re: RichFaces connection problem to databases
              iabughosh

              which RichFaces version do you have ?, please post your web.xml.

              • 4. Re: RichFaces connection problem to databases
                maserati

                Thanks for reply:

                I use RichFaces 3.2

                Here my Web.xml

                 

                 

                xml version="1.0" encoding="UTF-8"
                
                
                <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
                  <display-name>JSFFaceletsTutorial</display-name>
                  <welcome-file-list>
                    <welcome-file>index.html</welcome-file>
                    <welcome-file>index.htm</welcome-file>
                    <welcome-file>index.jsp</welcome-file>
                    <welcome-file>default.html</welcome-file>
                    <welcome-file>default.htm</welcome-file>
                    <welcome-file>default.jsp</welcome-file>
                  </welcome-file-list>
                  <servlet>
                    <servlet-name>Faces Servlet</servlet-name>
                    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                    <load-on-startup>1</load-on-startup>
                  </servlet>
                  <servlet-mapping>
                    <servlet-name>Faces Servlet</servlet-name>
                    <url-pattern>/faces/*</url-pattern>
                  </servlet-mapping>
                  <context-param>
                  <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                  <param-value>.xhtml</param-value>
                   </context-param>
                  
                  <context-param>
                    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
                    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                    <param-value>client</param-value>
                  </context-param>
                  <context-param>
                    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
                    <param-value>resources.application</param-value>
                  </context-param>
                  <context-param>
                 <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
                 <param-value>true</param-value>
                 </context-param>
                 <!-- Making the RichFaces skin spread to standard HTML controls -->
                 
                  <context-param>
                    <param-name>org.richfaces.CONTROL_SKINNING</param-name>
                    <param-value>enable</param-value>
                  </context-param>
                  
                  <context-param>
                   <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                   <param-value>com.sun.facelets.FaceletViewHandler</param-value>
                  </context-param>
                  
                  <context-param>
                    <param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
                    <param-value>disable</param-value>
                  </context-param>
                <!-- Defining and mapping the RichFaces filter -->
                  <filter>
                   <display-name>RichFaces Filter</display-name>
                   <filter-name>richfaces</filter-name>
                   <filter-class>org.ajax4jsf.Filter</filter-class>
                  </filter>
                <filter-mapping>
                  <filter-name>richfaces</filter-name>
                  <servlet-name>Faces Servlet</servlet-name>
                  <dispatcher>REQUEST</dispatcher>
                  <dispatcher>FORWARD</dispatcher>
                  <dispatcher>INCLUDE</dispatcher>
                </filter-mapping>
                 
                  <listener>
                    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
                  </listener>
                </web-app>