does not execute action listener

Splash Forums PrettyFaces Users does not execute action listener

This topic contains 22 replies, has 4 voices, and was last updated by  Christian Kaltepoth 5 years, 6 months ago.

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #23253

    If you want to implement RESTful URLs with PrettyFaces, you will have to pass arguments with your URL. This is a very common pattern when using PrettyFaces.

    You should really have a look at the documentation to get a deeper understanding of how PrettyFaces is used:

    http://ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/

    You could also have a look at this post I wrote some time ago. It describes a typical master-detail scenario and how it can be implemented using PrettyFaces:

    http://ocpsoft.org/support/prettyfaces-users/prettyfaces-hibernate-spring-lazy-initialization#post-3355

    Christian

    #23254

    Hi,

    I am new to PrettyFace,I got a similar stupid issue that the action could not be executed.

    CommandLink as below:

    filename: complaint.jsf

    <h:commandLink id=”display” value=”#{msg.COMMON_BUTTON_SUBMIT}” action=”#submissionBean.submitSubmissionData}”> </h:commandLink>

    Pretty face config:

    <url-mapping id=”generalcomplaint” >

    <pattern value=”/generalcomplaint/” />

    <view-id>/complaint.jsf</view-id>

    </url-mapping>

    From the customPhase Listener after clicking the command link, it submitted the form and reloaded the same page without calling the method “submitSubmissionData”.

    Here is the Phase Listener log for the request.

    [25/02/13 17:38:31:816 CST] 0000003a SystemOut O START PHASE RESTORE_VIEW(1)

    [25/02/13 17:38:31:816 CST] 0000003a SystemOut O END PHASE RESTORE_VIEW(1)

    [25/02/13 17:38:31:817 CST] 0000003a SystemOut O START PHASE RENDER_RESPONSE(6)

    [25/02/13 17:38:32:150 CST] 0000003a SystemOut O END PHASE RENDER_RESPONSE(6)

    My current environment:

    JSF 2.0

    Myfaces 2.1.9

    Prettyfaces 3.3.3

    Websphere 8.0

    Servlet 3.0

    #23255

    Does it work if you access the view directly using the URL /complaint.jsf?

    #23256

    Thanks for your help.

    The complaint.jsf could be rendered when it was not running with Prettyface.

    Once I put the Prettyface lib into the project,I could access the page using the prettyface mapping, /contextroot/generalcomplaint/, but when I tried to click on the command link and submit the form using POST, it didn’t hit the action method at all. I was thinking about the URL mapping of the prettyface.

    Since the mapping of my Prettyface config didn’t have the ACTION element specified, however the commandlink has an Action attribute defined. How should I define the URL-MAPPING of the PrettyFace for access the same URL for view and submitting the same URL for the action.

    <url-mapping id=”generalcomplaint” >

    <pattern value=”/generalcomplaint/” />

    <view-id>/complaint.jsf</view-id>

    </url-mapping>

    Here is the generated HTML of the complaint.jsf

    Submit <//a>’

    The Attachment is the Temper data catched by the Firefox when I tried to click on the commandLink element.

    [attachment=5546,83]

    #23257

    Hi,

    I just ran the sample code of encoding.xhtml found at https://github.com/ocpsoft/prettyfaces/tree/master/tests-jsf2/src/test/resources/encoding

    It could call the action method exampleBean.handleDecode through the PrettyFace

    I will try to check out what wrong with my application.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">

    <f:metadata>
    <f:viewParam name="dis" value="#{p}" />
    </f:metadata>

    <head>
    <title>Encoding Test</title>
    </head>

    <body>
    <h1>Encoding Test</h1>
    <h1><h:outputText value="Pretty Decode Page" /></h1>
    <h:form id="form" prependId="false">
    <h:outputText value="Enter a value: will be decoded" /><br />
    <h:inputText id="input0" value="#{exampleBean.param0}" /><br /><br />

    <h:outputText value="Enter a value: will not be decoded" /><br />
    <h:inputText id="input1" value="#{exampleBean.param1}" />
    <!-- <h:commandButton id="submit" action="#{exampleBean.handleDecode}" value="Submit" /><br /> -->
    <h:commandLink id="submit" action="#{exampleBean.handleDecode}" value="Submit" />
    </h:form>
    </body>
    </html>

    Cheers.

    #23258

    Hi,

    I found the root cause of the form not calling the action method.

    Since the complaint.jsf has FileUploadItem, my form has to add the enctype=”multipart/form-data” .

    Once I tried to add the enctype=”multipart/form-data” to the encoding.xhtml. It would not call the action method at all.

    </f:metadata>

    <head>
    <title>Encoding Test</title>
    </head>

    <body>
    <h1>Encoding Test</h1>
    <h1><h:outputText value="Pretty Decode Page" /></h1>
    <h:form id="form" enctype="multipart/form-data" prependId="false">
    <h:outputText value="Enter a value: will be decoded" /><br />
    <h:inputText id="input0" value="#{exampleBean.param0}" /><br /><br />

    <h:outputText value="Enter a value: will not be decoded" /><br />
    <h:inputText id="input1" value="#{exampleBean.param1}" />
    <!-- <h:commandButton id="submit" action="#{exampleBean.handleDecode}" value="Submit" /><br /> -->
    <h:commandLink id="submit" action="#{exampleBean.handleDecode}" value="Submit" />

    </h:form>
    </body>
    </html>

    #23259
    #23260

    Nice to hear you got it working. :)

Viewing 8 posts - 16 through 23 (of 23 total)

You must be logged in to reply to this topic.

Comments are closed.