2011-01-27 25 views
2

setPropertyActionListener不工作我有下面的代码:F:当simpleModal工作

<h:commandLink value="#{bean.lastName}" onclick="$('#popDiv').modal(); return false;"> 
    <f:setPropertyActionListener target="#{personController.person}" value="#{bean}" /> 
</h:commandLink> 

的问题是,为了使(的SimpleModal)无法打开和关闭马上我必须使用模式面板“返回false “什么时候发生”onclick“。但是“返回false”会导致f:setPropertyActionListener无效。 可以做些什么来使他们都工作?

在此先感谢。

+0

工作你找到一个解决办法? – Sydney 2011-07-12 16:40:29

回答

1

你可以这样做:

<h:commandLink value="#{bean.lastName}" onclick="openModal(event);"> 
    <f:setPropertyActionListener target="#{personController.person}" value="#{bean}" /> 
</h:commandLink> 

function openModal(e) { 
    e.preventDefault(); 
    $('#popDiv').modal(); 
} 
+0

因为`f:setPropertyActionListener`运行在服务器端,而不是客户端,所以不起作用。因此,与'h:commandLink`关联的HTTP请求必须到服务器端才能运行。 – BalusC 2011-02-01 18:22:35

1

你需要

<p:commandLink value="#{bean.lastName}" onclick="openModal(event);"> 
    <f:setPropertyActionListener target="#{personController.person}" value="#{bean}" /> 
</p:commandLink>