have to press command button twice

后端 未结 5 668
不知归路
不知归路 2020-12-06 12:11

I\'m working on building a web page and notice now that I have to press the command button twice. Any command button has the same problem, so I figured I would add and actio

相关标签:
5条回答
  • 2020-12-06 12:33

    or you can add this ajax="false" property in your commandButton

    <p:commandButton ajax="false" action="#{userController.create}" value="#{bundle.CreateUserSaveLink}"></p:commandButton>
    
    0 讨论(0)
  • 2020-12-06 12:45

    That can happen when a parent component of the given <h:form> has been rendered/updated by another command button/link with <f:ajax>. The given form will then lose its view state which it would only get back after submitting the form for the first time. Any subsequent submits will then work the usual way. This is caused by a bug in JSF JS API as descibred in JSF issue 790 which is fixed in the upcoming JSF 2.2.

    You need to fix the another command button/link with <f:ajax> to explicitly include the client ID of the given <h:form> in the render.

    <f:ajax render=":somePanel :formP" />
    

    Another way is to replace this <f:ajax> by a PrimeFaces <p:commandLink> or <p:commandButton> so that you don't need to explicitly include the client ID of all the forms. PrimeFaces's own JS API has namely already incorporated this fix.

    0 讨论(0)
  • 2020-12-06 12:45

    I ran into the same issue. The solution was simple, instead of having both an actionListener and an action, just convert the actionListener method to return a string to where you want to navigate to and use it as the method for the action (and don't have an actionListener).

    In simple terms: only use an action (do not use an actionListener on a commandButton that is submitting a form).

    0 讨论(0)
  • 2020-12-06 12:47

    Please check your binding with bean.

    bean fields should be String or non primitive.

    0 讨论(0)
  • 2020-12-06 12:48

    add event="onclick" in your p:commandbutton
    I guess that will sort it out.

    0 讨论(0)
提交回复
热议问题