continuation of pressing button twice

后端 未结 1 939
粉色の甜心
粉色の甜心 2020-12-10 21:59

Yesterday I posted a question about having to press a button twice to get it to work. I received good help, which is the hallmark of stackoverflow, but the problem still exi

相关标签:
1条回答
  • 2020-12-10 22:55

    You've there a very specific problem. You're fully navigating by ajax instead of by a normal synchronous request and the whole view is replaced with the new view. The forms in the new view does not have the view state anymore which is indeed related to JSF issue 790. It's also not possible to reference the forms in the update of the <p:commandButton> as the forms does not exist in the same view.

    After all, it's not recommendable to fully navigate by ajax. It makes your page non-bookmarkable and non-searchbotindexable. I suggest to replace all forms of

    <p:commandButton ... action="otherViewId" />
    

    by

    <p:button ... outcome="otherViewId" />
    

    This will navigate by normal synchronous requests and will create new views wherein all forms will have their view state. Note that the <p:button> doesn't require a <h:form>, you can omit it if necessary.


    Unrelated to the concrete problem, I also suggest to put master.xhtml in the /WEB-INF folder so that the endusers can never request it by entering/guessing its URL in browser address bar. See also Which XHTML files do I need to put in /WEB-INF and which not?

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