0

While switching to admin panel, I set request attribute to show back button:

public void adminPanel() {
    Tools.getRequestContext().setAttribute("show_back_button", true);
}

Now in JSP page I check if this attribute exists:

<c:if test="${show_back_button eq true}">
    <h:commandButton action="index?faces-redirect=true"
        immediate="true"
        type="submit"
        value="#{msg.back}"
        styleClass="btn btn-default admin-button" />
</c:if>

After first entering admin panel, I have visible Back button. But when clicked, redirection to index.xhtml wasn't fired, but admin.xhtml is refreshing.

When I comment and everything is working fine and, back button is always visible, but is working.

So my question is what happens if show_back_button attribute is not set and I will test it with EL? JSF phases are corrupted? Maybe something else? What am I doing wrong?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    If you don't do any logic after submitting (form?) with `h:commandButton` consider using `h:button` for only navigation purposes. http://stackoverflow.com/questions/13070537/difference-between-hbutton-and-hcommandbutton – Geinmachi Oct 07 '15 at 20:04

1 Answers1

0

It looks like I found a solution. Added

<context-param>
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    <param-value>false</param-value>
</context-param>

simply resolve problem. Something with ViewState and tag is crux.

Thanks to http://balusc.omnifaces.org/2011/09/communication-in-jsf-20.html#ViewScopedFailsInTagHandlers post. I must investigate this problem deeper and deeper...