5 Replies Latest reply on Jan 27, 2008 11:40 AM by gringalet

    how can i use *.seam and *.jsf at the same time?

    gringalet

      i am glad to see jboss seam example -dvdstore, and i want to add a jsp file named upload.jsp in the root dir. and like this:
      --root
      -------home.xhtml
      -------browse.xhtml
      -------dvd.xhtml
      .------ ......
      -------upload.jsp

      now, i want to use upload.jsp for upload file.
      i make a managed-bean in faces-config.xml and it works well.

      but when i write the url :http://localhost:8080/dvd/upload.jsf, the error happens, it seems that seam can't find "upload.jsp" file.
      who can give me a hand?

        • 1. Re: how can i use *.seam and *.jsf at the same time?
          gringalet

          my faces-config.xml like this:

          <?xml version='1.0' encoding='UTF-8'?>
          <!DOCTYPE faces-config PUBLIC
           "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
           "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
          
          <faces-config>
          
           <!-- i18n -->
          
          <!--
          
           <lifecycle>
           <phase-listener>org.jboss.seam.jsf.TransactionalSeamPhaseListener</phase-listener>
           </lifecycle>
           -->
           <application>
           <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
           </application>
           <managed-bean>
           <description>ManagedBean sample that uses UploadBean</description>
           <managed-bean-name>MyManagedBean</managed-bean-name>
           <managed-bean-class>sample.jsf.MultipartBean</managed-bean-class>
           <managed-bean-scope>request</managed-bean-scope>
           </managed-bean>
           <navigation-rule>
           <navigation-case>
           <from-outcome>upload</from-outcome>
           <to-view-id>/upload.jsp</to-view-id>
           <redirect/>
           </navigation-case>
           <navigation-case>
           <from-outcome>flashgateway</from-outcome>
           <to-view-id>/flashgateway.jsp</to-view-id>
           <redirect/>
           </navigation-case>
           </navigation-rule>
           <lifecycle>
           <phase-listener>
           org.jboss.seam.jsf.TransactionalSeamPhaseListener
           </phase-listener>
           </lifecycle>
          
          </faces-config>


          my pages.xml like this:
          <!DOCTYPE pages PUBLIC "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
           "http://jboss.com/products/seam/pages-1.2.dtd">
          
          <pages>
           <page view-id="/dvd.xhtml"
           action="#{search.selectFromRequest}" />
          
           <page view-id="/admin/ship.xhtml"
           no-conversation-view-id="/admin/admin.xhtml"/>
          
           <page view-id="/admin/accept.xhtml"
           no-conversation-view-id="/admin/admin.xhtml"/>
          
           <page view-id="/admin/admin.xhtml">
           <navigation>
           <rule if-outcome="ship">
           <redirect view-id="/admin/ship.xhtml"/>
           </rule>
           <rule if-outcome="accept">
           <redirect view-id="/admin/accept.xhtml"/>
           </rule>
           </navigation>
           </page>
          
           <!-- this action ensures that only admin users can access anything under /admin" -->
           <page view-id="/admin/*">
           <restrict>#{s:hasRole('admin')}</restrict>
           </page>
          
           <page view-id="*">
           <navigation from-action="#{identity.logout}">
           <redirect view-id="/home.xhtml"/>
           </navigation>
          
           <navigation from-action="#{identity.login}">
           <rule if="#{currentUser.admin}">
           <redirect view-id="/admin/admin.xhtml"/>
           </rule>
           </navigation>
          
           <navigation>
           <rule if-outcome="home">
           <redirect view-id="/home.xhtml"/>
           </rule>
          
           <rule if-outcome="browse">
           <redirect view-id="/browse.xhtml"/>
           </rule>
          
           <rule if-outcome="checkout">
           <redirect view-id="/checkout.xhtml"/>
           </rule>
          
           <rule if-outcome="showorders">
           <redirect view-id="/showorders.xhtml"/>
           </rule>
          
           <rule if-outcome="admin">
           <redirect view-id="/admin/admin.xhtml"/>
           </rule>
          
           <rule if-outcome="upload">
           <redirect view-id="/upload.jsp"/>
           </rule>
           </navigation>
           </page>
          
          
           <exception class="org.jboss.seam.security.NotLoggedInException">
           <redirect view-id="/home.xhtml">
           <message>You must be logged in to access administrative pages.</message>
           </redirect>
           </exception>
          
           <exception class="org.jboss.seam.security.AuthorizationException">
           <redirect view-id="/home.xhtml">
           <message>You are not authorized to access administrative pages.</message>
           </redirect>
           </exception>
          
          </pages>


          and my web.xml like this:
          <?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">
          
           <!-- Seam -->
          
           <listener>
           <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
           </listener>
          
           <filter>
           <filter-name>Seam Exception Filter</filter-name>
           <filter-class>org.jboss.seam.servlet.SeamExceptionFilter</filter-class>
           </filter>
          
           <filter-mapping>
           <filter-name>Seam Exception Filter</filter-name>
           <url-pattern>*.jsf</url-pattern>
           </filter-mapping>
          
           <!-- MyFaces -->
          
           <listener>
           <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
           </listener>
          
           <context-param>
           <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
           <param-value>client</param-value>
          
           </context-param>
           <context-param>
           <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
           <param-value>.xhtml</param-value>
           </context-param>
           <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>*.jsf</url-pattern>
           </servlet-mapping>
           <servlet-mapping>
           <servlet-name>Faces Servlet</servlet-name>
           <url-pattern>*.seam</url-pattern>
           </servlet-mapping>
          
          
           <!--ajax-->
          
          
           <display-name>a4jEchoText</display-name>
          
           <filter>
           <display-name>Ajax4jsf Filter</display-name>
           <filter-name>ajax4jsf</filter-name>
           <filter-class>org.ajax4jsf.Filter</filter-class>
           </filter>
          
           <filter-mapping>
           <filter-name>ajax4jsf</filter-name>
           <servlet-name>Faces Servlet</servlet-name>
           <dispatcher>REQUEST</dispatcher>
           <dispatcher>FORWARD</dispatcher>
           <dispatcher>INCLUDE</dispatcher>
           </filter-mapping>
          
          
           <filter-mapping>
           <filter-name>ajax4jsf</filter-name>
           <url-pattern>*.seam</url-pattern>
           </filter-mapping>
           <!--
           <context-param>
           <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
           <param-value>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</param-value>
           </context-param>
           -->
           <filter>
           <filter-name>UploadBeanFilter</filter-name>
           <display-name>UploadBeanFilter</display-name>
           <filter-class>javazoom.upload.filter.UploadBeanFilter</filter-class>
           <init-param>
           <param-name>encoding</param-name>
           <param-value>ISO-8859-1</param-value>
           </init-param>
           <init-param>
           <param-name>parser</param-name>
           <param-value>CFUPARSER</param-value>
           </init-param>
           <init-param>
           <param-name>maxcontentlength</param-name>
           <param-value>1073741824</param-value>
           </init-param>
           </filter>
          
           <filter-mapping>
           <filter-name>UploadBeanFilter</filter-name>
           <url-pattern>/*</url-pattern>
           </filter-mapping>
          
           <session-config>
           <session-timeout>10</session-timeout>
           </session-config>
          
          
          
          
          </web-app>



          My errors like this:
          HTTP Status 404


          • 2. Re: how can i use *.seam and *.jsf at the same time?
            mail.micke

            Hi,
            why does it have to be a jsp file? Can't you convert it to an xhtml file?

            If I were you I would look at the JSF spec and see what context parameters are available.
            By default it would look for .jsp files but via the:
            javax.faces.DEFAULT_SUFFIX
            You change that to xhtml.

            cheers

            • 3. Re: how can i use *.seam and *.jsf at the same time?
              gringalet

              thanks a lot. i used a uploadbean developed by javazoom . they have no xhtml spec in their components. what can i do?
              i don't know how to upload a file via a xhtml file in jboss seam dvd store example.
              i believe you would tell me something about that.
              :) thanks.

              • 4. Re: how can i use *.seam and *.jsf at the same time?
                mail.micke

                If you want to go the XHTML route, you need to define a blabla.taglib.xml for it and add the necessary context parameter for facelets to pick it up.

                There is info about it here facelets.dev.java.net , in the wiki I think there are taglib.xml files for other libraries you can have a look at.

                Also Seam has built in support for file uploads, check out this documentation:
                http://docs.jboss.com/seam/2.0.1.CR2/reference/en/html/controls.html
                (haven't tried it myself yet)

                good luck

                • 5. Re: how can i use *.seam and *.jsf at the same time?
                  gringalet

                  thanks man :)