JSF commandButton

Splash Forums PrettyFaces Users JSF commandButton

This topic contains 7 replies, has 2 voices, and was last updated by  Lincoln Baxter III 6 years, 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17803

    dave_r12
    Participant

    Hey we have recently begun experimenting with pretty faces in our project and it has worked out well. One thing we have encountered though is once we are on a pretty faces page (i.e. /hobbies/cars/civic) and we have a JSF command button, the action on the command button will not get called. Looking at the page source, it seems the form gets posted back to the same page. Since its being posted back to the same page, pretty faces will handle the request and it is never passed back through to jsf. I would assume this is a problem that would be faced by many developers but may be wrong. Are there any workarounds, or did I miss something in the documentation?

    Thanks

    #20303

    This doesn’t sound like normal behavior. Could you please post your relevant versions, prettyfaces, jsf, appserver — and also post some code and configuration (or a full example project would be best.)

    Thanks,

    Lincoln

    #20304

    dave_r12
    Participant

    Thanks for the fast response. I apologize, I think I found the solution. I used the onPostback attribute on the action element (set to false) and now the pages seem to work like expected. So if this is set to true, it doesn’t seem to pass the action to JSF?

    #20305

    What version of PrettyFaces are you using? That sounds backwards.

    <action> #{bean.action} </action> — should trigger the action on PostBack

    <action onPostback="false"> #{bean.action}</action> — should not trigger the action on PostBack

    This should have no affect on command button action methods (<h:commandButton action="#{otherBean.otherMethod}" />), unless of course your action method invokes navigation – this would prevent further JSF processing (including any command actions) for the current request

    #20306

    dave_r12
    Participant

    Lincoln, yes we use command buttons that invoke navigation. Although, isn’t this the default case with command buttons using the action attribute (without immediate attribute)? The method in the action attribute on the command button didn’t seem to be invoked when the onPostback attribute was set to true. And come to think about, we are also using command links with the immediate attribute set to true, and those as well didn’t work (again, these invoke navigation.) After setting a break point on the command buttons action method, it will only be called once the onPostback attribute is set to false. I apologize, I am still new to pretty faces.

    #20307

    Could you please send a test-case that I could try? To see what you are experiencing. Also, I still need your versions/code/config.

    #20308

    dave_r12
    Participant

    We are using JSF 1.2, as well as Spring (3.0.3.RELEASE) and have registered the SpringBeanFacesELResolver in the faces-config.xml.

    version: prettyfaces-jsf12-3.1.0

    pretty-config.xml

    <url-mapping id="viewItem" >
    <pattern value="/location/details/#{ itemId }" />
    <view-id>/location/detail.xhtml</view-id>
    <action onPostback="false">#{locationCrud.detailSetup}</action>
    </url-mapping>

    locationCrud is a bean registered in Spring application context (normal POJO).

    /location/detail.xhtml (stripped down)

    <head>
    </head>
    <body>
    <ui:composition template="/templates/skeleton.xhtml">
    <ui:define name="listing">
    <ui:include src="list.xhtml" />
    </ui:define>
    <ui:define name="display">
    <h1>#{msg.locationDetails}</h1>
    <h:form>
    <h:commandButton action="#{locationCrud.editSetup}" value="#{msg.btnEdit}">
    <f:setPropertyActionListener target="#{jsfService.itemId}" value="#{locationCrud.item.uuid}" />
    </h:commandButton>
    </h:form>
    </ui:define>
    </ui:composition>
    </body>
    </html>

    #20309

    Hmm… that’s very interesting.

    I haven’t heard of anyone else complaining about this. Could you post your locationCrud.detailSetup function?

    Thanks,

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

You must be logged in to reply to this topic.

Comments are closed.