0

I'm having this really weird issue where my commandLinkonly work if I have BOTH links in the same view.

Works fine, both links:

<ui:composition template="../../template.xhtml" xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://xmlns.jcp.org/jsf/html"
            xmlns:p="http://primefaces.org/ui"
            xmlns:f="http://xmlns.jcp.org/jsf/core"
            xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <ui:define name="content">
        <h:form>
            <p:dataTable var="v" value="#{myBean.myList}">
                <p:column headerText="Name">
                    <h:commandLink value="Go to next page" action="#{myBean.doThing(v)}" />
                    <p:commandLink value="Go to next page" action="#{myBean.doThing(v)}" />
                </p:column>
            </p:dataTable>
            <p:commandButton value="Submit" ajax="false" actionListener="#{myBean.submit}" />
        </h:form>
    </ui:define>
</ui:composition>

But if I remove either link, it doesn't even reach the method doThing() and reloads an empty page.

My bean:

@ManagedBean(name="myBean")
@RequestScoped
public class MyBean {
    private List<Object> myList = new ArrayList<>();
    public MyBean() {
    }

    public String doThing(Object obj) {
        // This never prints if I remove one of the links
        System.out.println("You're doing the thing!");
        return "nextView?faces-redirect=true"
    }

    // Getters, setters etc.
}

I'm using JSF 2.0 and GlassFish 4.0.

How can I fix this and why is it happening?

I have a commandLink in a p:dataTable in another view and it's working fine.

EDIT:

Added the complete XML for the composition part of the view. The partial is inside a template:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <!-- css imports, titles etc -->
    </h:head>
    <h:body>
        <ui:insert name="menu">
            <ui:include src="./default/content.xhtml" />
        </ui:insert>
    </h:body>
</html>
Community
  • 1
  • 1
Gemtastic
  • 6,253
  • 6
  • 34
  • 53

0 Answers0