JSF redirect via commandButton

后端 未结 1 542
离开以前
离开以前 2021-01-07 18:39

I cannot redirect to another page if the code is like this:


         


        
1条回答
  •  执笔经年
    2021-01-07 19:31

    The doesn't generate a submit button. It just generates a "dead" button without any effects, purely intented to be used for custom onclick="..." scripts and like. This is somewhat a leftover of the dark JSF 1.0/1.1 era, when it wasn't nicely possible to just use plain vanilla HTML in JSF for this kind of things.

    The performs the submit by ajax powers through JSF-generated onclick. It doesn't care about the button's type.

    Essentially, removing type="button" and relying on its default type="submit" should fix your problem.

    
    

    However, all with all, if this is the real code and you don't actually intend to invoke a bean action, then you're going in completely the wrong direction as to implementing the functional requirement of navigating to a different page by a button. You should be using instead.

    
    

    See also:

    • Difference between h:button and h:commandButton
    • How to navigate in JSF? How to make URL reflect current page (and not previous one)

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