JSF commandButton问题

时间:2014-07-08 17:01:30

标签: jsf jsf-2

我正在使用JSF提供搜索功能。我得到列表并在数据表中正确显示:

<p:dataTable id="props" var="prop" value="#{propController.propSearch}" editable="true" style="margin-bottom:20px">
    <p:column headerText="Id" width="20">                                       
        <h:outputText value="#{prop.id}" />
    </p:column>
    <p:column headerText="Name" width="300">                  
        <h:outputText value="#{prop.name}"/>                                                               
     </p:column>  
     <p:column headerText="Description">
         <h:outputText value="#{prop.shortDescription}" />                 
     </p:column>  
     <p:column headerText="Price" width="120">               
         <h:outputText value="#{prop.price}" />
     </p:column>  
     <p:column width="120">                 
         <h:commandButton value="View Prop" immediate="true" action="#{propController.viewSingleProp(prop)}" />                 
     </p:column>
     <p:column width="120">                 
         <h:commandButton value="Delete" immediate="true" onclick="return confirm('Are you sure you want to delete this prop?')" actionListener="#{propController.deleteProp(prop)}" />                                    
     </p:column> 

</p:dataTable>
</h:form>    

但是,不会调用commandButton来查看每个单独的项目。相反,搜索页面只刷新而没有数据。

为什么会这样?

1 个答案:

答案 0 :(得分:0)

(我希望您问题中的代码中缺少<h:form>的开头标记,而不是实际代码中的代码!)

您需要从immediate="true"删除属性h:commandButton

请参阅: