Primefaces FileUpload and Prettfaces Error

Splash Forums PrettyFaces Users Primefaces FileUpload and Prettfaces Error

This topic contains 31 replies, has 5 voices, and was last updated by  Lincoln Baxter III 6 years, 3 months ago.

Viewing 15 posts - 1 through 15 (of 32 total)
  • Author
    Posts
  • #17804

    kency
    Participant

    If I’m reading the xsd correctly, a view-id should be mapped like this

    <view-id value=”/faces/brand/buyBrand.xhtml” />

    intstead of

    <view-id> /faces/brand/buyBrand.xhtml </view-id>

    #20310

    kency
    Participant

    Hi Lincoln!

    After use Prettyfaces, and work something and now i have problem with Prettyfaces and Primefaces Fileupload, if not use PrettyFaces , primefaces upload can work, but else when user Prettyfaces , primefaces fileupload can not work.

    This is bug of Prettyfaces ? or Primefaces FileUpload?

    #20311

    Could you try to add the following rewrite rule to your pretty-config.xml and tell us if it works for you?

    <rewrite match="(?i)^(.*);jsessionid=w+(.*)" substitute="$1$2" redirect="chain" />

    #20312

    kency
    Participant

    To Christian: i no have any rewrite rule in pretty-config.xml, i use localhost

    If i use index/upload.jsf, primeface fileupload work well but i user index/upload it can not work

    #20313

    @kency – Add the rule christian pasted. This is a bug in Version 3.1.0 of prettyfaces that will be fixed in 3.1.1

    #20314

    kency
    Participant

    @lincoln i did follow you but it not work, it can’t upload

    #20315

    Which JSF implementation do you use? I never got PrimeFaces uploads working with MyFaces but Mojarra seems to work fine…

    And could you please post all relevant parts of your configuration? Especially the pretty-config.xml and your page content?

    #20316

    kency
    Participant

    i use JSF 2.0,Mojarra 2.0.2, GF v3 and NetBeans 6.9.1

    PrettyFaces Config

    =================================================================

    <pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.1.0
    http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.1.0.xsd">

    <!-- Begin RewriteRules -->

    <rewrite match="(?i)^(.*);jsessionid=w+(.*)" substitute="$1$2" redirect="chain" />
    <!-- Begin UrlMappings -->

    <url-mapping id="home">
    <pattern value="/" />
    <view-id>/faces/index.xhtml</view-id>
    </url-mapping>

    <url-mapping id="adminindex">
    <pattern value="/admin/index" />
    <view-id>/faces/admin/index.xhtml</view-id>
    </url-mapping>

    <url-mapping id="adminlogin">
    <pattern value="/admin/login" />
    <view-id>/faces/admin/login.xhtml</view-id>
    </url-mapping>

    <url-mapping id="mainRegister">
    <pattern value="/index/register" />
    <view-id>/faces/com/content/register/chinhreg.xhtml</view-id>
    </url-mapping>

    <url-mapping id="registerPage">
    <pattern value="/index/register/procedure" />
    <view-id>/faces/com/content/register/register.xhtml</view-id>
    </url-mapping>

    <url-mapping id="registerMessage">
    <pattern value="/index/register/success" />
    <view-id>/faces/com/content/register/success.xhtml</view-id>
    </url-mapping>

    <url-mapping id="homeLogin">
    <pattern value="/index/login" />
    <view-id>/faces/com/content/login/login.xhtml</view-id>
    </url-mapping>

    <url-mapping id="loginError">
    <pattern value="/index/login/error" />
    <view-id>/faces/com/content/login/error.xhtml</view-id>
    </url-mapping>

    <url-mapping id="about">
    <pattern value="/index/about" />
    <view-id>/faces/com/content/about/about.xhtml</view-id>
    </url-mapping>

    <url-mapping id="itemslist">
    <pattern value="/index/category/#{catItemsListController.subDetails.subcatName}" />
    <view-id>/faces/com/content/items/itemlist.xhtml</view-id>
    </url-mapping>

    <url-mapping id="itemdetails">
    <pattern value="/index/items/#{catItemsListController.itemsDetails.itemid}" />
    <view-id>/faces/com/content/items/itemdetails.xhtml</view-id>
    </url-mapping>

    <url-mapping id="cart">
    <pattern value="/index/cart/#{memberLoginController.user.username}" />
    <view-id>/faces/com/content/items/cart.xhtml</view-id>
    </url-mapping>

    </pretty-config>

    =================

    in Web.xml i config

    <filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
    <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    and my xhtml code

    <h:form  id="addItemForm"  enctype="multipart/form-data">

    <h:panelGrid columns="2" id="addItemPanel">
    <h:outputLabel value="ProductName" for="itemName" />
    <h:inputText id="itemName" value="#{itemStatusController.item.itemName}" title="ItemName" required="true" requiredMessage="The ItemName field is required."/>
    <h:outputLabel value="Describe" for="itemDescribe" />
    <h:inputText id="itemDescribe" value="#{itemStatusController.item.itemDescribe}" title="ItemDescribe" />
    <h:outputLabel value="Details" for="itemDetail" />
    <p:editor id="itemDetail" value="#{itemStatusController.item.itemDetail}" widgetVar="addItemEditor"/>
    <h:outputLabel value="Img" for="imgAvatar" />
    <p:fileUpload fileUploadListener="#{itemStatusController.handleFileUpload}" update="growl1,imgAvatar" />
    <h:outputLabel value="Thumbnail" />
    <h:graphicImage value="/item/#{itemStatusController.name}" id="imgAvatar" />
    <h:outputLabel value="Instock" for="instock" />
    <h:inputText id="instock" value="#{itemStatusController.item.instock}" title="Instock" required="true" requiredMessage="The Instock field is required."/>
    <h:outputLabel value="Price" for="price" />
    <h:inputText id="price" value="#{itemStatusController.item.price}" title="Price" required="true" requiredMessage="The Price field is required."/>
    <h:outputLabel value="fine" for="fine" />
    <h:inputText id="fine" value="#{itemStatusController.item.fine}" title="Fine" required="true" requiredMessage="The Fine field is required."/>
    <h:outputLabel value="DateExp" for="dateexp" />
    <h:inputText id="dateexp" value="#{itemStatusController.item.dateexp}" title="Dateexp" required="true" requiredMessage="The Dateexp field is required."/>
    <h:outputLabel value="Author" for="author" />
    <h:inputText id="author" value="#{itemStatusController.item.author}" title="Author" />
    <h:outputLabel value="Status:" for="status" />
    <h:selectOneMenu id="status" value="#{itemStatusController.item.status}" title="SubCat" required="true" requiredMessage="The SubCat field is required.">
    <!-- TODO: update below reference to list of available items-->
    <f:selectItems value="#{itemStatusController.enumStatus}"/>

    </h:selectOneMenu>
    <h:outputLabel value="Category" for="subCat" />
    <h:selectOneMenu id="subCat" value="#{itemStatusController.item.subCat}" title="SubCat" required="true" requiredMessage="The SubCat field is required.">
    <!-- TODO: update below reference to list of available items-->
    <f:selectItems value="#{itemStatusController.allSubCat}"/>
    </h:selectOneMenu>

    </h:panelGrid>
    <p:commandButton onclick="addItemEditor.saveHTML()" style="float: right" update="itemlistForm:itemlistTable,growl1" action="#{itemStatusController.addNewItem}" value="Add" />

    </h:form>

    #20317

    It looks like you are missing an entry in your dispatcher for Pretty Filter:

    <dispatcher>ASYNC</dispatcher>

    #20318

    kency
    Participant

    @lincoln it not work too

    #20319

    Kency, here is a demo application of PrettyFaces and PrimeFaces working together:

    http://ocpsoft.com/wp-content/uploads/2010/11/pretty-prime-test.zip

    Perhaps you could take a look at this and figure out what is different with your application.

    1. Download that zip file example
    2. Extract it to a folder
    3. Open a terminal in that folder
    4. Type: mvn jetty:run-war
    5. Browse to: http://localhost:8181/pretty-prime-test/

    Hope this helps,

    Lincoln

    #20320

    xuzhike
    Participant

    Lincoln, thank you very much. it really works now.

    I met the same error before. see my prevous web.xml:


    <filter>

    <filter-name>PrimeFaces FileUpload Filter</filter-name>

    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>

    <init-param>

    <param-name>thresholdSize</param-name>

    <param-value>51200</param-value>

    </init-param>

    <init-param>

    <param-name>uploadDirectory</param-name>

    <param-value>/tmp</param-value>

    </init-param>

    </filter>

    <filter-mapping>

    <filter-name>PrimeFaces FileUpload Filter</filter-name>

    <servlet-name>Faces Servlet</servlet-name>

    </filter-mapping>

    <filter>

    <filter-name>Pretty Filter</filter-name>

    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>

    </filter>

    <filter-mapping>

    <filter-name>Pretty Filter</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    </filter-mapping>


    two different points:

    1) in your web.xml, Pretty Filter is before PrimeFaces FileUpload Filter

    mime is inverse

    2) in my web.xml, <filter-mapping> in PrimeFaces FileUpload Filter is <servlet-name>Faces Servlet</servlet-name>, not <dispatcher>

    would you please help to explain why it can work?

    thx

    #20321

    PrettyFaces uses servlet FORWARDs to redirect traffic internally within the server.

    If you want your PrimeFaces filter to intercept requests that are FORWARD’ed from another Filter, you need to add:

    <dispatcher>FORWARD</dispatcher>

    If you PrimeFaces filter to intercept requests that are sent do ERROR page, you need to add:

    <dispatcher>ERROR</dispatcher>

    If you want PrimeFaces filter to intercept plain REQUESTs, then you need to add:

    <dispatcher>REQUEST</dispatcher>

    The same goes for ASYNC requests:

    <dispatcher>ASYNC</dispatcher>

    Does that help explain?

    #20322

    kency
    Participant

    Hi Lincoln i not have Maven , so i can’t do following step 4

    #20323

    Get Maven? :)

Viewing 15 posts - 1 through 15 (of 32 total)

You must be logged in to reply to this topic.

Comments are closed.