0

This seems silly, but I can not figure out why it is not working, I have the following project tree:

enter image description here

Inside dashboard.xhtml I have a button that has to redirect the user to RequisicoesEmAberto.xhtml.

This is what I tried when using a html button:

<button id="reqAbertoBtn" class="btnAcessoRapido" onclick="ClickEvent()">
    <div class="iconeBtnAcessoRapido">
        <i class="fal fa-folder-open"></i>
    </div>
    <span class="tituloBtnAcessoRapido">Requisições em Aberto</span>
</button>  

function ClickEvent() {
    window.location.href = '/evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml';
}

However the page only refreshed, then I decided to try a PrimeFaces component for that, so I tried:

<p:commandButton icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" action="/evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml?faces-redirect=true"/>  

So when I clicked the button an error saying that it was not possible to find the resource "/evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml" occurred, but the page is there, you can access it if you type the url in the browser.

I also tried using outcome:

<p:button icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" outcome="/evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml"/>

and

<p:button icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" outcome="../compras/requisicao/RequisicoesEmAberto.xhtml"/>

and

<p:button icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" outcome="RequisicoesEmAberto.xhtml"/>

Needles to say that also gave me an error:

Could not resolve NavigationCase for outcome: /evop/protected/compras/requisicao/RequisicoesEmAberto.xhtml

I can't believe it is that hard to do a simple page redirect, what am I missing here?

Alexandre Krabbe
  • 727
  • 1
  • 13
  • 33
  • Almost seems like you are using JSF 1.x ? In JSF 1.x you have to define navigation rules in `faces-config.xml`. If you are unsure - can you show us your classpath ? – Adam Waldenberg Apr 01 '19 at 06:59

1 Answers1

0

Try this you can give the reference to page RequisicoesEmAberto.xhtml W.r.t. DashBoard.xhtml

<p:commandButton icon="fal fa-folder-open" iconPos="top" value="Requisições em Aberto" action="../compras/requisicao/RequisicoesEmAberto.xhtml?faces-redirect=true"/> 
saurabhiitr
  • 47
  • 1
  • 7