0
所以我本來我有一個所有命令鏈接形式停止工作AJAX請求後
<h:selectBooleanCheckbox value="#salesExpenseController.addSalesExpense.fixed}" >
<h:ajax event="change" listener="#{salesExpenseController.checkFixed()}" render = "addBidPrice addBidTotal" />
</h:selectBooleanCheckbox>
監聽功能:
public String checkFixed() {
if (this.getAddSalesExpense().getFixed()) {
if (this.subOperation.equals(_add)) {
getAddSalesExpense().setBidPrice(BigDecimal.ZERO);
}
if (this.subOperation.equals(_edit)) {
getEditSalesExpense().setBidPrice(BigDecimal.ZERO);
}
} else {
if (this.subOperation.equals(_add)) {
getAddSalesExpense().setBidTotal(BigDecimal.ZERO);
}
if (this.subOperation.equals(_edit)) {
getEditSalesExpense().setBidTotal(BigDecimal.ZERO);
}
}
return _viewTimberSale;
}
每當我點擊我的複選框,在表單中的所有其他命令鏈接會不行。我在我的checkFixed()中放置了一個System.out.println(),並且ajax請求沒有到達函數或給出任何錯誤,就像沒有任何事情發生一樣。
我改變我的複選框,此修復了這個問題:
<h:selectBooleanCheckbox value="#{salesExpenseController.addSalesExpense.fixed}" >
<p:ajax event="change" listener="#{salesExpenseController.checkFixed()}" update = "addBidPrice addBidTotal" />
</h:selectBooleanCheckbox>
而且一切正常,這也正是它應該。
什麼是可能的解釋?
這裏是形式的故障部件,我不能發佈它會超過30,000個字符的整個形式:
<!-- START SALES EXPENSE -->
<h:panelGroup layout="block" rendered="#{timberSaleController.operation.equals(timberSaleController.saleExpense)}">
<h1>Sale Expense</h1>
<h:panelGroup layout="block">
<h:commandLink styleClass="actionLinkButton" value="#{messages.Link_add}" action="#{salesExpenseController.prepareAddSalesExpense(timberSaleController.selected)}" rendered="#{salesExpenseController.subOperation == null}" />
<h:commandLink styleClass="actionLinkButton" value="#{messages.Link_cancel}" action="#{salesExpenseController.resetValues()}" rendered="#{salesExpenseController.subOperation != null}" />
<br/>
<br/>
</h:panelGroup>
<!--SALES EXPENSE TABLE -->
<h:panelGroup layout="block" rendered="#{salesExpenseController.subOperation == null}">
<h:dataTable value="#{salesExpenseController.getSaleList(timberSaleController.selected)}" var="exp"
border="0"
cellpadding="3"
cellspacing="0"
rowClasses="jsfcrud_odd_row,jsfcrud_even_row"
rules="all"
style="border:solid 1px; text-align: center;"
rendered ="#{salesExpenseController.getSaleList(timberSaleController.selected).size() > 0}"
>
<h:column>
<f:facet name="header">
<h:outputText value="#{messages.Title_description}" />
</f:facet>
<h:outputText value="#{exp.description}" >
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{messages.Title_category}" />
</f:facet>
<h:outputText value="#{timberSaleController.formatString(exp.expenseCategory)}" >
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{messages.Title_fixedPrice}" />
</f:facet>
<h:outputText value="#{exp.fixed}" >
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{messages.Title_bidPrice}" />
</f:facet>
<h:outputText value="#{exp.bidPrice}" >
<f:convertNumber integerOnly="true" type="currency" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{messages.Title_bidTotal}" />
</f:facet>
<h:outputText value="#{exp.bidTotal}" >
<f:convertNumber integerOnly="true" type="currency" />
</h:outputText>
</h:column>
<h:column rendered = "#{exp.actualPrice != null}">
<f:facet name="header">
<h:outputText value="#{messages.Title_actualPrice}" />
</f:facet>
<h:outputText value="#{exp.actualPrice}" >
<f:convertNumber integerOnly="true" type="currency" />
</h:outputText>
</h:column>
<h:column rendered = "#{exp.actualTotal != null}">
<f:facet name="header">
<h:outputText value="#{messages.Title_actualTotal}" />
</f:facet>
<h:outputText value="#{exp.actualTotal}" >
<f:convertNumber integerOnly="true" type="number" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{messages.Title_lastEdited}" />
</f:facet>
<h:outputText value="#{exp.lastEdited}" >
<f:convertDateTime type="date" dateStyle="short" />
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{messages.Title_lastEditedBy}" />
</f:facet>
<h:outputText value="#{exp.lastEditedBy}" >
</h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value=" " />
</f:facet>
<h:commandLink value="#{messages.Link_edit}" action ="#{salesExpenseController.editSalesExpense(exp)}" />
<br/>
<h:commandLink value="#{messages.Link_complete}" action="#{salesExpenseController.prepareCompleteSalesExpense(exp)}" />
</h:column>
</h:dataTable>
<br/>
<br/>
<br/>
<h:panelGroup layout="block">
<table
border="0"
cellpadding="3"
cellspacing="0"
rowClasses="jsfcrud_odd_row,jsfcrud_even_row"
rules="all"
style="border:solid 1px; text-align: center;"
>
<tr>
<th>Categories</th>
<th>Average Bid Price</th>
<th>Bid Total</th>
</tr>
<ui:repeat value="#{salesExpenseController.getDistinctCategoriesBySale(timberSaleController.selected)}" var="cat">
<tr>
<td>
<h:outputText value="#{timberSaleController.formatString(cat)}" />
</td>
<td>
<h:outputText value="#{salesExpenseController.getAverageExpensePriceByCategoryAndSale(cat , timberSaleController.selected)}" >
<f:convertNumber integerOnly="true" type="currency"/>
</h:outputText>
</td>
<td>
<h:outputText value="#{salesExpenseController.getTotalExpenseByCategoryAndSale(cat, timberSaleController.selected)}" >
<f:convertNumber integerOnly="true" type="currency"/>
</h:outputText>
</td>
</tr>
</ui:repeat>
<tr>
<td>
<h:outputText value ="Totals" />
</td>
<td>
<h:outputText value ="#{salesExpenseController.getAverageBidPriceBySale(timberSaleController.selected)}" >
<f:convertNumber integerOnly="true" type="currency"/>
</h:outputText>
</td>
<td>
<h:outputText value ="#{salesExpenseController.getTotalBidTotalBySale(timberSaleController.selected)}" >
<f:convertNumber integerOnly="true" type="currency"/>
</h:outputText>
</td>
</tr>
</table>
</h:panelGroup>
</h:panelGroup>
<!--SALES EXPENSE ADD -->
<h:panelGroup layout="block" rendered="#{salesExpenseController.subOperation.equals(timberSaleController.getAdd())}">
<h:panelGrid columns="3">
<h:outputLabel value="#{messages.Title_description}" />
<h:inputTextarea value="#{salesExpenseController.addSalesExpense.description}" />
<h:outputText value=" " />
<h:outputLabel value="#{messages.Title_category}" />
<h:selectOneMenu value="#{salesExpenseController.addSalesExpense.expenseCategory}">
<f:selectItems value="#{timberSaleController.dropDownHelper.getExpenseTypeSelectOne()}" />
</h:selectOneMenu>
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_fixed}" />
<h:selectBooleanCheckbox value="#{salesExpenseController.addSalesExpense.fixed}" >
<p:ajax event="change" listener="#{salesExpenseController.checkFixed()}" update = "addBidPrice addBidTotal" />
</h:selectBooleanCheckbox>
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_bidPrice}" />
<h:inputText id="addBidPrice" value="#{salesExpenseController.addSalesExpense.bidPrice}" disabled="#{salesExpenseController.addSalesExpense.fixed}" />
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_bidTotal}" />
<h:inputText id="addBidTotal" value="#{salesExpenseController.addSalesExpense.bidTotal}" disabled="#{!salesExpenseController.addSalesExpense.fixed}" />
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<h:commandLink styleClass="actionLinkButton" value="#{messages.Link_add}" action="#{salesExpenseController.addSaleExpenseToSale()}" />
</h:panelGrid>
</h:panelGroup>
<!--SALES EXPENSE EDIT -->
<h:panelGroup layout="block" rendered="#{salesExpenseController.subOperation.equals(timberSaleController.getEdit())}">
<h:panelGrid columns="3">
<h:outputLabel value="#{messages.Title_description}" />
<h:inputTextarea value="#{salesExpenseController.editSalesExpense.description}" />
<h:outputText value=" " />
<h:outputLabel value="#{messages.Title_category}" />
<h:selectOneMenu value="#{salesExpenseController.editSalesExpense.expenseCategory}">
<f:selectItems value="#{timberSaleController.dropDownHelper.getExpenseTypeSelectOne()}" />
</h:selectOneMenu>
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_fixed}" />
<h:selectBooleanCheckbox value="#{salesExpenseController.editSalesExpense.fixed}" >
<p:ajax event="change" listener="#{salesExpenseController.checkFixed()}" update="editBidPrice editBidTotal" />
</h:selectBooleanCheckbox>
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_bidPrice}" />
<h:inputText id="editBidPrice" value="#{salesExpenseController.editSalesExpense.bidPrice}" disabled="#{salesExpenseController.editSalesExpense.fixed}" />
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_bidTotal}" />
<h:inputText id="editBidTotal" value="#{salesExpenseController.editSalesExpense.bidTotal}" disabled="#{!salesExpenseController.editSalesExpense.fixed}" />
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<h:commandLink styleClass="actionLinkButton" value="#{messages.Link_complete}" action="#{salesExpenseController.completeEditSalesExpense()}" />
<h:commandLink styleClass="actionLinkButton" value="#{messages.Link_destroy}" action="#{salesExpenseController.destroyEditSalesExpense()}" />
</h:panelGrid>
</h:panelGroup>
<!--
COMPLETE LOG SALE
-->
<h:panelGroup layout="block" rendered="#{salesExpenseController.subOperation.equals(timberSaleController.getComplete())}">
<h:panelGrid columns="3">
<h:outputLabel value="#{messages.Title_description}" />
<h:inputTextarea disabled="true" value="#{salesExpenseController.completeSalesExpense.description}" />
<h:outputText value=" " />
<h:outputLabel value="#{messages.Title_category}" />
<h:selectOneMenu disabled="true" value="#{salesExpenseController.completeSalesExpense.expenseCategory}">
<f:selectItems value="#{timberSaleController.dropDownHelper.getExpenseTypeSelectOne()}" />
</h:selectOneMenu>
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_fixed}" />
<h:selectBooleanCheckbox disabled="true" value="#{salesExpenseController.completeSalesExpense.fixed}" >
<p:ajax event="change" listener="#{salesExpenseController.checkFixed()}" update="" />
</h:selectBooleanCheckbox>
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_bidPrice}" />
<h:inputText value="#{salesExpenseController.completeSalesExpense.bidPrice}" disabled="#{salesExpenseController.completeSalesExpense.fixed}" />
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_actualPrice}" />
<h:inputText value="#{salesExpenseController.completeSalesExpense.actualPrice}" disabled ="#{salesExpenseController.completeSalesExpense.fixed}" />
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_bidTotal}" />
<h:inputText value="#{salesExpenseController.completeSalesExpense.bidTotal}" disabled="#{!salesExpenseController.completeSalesExpense.fixed}" />
<h:outputText value=" " />
<h:outputLabel value="#{messages.Label_actualTotal}" />
<h:inputText value="#{salesExpenseController.completeSalesExpense.actualTotal}" disabled ="#{!salesExpenseController.completeSalesExpense.fixed}" />
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<h:outputText value=" " />
<h:commandLink styleClass="actionLinkButton" value="#{messages.Link_complete}" action="#{salesExpenseController.completeCompleteSalesExpense()}" />
</h:panelGrid>
</h:panelGroup>
</h:panelGroup>
<!-- END ADD SALESEXPENSE -->
如果您閱讀了您的標題並查看了您發佈的代碼,您是否認爲代碼中缺少某些內容? – Kukeltje
TLDR;你不能創建[mcve]嗎? – Kukeltje
查看你的JS控制檯的線索,只要你點擊「不起作用」 – kolossus