Domanda

<html xmlns:h="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:o="http://omnifaces.org/ui">

<o:form includeViewParams="true">
  <h:commandButton value="Home" action="/index?faces-redirect=true"/>
  <p:dataTable> 

  </p:dataTable>
</o:form>

The h:commandButton is not working under the o:form. When I click on it, it remains on the same page. But when I change to h:form, it works. Nevertheless I need to use o:form for the includeViewParams. Is there any way I could resolve this?

È stato utile?

Soluzione

This construct works for me, as in, it actually navigates to /index. Only the view params disappear from the URL because you're forcing a redirect. But there is more, the <h:commandButton> is here essentially the wrong tool for the purpose. You want pure page-to-page navigation. You should then not be using a command link/button at all, but a plain link/button. You need <h:button>.

<h:button value="Home" outcome="/index" includeViewParams="true" />

Note: this doesn't require any form.

See also:

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top