0

The managed bean involved.

@Named
@ViewScoped
public class Bean implements Serializable {

    public Bean() {}

    private static final long serialVersionUID = 1L;

    public String navigate() {
        System.out.println("navigate() invoked.");
        // This method carries some logic here.
        return "/ContextPath/location/page.xhtml?faces-redirect=true";
    }
}

Now, using a command component with action is expected to redirect to a said resource.

<h:form>
    <p:commandButton value="Submit" action="#{bean.navigate}"/>
</h:form>

This is however, always untrue no matter ajax is set to false or using another command component like <p|h:commandLink>. The action method is invoked as usual in either case but it does not perform navigation.

Replacing the action method directly with a navigation case outcome such as,

<p:commandButton value="Submit"
                 action="/ContextPath/location/page.xhtml?faces-redirect=true"/>

does not make any difference.

Is this really expected?

This is a kind of very basic question but I do not find at least direct answers in other already asked questions.


Using Mojarra 2.2.12 and PrimeFaces 5.2 (community bundle).

Tiny
  • 27,221
  • 105
  • 339
  • 599
  • If the `/ContextPath` indeed represents the context path, it does not belong there. An absolute outcome is already interpreted relative to context root. Retry with `/location/page.xhtml?faces-redirect=true`. – BalusC Oct 04 '15 at 12:57
  • 1
    I wonder if you didn't get a warning in server log like [Unable to find matching navigation case with from-view-id](http://stackoverflow.com/questions/13963170/unable-to-find-matching-navigation-case-with-from-view-id-pages-index-xhtml/) (which is essentially a duplicate) – BalusC Oct 04 '15 at 13:02
  • I removed the application's context path but the behaviour did not change. `

    ` and `

    ` invoke the action method in the bean as usual but they do not perform navigation. I see no warning on the server log. This also does not go : ``. This however, worked on a test project. There should be a hidden problem somewhere in the real application itself where no warning is raised even though a navigation case outcome is deliberately given wrong in a single test XHTML file.

    – Tiny Oct 04 '15 at 14:45
  • Awkward. Let me look .. Just in case, action method is really invoked? And, which server exactly? – BalusC Oct 04 '15 at 15:03
  • It is GlassFish 4.1. The method is invoked. I guessed there is a hidden problem in the application which is still to be uncovered. This has likely a correlation with [this](http://stackoverflow.com/q/27795529/1391249) and probably [this](http://stackoverflow.com/q/26741693/1391249) too. – Tiny Oct 04 '15 at 15:08
  • Any custom navigation handlers in the application? – BalusC Oct 04 '15 at 15:18
  • Like [this](http://stackoverflow.com/a/23435870/1391249). The last example - the third point (`public class ViewParamValidationFailed extends TagHandler implements ComponentSystemEventListener {...}`). – Tiny Oct 04 '15 at 15:21
  • `ComponentSystemEventListener` was replaced by `SystemEventListener` and `isListenerForSource()` was overridden afterwards in the tag handler class as stated [here](http://stackoverflow.com/a/23872616/1391249). – Tiny Oct 04 '15 at 15:51
  • In addition to the context path, there was a ridiculous oversight in the XHTML file name. `page.xhtml` was actually `Page.xhtml` beginning with a capital letter (It should have certainly thrown an appropriate exception but it did not due to a [previous problem](http://stackoverflow.com/q/27795529/1391249) which still remains abandoned without any logical reason). – Tiny Oct 27 '15 at 16:39

0 Answers0