2016-02-05 27 views
1

我有以下代碼。當在密碼字段中按回車鍵時,要通過「selectAllEssie3S1_1」調用spring webflow功能,然後調用控制器功能。但是我發現這個函數在調試時沒有被調用。有什麼不對的嗎??primefaces密碼控制與按回車調用webflow功能

<p:password id="encryptedKey" value="#{chkTeacherList.encryptedKeyValue}" 
onkeypress="if (event.keyCode == 13) { onchange(); return false; }"> 
<p:ajax event="change" action="selectAllEssie3S1_1" update="gridItemName" > 
</p:ajax> 
</p:password> 

回答

1

看看這段代碼,也許可以幫助你

<p:remoteCommand name="test" actionListener="#{chkTeacherList.test}"/> 
<p:password id="encryptedKey" value="#{chkTeacherList.encryptedKeyValue}" 
    onkeypress="if (event.keyCode == 13) { test(); return false; }"/> 
and in backing bean: 

public void test() { 
System.out.println("Pressed enter! value :"+encryptedKeyValue); 
} 
+0

我需要傳遞的參數例如控制器功能statusBean.test(RequestContext ...) –

+0

喲可以傳遞參數給remoteCommand看看這個答案:http://stackoverflow.com/questions/7221495/pass-parameter-to-premotecommand-from-javascript,但如果你想要從bean中直接獲取一些值直接在bean方法 – ZaoTaoBao

+0

上,並且如果你想直接用springwebflow連接remoteCommand嘗試添加動作屬性和轉換名稱 – ZaoTaoBao