[英]Command Button wont work primefaces
我有xhtml頁面,其中的數據網格中有數據網格,我想通過使用我編碼如下的按鈕或鏈接按鈕來調用方法
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>TODO supply a title</title>
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="center">
<p:graphicImage value="images/common/banner1.png"
style="width: 100%;min-width: 1350px"/>
<h:form id="menu_bar_form">
<p:menubar style="font-size: 14px;min-width: 1340px;" >
<p:menuitem style="width: 50px" disabled="true"/>
<p:menuitem value="HOME" url="home.xhtml"/>
<p:menuitem style="width: 100px" disabled="true"/>
<p:submenu label="PHONES">
<p:menuitem value="Apple" outcome="phones">
<f:param name="brand" value="Apple"/>
</p:menuitem>
<p:menuitem value="Motorola" outcome="phones">
<f:param name="brand" value="Motorola"/>
</p:menuitem>
<p:menuitem value="Nokia" outcome="phones">
<f:param name="brand" value="Nokia"/>
</p:menuitem>
<p:menuitem value="Samsung" outcome="phones">
<f:param name="brand" value="Samsung"/>
</p:menuitem>
</p:submenu>
<p:menuitem style="width: 100px" disabled="true"/>
<p:menuitem value="COMPARE"/>
<p:menuitem style="width: 100px" disabled="true"/>
<p:submenu label="ACCESSORIES">
//ADD CONTENT
</p:submenu>
<p:menuitem style="width: 100px" disabled="true"/>
<p:menuitem value="CONTACT"/>
<f:facet name="options">
<h:panelGrid columns="2" style="font-size: 12px">
<p:autoComplete id="search_textBox" value="#{homeBean.searchItem}"
completeMethod="#{homeBean.search}"/>
<p:commandButton value="Search" icon="ui-icon-search" />
</h:panelGrid>
</f:facet>
</p:menubar>
</h:form>
<h:form id="page_content">
<table cellspacing="2" style="font-size: 14px;
width: 100%;min-width: 1350px">
<thead>
<tr>
<th></th>
<th style="width: 1000px;text-align:center">
<p:dataGrid var="phone" value="#{phonesBean.phoneList}" columns="8"
rows="12" paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="9,12,15" style="text-align: center;">
// ++++++++++++++++++++++++++++++++++++ Problem++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<p:panel header="#{phone.model}" style="width: 175px" >
<h:panelGrid columns="1" style="width:100%">
<p:graphicImage value="#{phone.imageUrl}"/>
</h:panelGrid>
<p:commandButton value="click here" action="#{phonesBean.test()}"/>
</p:panel>
//+++++++++++++++++++++++++++++++++++Problem+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
</p:dataGrid>
</th>
<th></th>
</tr>
</thead>
</table>
</h:form>
</p:layoutUnit>
</p:layout>
</h:body>
我調試了代碼,但是測試方法不會調用。 並且沒有任何異常或錯誤。
在EL中寫方法名稱,不帶括號,並添加ajax="false"
<p:commandButton value="click here" action="#{phonesBean.test}" ajax="false"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.