Prettyfaces + Primefaces – JSF2.0 – Glassfish 3

Splash Forums PrettyFaces Users Prettyfaces + Primefaces – JSF2.0 – Glassfish 3

This topic contains 9 replies, has 4 voices, and was last updated by  biblio 9 years, 9 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #17787

    dmport
    Participant

    Hi everyone

    I am new to Prettyfaces and i was trying to add it to a project in JSF 2 and Primefaces, i am using a p:commandButton with an actionListener to a bean but this action is never called (debugging to see). I readed a lot of forums and one of the things that i tried is in web.xml add the <async-supported>true</async-supported> in the Pretty Filter. But i can’t managed to get it working. Should i use anything on pretty-config to enable ajax support?

    Thanks in advance

    #20217

    Could you post the relevant parts of your code and the mapping definition? This would help finding the cause of your problems.

    #20218

    dmport
    Participant

    Thanks for the reply

    Here is the information

    `clientDetails.xhtml

    The objective of this button is to open a dialog but before do an action on the bean.

    <p:commandButton actionListener=”#{clientDetailBean.setupCreateClientUser}”

    oncomplete=”dialogCreateUser.show()” value=”Add new”/>

    The methods on bean

    public void setupCreateClientUser(ActionEvent actionEvent){

    this.currentClientUser = new Clientuser();

    this.currentClientUser.setActive(true);

    this.currentClientUser.setClient(currentClient);

    }

    public void insertClientUser(ActionEvent actionEvent){

    if(currentClientUser!=null){

    User.InsertUser(currentClientUser);

    }

    }

    web.xml

    <web-app version=”3.0″ 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_3_0.xsd“>

    <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>*.xhtml</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    </filter-mapping>

    <context-param>

    <param-name>javax.faces.PROJECT_STAGE</param-name>

    <param-value>Development</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>*.xhtml</url-pattern>

    </servlet-mapping>

    <servlet>

    <servlet-name>Resource Servlet</servlet-name>

    <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>

    </servlet>

    <servlet-mapping>

    <servlet-name>Resource Servlet</servlet-name>

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

    </servlet-mapping>

    <context-param>

    <param-name>com.sun.faces.allowTextChildren</param-name>

    <param-value>true</param-value>

    </context-param>

    <context-param>

    <param-name>primefaces.skin</param-name>

    <param-value>none</param-value>

    </context-param>

    <session-config>

    <session-timeout>

    30

    </session-timeout>

    </session-config>

    <welcome-file-list>

    <welcome-file>home.xhtml</welcome-file>

    </welcome-file-list>

    </web-app>

    <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“>

    <url-mapping id=”clients.show”>

    <pattern value=”/clients/” />

    <view-id>/client/show.xhtml</view-id>

    </url-mapping>

    <url-mapping id=”clients.create”>

    <pattern value=”/clients/newclient” />

    <action>#{clientDetailBean.setupCreateClient}</action>

    <view-id>/client/create.xhtml</view-id>

    </url-mapping>

    <url-mapping id=”clients.details”>

    <pattern value=”/clients/#{ clientid }/” />

    <query-param name=”clientid”>#{clientDetailBean.currentClientId}</query-param>

    <action onPostback=”false”>#{clientDetailBean.selectClient}</action>

    <view-id>/client/clientDetails.xhtml</view-id>

    </url-mapping>

    <url-mapping id=”clients.edit”>

    <pattern value=”/clients/edit/#{ clientid }/” />

    <query-param name=”clientid”>#{clientDetailBean.currentClientId}</query-param>

    <action>#{clientDetailBean.selectClient}</action>

    <view-id>/client/edit.xhtml</view-id>

    </url-mapping>

    </pretty-config>

    <faces-config version=”2.0″

    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_2_0.xsd“>

    <navigation-rule>

    <from-view-id>*</from-view-id>

    <navigation-case>

    <from-outcome>clients.show</from-outcome>

    <to-view-id>/client/show.xhtml</to-view-id>

    </navigation-case>

    <navigation-case>

    <from-outcome>clients.details</from-outcome>

    <to-view-id>/client/clientDetails.xhtml</to-view-id>

    </navigation-case>

    <navigation-case>

    <from-outcome>clients.edit</from-outcome>

    <to-view-id>/client/edit.xhtml</to-view-id>

    </navigation-case>

    <navigation-case>

    <from-outcome>clients.create</from-outcome>

    <to-view-id>/client/create.xhtml</to-view-id>

    </navigation-case>

    <navigation-case>

    <from-outcome>home.show</from-outcome>

    <to-view-id>/home.xhtml</to-view-id>

    </navigation-case>

    </navigation-rule>

    </faces-config>

    #20219

    I think your pretty filter mapping url-pattern is backwards; it needs to use a different value. Instead of *.xhtml, use /*:

    <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>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    #20220

    dmport
    Participant

    I tried it now.

    Still, the action isn’t called when i click the button!

    #20221

    Could you try p:commandLink instead? I recently had some strange issues with p:commandButton inside data tables that I fixed by using p:commandLink instead. Seems like a bug in PrimeFaces, but I didn’t had the time to have a closer look at it yet.

    BTW: It looks like you are using navigation rules inside faces-config.xml. This is a bit uncommon. You won’t need them if you are using PrettyFaces. Just return something like pretty:clients.details from your action methods (pretty: followed by the mapping id).

    #20222

    Chkal is right, but could you also try this?

    <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>ASYNC</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

    #20223

    dmport
    Participant

    Thank you guys, that worked for now.

    Keep up with the good work. :D

    #20224

    Awesome! You’re welcome. This change is in the latest 3.1.1-SNAPSHOT if you want to just use that JAR instead of doing all this custom configuration.

    Release should happen soon since it includes a bunch of new bug-fixes.

    #20225

    biblio
    Participant

    thanks guys

    this is very helped me …

Viewing 10 posts - 1 through 10 (of 10 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.