I can't make my commandLink fire a bean action.
I've tried calling my bean method with <p:commandButton>
, <h:commandLink>
, <h:outputLink>
and <p:commandLink>
.
Also, i've used onclick
, onmousedown
, action
and actionListener
and none of those worked.
My code looks like this at the moment:
base.xhtml
<div>
<h:form>
<p:commandLink id="logoutButton" action="#{loginController.logout}">
<p:graphicImage name="/images/logout.png"/>
</p:commandLink>
</h:form>
<!-- Rest of code (layout with some layoutUnits) -->
</div
Bean method (Testing purposes, not the actual method):
public void logout() {
System.out.println("logged out");
}
According to BalusC, my question is duplicated. I had already searched for similar problems before making this question, and guess what? Nothing worked. Looking at same question that has already been answered, here are my answers to the previously described problems:
1 - The commandLink is inside a form
.
2 - The commandLink is not in a nested form
.
3 - No UIInput value validation/conversion is showing errors.
4 - The commandLink is not inside a iterating component.
5 - As the pages load, the button is not rendered. I've set it to render only if the user log-ins with a commandLink placed in that same form. It is indeed using AJAX.
6 - The onclick attribute of the UICommand component and the onsubmit attribute of the UIForm are not throwing a JavaScript error.
7 - base.xhtml
has a <h:head>
8 - The parent of my <h:form>
is not being updated/rendered.
9 - Im not using enctype="multipart/form-data"
in my form.
10 - I'm not using actionListener
.
11 - I'm not using PhaseListener
or EventListener
.
12 - There is no Filter
or Servlet
blocking the request to the FacesServlet.
Bonus:
- Debugging with Firebug, i've noticed that when i click the logout button i'm getting a code 200 response from the server, meaning it is
supposed
to be OK. - My form is in a Template file (base.xhtml). After that form, i am using a
<p:layout>
element and my website code is inside it's<p:layoutUnit>
.