Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 我的actionListener被忽略了_Jsf - Fatal编程技术网

Jsf 我的actionListener被忽略了

Jsf 我的actionListener被忽略了,jsf,Jsf,我有一个jsf页面,其中有以下表单: <h:commandButton id="submit" value="Submit"> <h:inputText id="locationInputId" value="#{historicCtrl.historic.search}" ></h:inputText> <f:ajax event="click" render="resultGrou

我有一个jsf页面,其中有以下表单:

<h:commandButton id="submit" value="Submit">


                <h:inputText id="locationInputId" value="#{historicCtrl.historic.search}" ></h:inputText>

                <f:ajax event="click" render="resultGroup" listener="#{cSVobjectCtrl.doRender}"/>
                <label for="lat">Latitude</label>
                <h:inputText id="lat" value="#{cSVobjectCtrl.lat}"/>
                <label for ="lng">Longitude</label>
                <h:inputText id="lng" value="#{cSVobjectCtrl.lng}"/>
                <f:actionListener binding="#{historicCtrl.insertSearch(2)}"/>
            </h:commandButton >

纬度
经度
问题是线路:

被忽略了,我不知道为什么

我尝试了更简单的代码版本:

<h:form>
            <h:outputText value="Lieu"/>
            <h:inputText id="login" value="#{historicCtrl.historic.search}" required="true"></h:inputText>   
            <br/>

            <h:commandButton value="Search">
               <h:outputText id ="textToInsertId" value="#{historicCtrl.insertSearch(2)}"/>
            </h:commandButton>
        </h:form>


这一个正在工作,我可以看到该方法应该在控制台上打印的跟踪,并且在我的数据库中有插入

相反,我在消息中编写的第一个代码没有按预期工作。事实上,除了f之外,一切都在自然运行;正如我上面解释的那样


为什么不使用此指令?

您的代码确实令人困惑,但我将集中讨论这个问题,并提供一个示例,说明您的代码应该是什么样子

如果要绑定actionListener,必须将其绑定到实现actionListener接口的对象,而不是方法,例如:

facelet

<f:actionListener binding="#{historicCtrl}" />
如果使用绑定,则无法将参数传递给actionListener。更好的方法是使用h:commandButton的actionListener属性。在这种情况下,您的代码应该如下所示:

<h:form id="form">
     <h:inputText id="locationInputId" value="#{historicCtrl.historic.search}" />

     <br />

     <h:outputLabel for="lat" value="Latitude" />
     <h:inputText id="lat" value="#{cSVobjectCtrl.lat}"/>

     <br />

     <h:outputLabel for="lng" value="Longitude" />
     <h:inputText id="lng" value="#{cSVobjectCtrl.lng}"/>

     <br />

     <h:commandButton id="submit" value="Submit" actionListener="#{historicCtrl.insertSearch(2)}">
        <f:ajax execute="form" render="resultGroup" listener="#{cSVobjectCtrl.doRender}"/>
     </h:commandButton>
</h:form>




<h:form id="form">
     <h:inputText id="locationInputId" value="#{historicCtrl.historic.search}" />

     <br />

     <h:outputLabel for="lat" value="Latitude" />
     <h:inputText id="lat" value="#{cSVobjectCtrl.lat}"/>

     <br />

     <h:outputLabel for="lng" value="Longitude" />
     <h:inputText id="lng" value="#{cSVobjectCtrl.lng}"/>

     <br />

     <h:commandButton id="submit" value="Submit" actionListener="#{historicCtrl.insertSearch(2)}">
        <f:ajax execute="form" render="resultGroup" listener="#{cSVobjectCtrl.doRender}"/>
     </h:commandButton>
</h:form>