Domanda

I'm been scratching my head over this one... I have plenty of projects with a working commandLink element, however I cannot for the life of me get it to work in this project. I've followed BalusC response here: commandButton/commandLink/ajax action/listener method not invoked or input value not updated down to the letter and yet still no joy.

Currently I've boiled my code down to as simple as it can go:

@ManagedBean
@SessionScoped
public class TestBean {

    private @Inject transient Logger logger; 

    public void testEvent(ActionEvent actionEvent) {
        logger.log(Level.INFO, "Event Fired!!");
        return;
    }
}

In my xhtml file i have:

<h:form>
   <h:commandLink id="test" actionListener="#{testBean.testEvent}" value="Test Me!"/>
</h:form>

When I click the link, the method is not invoked, and I am redirected to the web-apps root (login page, despite having a login filter :/) If I change the link to a commandButton it works as expected.

The current application utilises the ui:composition tags for templating, and I've triple checked for nested h:form tags, I'm not using any ajax calls or additional JS libraries. My templates implement jsf tags where it matters i.e. h:head, h:body etc.. Could anyone provide any indication or possible causes for the weird behavior I am experiencing?

Finally I have tested this commandLink in on various pages within my web-app and the commandLink element in general just refuses to invoke.

Here is the compiled html of my link if anyone is interested:

<form id="j_idt26" name="j_idt26" method="post" action="/my-project/webpages/Login.xhtml" enctype="application/x-www-form-urlencoded">
   <input type="hidden" name="j_idt26" value="j_idt26" />
   <a id="j_idt26:test" href="#" onclick="mojarra.jsfcljs(document.getElementById('j_idt26'),{'j_idt26:test':'j_idt26:test'},'');return false">Test Me!</a><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-109553560791909389:-730254890454894147" autocomplete="off" />
</form>
È stato utile?

Soluzione

After rebuilding the project, commandLinks work as they should and I was unable to reproduce the error in my new project. If I get time, I will try and debug my original project and determine what the original issue is/was.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top