faces-redirect working when hard coded into xhtml but not from result of method call

Viewed 26

I'm trying to make sure the url reflects the current page properly.

When I change page this way:

     <h:form>
        <h3>Redirect</h3>
        <h:commandButton type="submit" action = "page1?faces-redirect=true" value = "Page1" />
    </h:form>

it works properly updating the page to "webapp/page1.xhtml"

But when I update it through a method call:

    <h:form>
        <h:commandButton type="submit" action="#{navigationController.showPage}"
                         value="Page1">
            <f:setPropertyActionListener target="#{navigationController.pageId}" value="1"/>
        </h:commandButton>

    </h:form>

With java code

    public String showPage() {
    if (pageId == null) {
        return "home";
    }
    if (pageId.equals("1")) {
        return "page1?faces-redirect = true";
    } else {
        return "home";
    }

It won't update properly despite moving to the right page.

0 Answers
Related