1

I created this button and want it to call the function in action="" while also redirecting to a new page (displayed in the comment).

<p:commandButton icon="pi pi-pencil" value="Edit"
          styleClass="rounded-button ui-button-primary"
          action="#{notificationService.editNotificationInList(notification)}"/><!-- outcome="/create"/-->

So far I know I can use <p:button> to only redirect (without executing any functions).

Neur0
  • 367
  • 5
  • 13
  • 2
    If your `action` returns a String then Faces will try to map that to a URL and you can use `?faces-redirect` to tell it to redirect so in your Java method add `return "mypage.xhtml?faces-redirect=true` to redirect to the mypage.xhtml – Melloware Jun 28 '21 at 18:13
  • 1
    Does this answer your question? [Redirect using ](https://stackoverflow.com/questions/29647525/redirect-using-pcommandbutton) – stefan-dan Jun 30 '21 at 12:02
  • @stefan-dan yes it does, but melloware's solution worked as well – Neur0 Jul 10 '21 at 22:36

0 Answers0