2017-02-23 9 views
0

を無視されます。私のactionListenerが、私はこのフォームを持つJSFページ持って

< F:のactionListenerは= "#{historicCtrl.insertSearchを結合

<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 > 

を問題は、その行であります(2)} "/>

私は無視され、理由はわかりません。

は、私は、コードを簡単にバージョン試してみました:これは1が動作している

<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以外はすべて自然に動作しています。

この命令は何故ですか?

答えて

0

あなたのコードは本当に混乱しますが、私はその質問に集中して、あなたのコードがどのように見えるかの例を提供します。

あなたはActionListenerをバインドしたい場合は、例えば、ActionListenerの-インタフェースを実装するオブジェクトにしていないメソッドにバインドする必要があります。

にfacelet

<f:actionListener binding="#{historicCtrl}" /> 

のActionListener

@ManagedBean 
@ViewScoped 
public class HistoricCtrl implements Serializable, ActionListener { 

    private static final long serialVersionUID = 6307961450435094233L; 

    @Override 
    public void processAction(ActionEvent e) throws AbortProcessingException { 
     // TODO implement 
    } 
} 

バインディングを使用すると、あなたの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> 
関連する問題