9 Replies Latest reply on Mar 27, 2008 3:56 AM by bjoernb

    Invalid URL constructed in Ajax requests

    alex.alvarez

      Hi All,

      i have been trying to migrate a JSF Portlet to use RichFaces. I have used as a basis the seamBookingPortlet.war and have removed everything that is Seam specific.

      The main problem that i am having is that when i set a component to use ajax
      (i.e. rich:tabPanel switchType="ajax" ), the URLs are constructed wrongly... For example the context SmartPortlet is written twice

      /SmartPortlet/SmartPortlet/faces/WEB-INF/jsf/globalAdmin.xhtml


      or they skip the /portal/


      http://localhost:8080/SmartPortlet/css/screen.css
      

      instead of

      http://localhost:8080/portal/SmartPortlet/css/screen.css


      Any ideas?

      Alex

        • 1. Re: Invalid URL constructed in Ajax requests
          wesleyhales

          Take a look at this example war:
          http://anonsvn.jboss.org/repos/portletbridge/trunk/examples/richfaces/componentdemo/
          It has a working tabPanel.

          Or you can follow the instructions on the wiki:
          http://labs.jboss.com/auth/wiki/JBossPortletBridge

          • 2. Re: Invalid URL constructed in Ajax requests
            alex.alvarez

            Hi Wesley,

            thanks for the reply. Out firewall blocks access to repositories, so i was unable to build the application, still i replaced the xml configuration files and now the portlet gets the RichFaces resources (framework.pack.js and ui.pack.js), so things are a bit better.

            The ajax functionality didn't improve though.

            Regards,
            Alex

            • 3. Re: Invalid URL constructed in Ajax requests
              wesleyhales

              In that case, make sure you read the wiki for configuration:
              http://labs.jboss.com/wiki/JBossPortletBridge

              • 4. Re: Invalid URL constructed in Ajax requests
                alex.alvarez

                Still no success, i'm looking at the failed request with firebug and i get:

                Params:
                =====
                javax.portlet.faces.DirectLink true
                org.jboss.portletbridge.VIEWID /WEB-INF/jsf/globalAdmin.xhtml


                Response
                ======
                HTTP Status 404 -
                ---------------------
                type Status report

                message

                description
                The requested resource () is not available.
                JBossWeb/2.0.1.GA


                Post
                ===
                (empty)


                is there wany way to follow or troubleshoot the requests across the environments?

                Regards,
                Alex

                • 5. Re: Invalid URL constructed in Ajax requests
                  alex.alvarez

                  I finally discovered what is happening, I managed to build the JSF portlet using your maven archetype...

                  Comparing the projects, i discovered that i had the .xhtml files under the \WEB-INF\ directory.

                  regards,
                  Alex

                  • 6. Re: Invalid URL constructed in Ajax requests
                    bjoernb

                    hey, i am still have the same problem as you. i see the portlet but when i make an ajax request i get the error:

                    HTTP Status 404 - The requested resource () is not available

                    but i have no clue how to solve this... or how you solved it

                    my xmls are a follows:

                    web.xml

                    <?xml version="1.0" encoding="UTF-8"?>
                    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
                    
                    <display-name>Richfaces Example</display-name>
                    
                    <context-param>
                    <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                    <param-value>
                    org.jboss.portletbridge.application.FaceletPortletViewHandler
                    </param-value>
                    </context-param>
                    <context-param>
                    <param-name>javax.portlet.faces.renderPolicy</param-name>
                    <param-value>ALWAYS_DELEGATE</param-value>
                    </context-param>
                    <context-param>
                    <param-name>
                    javax.portlet.faces.preserveActionParams
                    </param-name>
                    <param-value>true</param-value>
                    </context-param>
                    <context-param>
                    <param-name>org.ajax4jsf.RESOURCE_URI_PREFIX</param-name>
                    <param-value></param-value>
                    </context-param>
                    <context-param>
                    <param-name>org.richfaces.LoadStyleStrategy</param-name>
                    <param-value>NONE</param-value>
                    </context-param>
                    <context-param>
                    <param-name>org.richfaces.LoadScriptStrategy</param-name>
                    <param-value>NONE</param-value>
                    </context-param>
                    <context-param>
                    <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
                    <param-value>false</param-value>
                    </context-param>
                    
                    
                    <!-- JSF -->
                    
                    <context-param>
                    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                    <param-value>.jsf</param-value>
                    </context-param>
                    
                    <context-param>
                    <param-name>org.richfaces.SKIN</param-name>
                    <param-value>blueSky</param-value>
                    </context-param>
                    
                    <context-param>
                    <param-name>javax.faces.CONFIG_FILES</param-name>
                    <param-value>/WEB-INF/faces-config.xml</param-value>
                    </context-param>
                    
                    <context-param>
                    <param-name>facelets.DEVELOPMENT</param-name>
                    <param-value>true</param-value>
                    </context-param>
                    
                    <filter>
                    <display-name>Ajax4jsf Filter</display-name>
                    <filter-name>ajax4jsf</filter-name>
                    <filter-class>org.ajax4jsf.Filter</filter-class>
                    <init-param>
                    <param-name>forceparser</param-name>
                    <param-value>false</param-value>
                    </init-param>
                    </filter>
                    
                    <filter-mapping>
                    <filter-name>ajax4jsf</filter-name>
                    <servlet-name>Faces Servlet</servlet-name>
                    <url-pattern>*.jsf</url-pattern>
                    <dispatcher>REQUEST</dispatcher>
                    <dispatcher>FORWARD</dispatcher>
                    <dispatcher>INCLUDE</dispatcher>
                    </filter-mapping>
                    
                    <filter-mapping>
                    <filter-name>ajax4jsf</filter-name>
                    <servlet-name>Faces Servlet</servlet-name>
                    <url-pattern>/faces/rfRes/*</url-pattern>
                    <dispatcher>REQUEST</dispatcher>
                    <dispatcher>FORWARD</dispatcher>
                    <dispatcher>INCLUDE</dispatcher>
                    </filter-mapping>
                    
                    <servlet>
                    <servlet-name>FacesServlet</servlet-name>
                    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                    <load-on-startup>1</load-on-startup>
                    </servlet>
                    
                    <servlet-mapping>
                    <servlet-name>FacesServlet</servlet-name>
                    <url-pattern>/faces/*</url-pattern>
                    </servlet-mapping>
                    
                    <session-config>
                    <session-timeout>10</session-timeout>
                    </session-config>
                    
                    <welcome-file-list>
                    <welcome-file>/faces/index.jsf</welcome-file>
                    </welcome-file-list>
                    </web-app>
                    


                    faces-config.xml
                    <?xml version='1.0' encoding='UTF-8'?>
                    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
                    version="1.2">
                     <application>
                     <view-handler>
                     org.jboss.portletbridge.application.PortletViewHandler
                     </view-handler>
                     <state-manager>
                     org.jboss.portletbridge.application.PortalStateManager
                     </state-manager>
                    
                     </application>
                     <factory>
                     <faces-context-factory>
                     org.jboss.portletbridge.context.FacesContextFactoryImpl
                     </faces-context-factory>
                     </factory>
                    
                     <managed-bean>
                     <description>Restaurant Bean</description>
                     <managed-bean-name>Restaurant</managed-bean-name>
                     <managed-bean-class>my.data.Restaurant</managed-bean-class>
                     <managed-bean-scope>session</managed-bean-scope>
                     </managed-bean>
                    </faces-config>
                    


                    jboss-portlet.xml
                    <?xml version="1.0"?>
                    
                    <!DOCTYPE portlet-app PUBLIC
                     "-//JBoss Portal//DTD JBoss Portlet 2.6//EN"
                     "http://www.jboss.org/portal/dtd/jboss-portlet_2_6.dtd"><portlet-app>
                     <portlet>
                     <portlet-name>Ajax</portlet-name>
                     <header-content>
                     <script src="/faces/rfRes//org/ajax4jsf/framework.pack.js" type="text/javascript" ></script>
                     <script src="/faces/rfRes//org/richfaces/ui.pack.js" type="text/javascript" ></script>
                     <link rel="stylesheet" type="text/css" href="/faces/rfRes//org/richfaces/skin.xcss" />
                     </header-content>
                     </portlet>
                    </portlet-app>
                    


                    portlet.xml
                    <portlet>
                    <portlet-name>Ajax</portlet-name>
                    <portlet-class>
                    javax.portlet.faces.GenericFacesPortlet
                    </portlet-class>
                    
                    <init-param>
                    <name>javax.portlet.faces.defaultViewId.view</name>
                    <value>/WEB-INF/jsp/ajax/ajax.jsf</value>
                    </init-param>
                    
                    <init-param>
                    <name>javax.portlet.faces.preserveActionParams</name>
                    <value>true</value>
                    </init-param>
                    <expiration-cache>-0</expiration-cache>
                    <portlet-info>
                    <title>RichFaces Example Portlet</title>
                    </portlet-info>
                    <supports>
                    <mime-type>text/html</mime-type>
                    <portlet-mode>VIEW</portlet-mode>
                    </supports>
                    </portlet>
                    


                    and my jsf-file ajax.jsf:
                    <f:view xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
                    <a4j:portlet>
                    
                    <h:outputText value="RichFaces components in the portal environment" />
                    
                    <h:form>
                    <h:panelGrid columns="1" border="1">
                    <h:inputText value="#{Restaurant.username}">
                    <a4j:support event="onkeyup" reRender="text" />
                    </h:inputText>
                    <h:outputText id="text" value="#{Restaurant.username}" />
                    
                    
                    <a4j:commandButton action="#{Restaurant.alteration}" value="Click" reRender="counter" >
                    </a4j:commandButton>
                    
                    <a4j:commandLink value="Portlet Instances" action="#{Restaurant.alteration}" reRender="counter"/>
                    <h:outputText id="counter" value="Click count: #{Restaurant.counter}" />
                    </h:panelGrid>
                    </h:form>
                    
                    </a4j:portlet>
                    </f:view>
                    



                    would appreciate your support !!
                    thx !!

                    • 7. Re: Invalid URL constructed in Ajax requests
                      bjoernb

                      meanwhile i frigured out that i am also missing the /portal/ infront of my project !
                      how can i repair this missing url-string part ?
                      can anyone help me thereby ?

                      • 8. Re: Invalid URL constructed in Ajax requests
                        alex.alvarez

                        What i discovered is that you can not have JSPs or XHTML files under /WEB-INF/

                        For instance, you would have to move your file from

                        /WEB-INF/jsp/ajax/ajax.jsf

                        to

                        /jsp/ajax/ajax.jsf

                        I don't know if they can fix the bridge to solve this problem.

                        • 9. Re: Invalid URL constructed in Ajax requests
                          bjoernb

                          yeahhhh thanx !!!!
                          that worked :)

                          really thanks a lot alex.alvarez :)