I am having some trouble getting a p:remoteCommand to work, it is defined as follows:
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
template="/template.xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
<h:form id="form" enctype="multipart/form-data" >
<p:remoteCommand name="connectionTest" action="#{entry.checkConnection}" oncomplete="console.log('BAR');" style="display: none;"/>
<p:inputText id="dummy" required="true" value="#{entry.X}" disabled="#{entry.disabled}" />
<script type="text/javascript">
$(function() {
$(document).ready(async function () {
console.log('foo');
connectionTest();
});
});
</script>
</h:form>
</ui:define>
</ui:composition>
And a bean method in a ViewScoped bean named "entry":
public void checkConnection() {
...do stuff
}
The remote command is invoked, as foo and BAR are printed to the console, but the actual bean method checkConnection is not being invoked. I have tried all permutations of action vs actionListener and entry.checkConnection vs entry.checkConnection().
The remoteCommand and script tags are in the same h:form inside a ui:define inside a ui:composition. What am I missing?
Edit: after some trial and error, it seems related to having a required="true" p:inputText on the same form. I have updated my question accordingly. Moving the p:remoteCommand out of the form seems to make it work, but I still am unsure why a p:remoteCommand inside a form with a required p:inputText does not work.