Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
p:remoteCommand being invoked, but not the action method

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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda