2014-06-17 73 views
0

我使用jsf2.0。我的代碼是這樣的:h:commandLink與f:ajax不起作用

<h:form id="form"> 
    <h:commandButton value="testbutton" action="#{Bean.test}"> 
     <f:ajax render="msg"/> 
    </h:commandButton> 
    <h:outputText value="#{Bean.outmsg}" id="msg"/> 
</h:form> 

它運行良好。 但如果我改變H:命令按鈕到h:commandlink, 代碼如下所示:

<h:form id="form"> 
    <h:commandLink value="testbutton" action="#{Bean.test}"> 
     <f:ajax render="msg"/> 
    </h:commandLink> 
    <h:outputText value="#{Bean.outmsg}" id="msg"/> 
</h:form> 

然後我的代碼不能工作。 我需要幫助,謝謝你們。

+0

這是什麼意思_my代碼不能work_?同時顯示託管的bean。 – perissf

+0

的意思是改變爲commandlink,那麼#{Bean.test}將不會被調用 – user3748888

回答

2

使用此代碼。

<f:ajax event="click" render="msg" listener="#{Bean.test}"/> 

應該是你的java bean的一面吧。

public void test(AjaxBehaviorEvent event) { } 
相關問題