2

I have tried this command buttons and many more:

<p:commandButton value="Redirect" action="/tiposDocumentos.xhtml"/>

<p:commandButton value="Redirect" action="/administrador/tiposDocumentos.xhtml"/>

<p:commandButton value="Redirect" action="administrador/tiposDocumentos.xhtml"/>

I'm literarlly going nuts with this. I have other command buttons working like a charm, but this one is making me crazy!

This is my folder structure: enter image description here

When someone logs in as an administrator, is redirected to the file "initialMenu.xhtml" with this command button (which works)

<p:commandButton value="Sign - in" action="#{loginView.login}" update="msgGrowl" />

Then I don't know how to redirect to "TiposDocumentos.xhtml". Please, help.

I'm using SpringSecurity and other buttons that don't use the "login" method also work.

I can also redirect to "tiposDocumentos.xhtml" from login if I put it outside the "administrador" folder.

AFP_555
  • 2,392
  • 4
  • 25
  • 45
  • You forgot the most important part of the question: what exactly happens instead? – BalusC May 23 '16 at 07:34
  • I click the button and nothing happens – AFP_555 May 23 '16 at 07:35
  • Uh right. Please elaborate the problem in webdeveloper's perspective, not in enduser's perspective. This site is to support website developers, not website endusers. Start with pressing F12 in your webbrowser and inspecting JS console and Network monitor for clues. – BalusC May 23 '16 at 07:36
  • Hmm... This is my first web project so I'm not too familiar with how html elements interface with primefaces. Anyways, I just found out this is caused by Spring Security. – AFP_555 May 23 '16 at 07:44
  • I´m just going to leave this here in case anyone looks for this question: This is a very common problem with Spring Security. After a successful login it gets a little complicated to redirect. Search: Spring Security redirect after login. – AFP_555 May 23 '16 at 08:46
  • This question is useless without an answer or link to the answer you found. – BalusC May 23 '16 at 08:53
  • Many links: https://www.google.com.co/?ion=1&espv=2#q=Spring+Security+redirect+after+login First link: http://www.baeldung.com/spring_redirect_after_login I didn't solve it because it isn't necessary for me. I hope that helps. – AFP_555 May 23 '16 at 09:03

1 Answers1

2

Can you try "faces-redirect=true""as explained here and elsewhere

<p:commandButton id="btn_cr" 
        value="Redirect"
        ajax="false"
        action="/tiposDocumentos.xhtml?faces-redirect=true">
    </p:commandButton>
kamwo
  • 1,980
  • 1
  • 23
  • 32
  • 3
    Please do not post "try this" answers as long as you haven't reproduced the described problem and tested the proposed solution on your own. If you're not able to do this, post a comment instead. – BalusC May 23 '16 at 07:37
  • 2
    @BaluC - point noted ! Thanks for pointing the correct way !! –  May 23 '16 at 07:43
  • @TheCoder You missed the `ajax="false"` from the mentioned link. Quote: By setting ajax to false we suppress the default use of AJAX and a asynchornous call to the backend. – kamwo Jun 02 '16 at 13:21