0

Hey guys I was reading JSF redirect via commandButton to see if maybe I was doing the redirect wrong, but I am not, this commandButton redirect with a relative path worked on PrimeFaces 3.5 but now on PrimeFaces 7.0 it just won't, however if I paste the exact absolute redirect url it will work, any idea why?

It was working on PF 3.5 but doesn't on 7.0:

<p:commandButton
    value="#{plantillaGeneralMB.cantTrasladosPendientes}"
    styleClass="cds-icon-traslados"
    onclick="return !validarPaginaActual('solicitartraslados.xhtml');"
    action="../movimientos/solicitartraslados.xhtml?faces-redirect=true"
    rendered="#{plantillaGeneralMB.blTrasladosPendientes}"
    title="#{tooltipsMsg.caja_traslados_pendientes}" ajax="false" />

This works on 7.0:

<p:commandButton
    value="#{plantillaGeneralMB.cantTrasladosPendientes}"
    styleClass="cds-icon-traslados"
    onclick="return !validarPaginaActual('solicitartraslados.xhtml');"
    action="/XHTML/movimientos/solicitartraslados.xhtml?faces-redirect=true"
    rendered="#{plantillaGeneralMB.blTrasladosPendientes}"
    title="#{tooltipsMsg.caja_traslados_pendientes}" ajax="false" />

Notice that I just have to put exactly where the xhtml is to make it work and I think that shouldn't be the way.

This is my project xhtml structure:

structure

whats going on? or am I missing something really obvious?

Also commandButton is on plantillaGeneral.xhtml which is on here:

plantillaGeneral

BugsForBreakfast
  • 712
  • 10
  • 30
  • So if you remove the styleclass, onclick, rendered, title, use a static value instead of EL it works? And where is the original source xhtml located? Relevant for attempt to reproduce. And any errors? – Kukeltje Aug 08 '19 at 22:30
  • Maybe related to _"Button/Link/MenuItem: The url/href attribute isn't automatically prepended by contextPath anymore. Use the outcome attribute for referencing JSF views in the same application or manually prepend url/href with #{request.contextPath}. See https://github.com/primefaces/primefaces/issues/3506."_ as mentioned in the migration guide ftom 6.2 to 7. Add a omment in the referenced issue and ask there – Kukeltje Aug 08 '19 at 22:48
  • @Kukeltje I will confirm you all this tomorrow my friend, just like on the code I posted, look at action on each paragraph of code, i changed the way he knows where is solicitartraslados.xhtml – BugsForBreakfast Aug 09 '19 at 03:41
  • What is the *source* file location, not the destination, that one is clear since it is in the action – Kukeltje Aug 09 '19 at 06:51
  • @Kukeltje source file? give me an example of that mate, like where is my project at? or where it is placed when I do the maven install command? – BugsForBreakfast Aug 09 '19 at 13:03
  • The file where the commandbuttons are in.... – Kukeltje Aug 09 '19 at 13:35
  • @Kukeltje they are in plantillaGeneral :D this button that redirects is on plantillaGeneral, and plantillaGeneral is on screenshot im gonna upload soon – BugsForBreakfast Aug 09 '19 at 15:02
  • Ok, that is a template. Which is the file (or one of the files) this template is used in? What if you put a button directly in there? And again, all these questions can be prevented if you start with making an [mcve] upfront. Always, always, always do this. including removing templates. See also https://www.stackoverflow.com/tags/jsf/info – Kukeltje Aug 09 '19 at 15:49
  • @Kukeltje The file(s) this template is used in is on everywhere, all the other xhtml use him mate, but the button that redirects is only in there in plantillaGeneral, because it is a header that has that button to redirect to solicitartraslados.xhtml, but it is only working if I "burn" the path /XHTML/movimientos/solicitartraslados.xhtml?faces-redirect=true, and on PF 3.5 it worked with the other way mate, and don't worry ask me all you need :) I try to make the example but is complicated in this case – BugsForBreakfast Aug 09 '19 at 15:56
  • 1
    This can never be complicated in creating a [mcve]... At most 15 minutes work. And I understand the problem... no need to repeat that. And keep in mind that actions if the contain direct references to pages, always need to be relative to the page, not the template. – Kukeltje Aug 09 '19 at 16:37
  • @Kukeltje hey brother I think I found the mistake, it works with the other way if I add another "/" at the begining like so: /../movimientos/solicitartraslados.xhtml?faces-redirect=true is that natural for you? But I don't know how can we create a reproducible example for this bro, maybe we can go in chat and I show you complete code? – BugsForBreakfast Aug 09 '19 at 16:40
  • It is **never** about **complete code**. It is about a [mcve]. So two almost empty pages in different, one with a commandButton and an action that redirects to another relative page is difficult? I'm 100% sure your partners can help you with this – Kukeltje Aug 09 '19 at 17:33
  • And what you found does not feel it should be needed, but I read similar things in the PrimeFaces issuelist. Dit you comment on the issue? – Kukeltje Aug 09 '19 at 17:35
  • @Kukeltje I haven't commented this particular issue mate, can you give me the link I will check if it is something similar – BugsForBreakfast Aug 09 '19 at 19:12
  • Sigh, the link is in the 2nd comment... read, act instead of asking in comments... – Kukeltje Aug 09 '19 at 19:15
  • @Kukeltje though it was another one different mate, not sure if that is related to my problem, I will do some tests, but this is strange, do you think there is a problem if I leave it like this? /XHTML/movimientos/solicitartraslados.xhtml?faces-redirect=true – BugsForBreakfast Aug 09 '19 at 19:24
  • 1
    Absolute is fine.. – Kukeltje Aug 09 '19 at 20:19

0 Answers0