コントローラでイベントが発生しません。これがコードです。f:hのAjaxリスナーが起動しません:selectBooleanCheckbox
ビュー:
<ui:repeat var="operation" value="#{trade.operationsSortList}">
<tr class="operations">
<th class="empty_cell"></th>
<td id="operation" class="operation_cell color">#{operation.operation}</td>
<td class="color">#{operation.time}</td>
<td class="color">#{operation.coment}</td>
<td class="color">
<h:form>
<h:selectBooleanCheckbox>
<f:ajax event="click" listener="#{controller.onDelete}" />
<f:attribute name="trade" value="#{trade}" />
</h:selectBooleanCheckbox>
</h:form>
</td>
</tr>
</ui:repeat>
コントローラー:事前に
@ManagedBean
@RequestScoped
public class Controller
{
private ArrayList trades;
.....
.....
public void onDelete(AjaxBehaviorEvent event) {
Trade trade = (Trade) event.getComponent().getAttributes().get("trade");
}
}
ありがとう!
REDIT:
私はこの作業を得たが、私はテーブルを持っているので、私はまだ問題を抱えているので、私はformタグ内のテーブルをラップする必要があるので、私はformタグでビュー全体を囲みます。私の目標は、クリックしたチェックボックスをサーバーに送信することです!要求はサーバーに送信されますが、リスナーは呼び出されません。 javascriptイベントが呼び出されます。これはコードです:
VIEW:
<h:form>
<table id="trades">
<th class="image_cell"></th>
<th>Type</th>
<th>Portfolio</th>
<ui:repeat var="trade" value="#{controller.errorTrades}">
<tr class="trade error">
<td class="image_cell error"><h:graphicImage styleClass="expandable" url="resources/images/plus.png"></h:graphicImage></td>
<td id="type" class="error">#{trade.type}</td>
<td class="error">#{trade.portfolio}</td>
</tr>
<tr class="operations">
<td id="#{trade.murexId}" class="operation_row" colspan="4">
<table id="operations">
<tr class="header">
<th class="empty_cell"></th>
<th class="operation_cell">Operation</th>
<th>Time Transaction</th>
<th>Comment</th>
<th id="delete">Delete</th>
</tr>
<ui:repeat var="operation" value="#{trade.operationsSortList}">
<tr class="operation">
<th class="empty_cell"></th>
<td id="operation" class="operation_cell color">#{operation.operation}</td>
<td class="color">#{operation.time}</td>
<td class="color">#{operation.coment}</td>
<td class="color checkbox">
<h:selectBooleanCheckbox title="delete">
<f:ajax execute="@this" event="click" listener="#{controller.onDelete}" onevent="onDeleteProcess" />
<f:attribute name="murexId" value="#{trade.murexId}" />
<f:attribute name="operationId" value="#{operation.id}" />
</h:selectBooleanCheckbox>
</td>
</tr>
</ui:repeat>
</table>
</td>
</tr>
</ui:repeat>
</table>
</h:form>
CONTROLLER:
@ViewScoped
public class Controller
{
private ArrayList trades;
private ArrayList errorTrades = new ArrayList();
.......code
public boolean onDelete(AjaxBehaviorEvent event)
{
long murexId = 0;
BigDecimal operationId = null;
boolean result = false;
Trade trade;
Iterator itop;
Operation operation;
......code
return true;
}
}
私はこの問題を解決することは非常に重要です。
ありがとうございます!
JSF impl/versionとは何ですか? Mojarra 2.1.7で問題を再現できません。私はしかし、初期バージョンではui:repeat + f:ajax inconsitentiesを思い出します。 – BalusC
私は最新のバージョンを使用しています – bribon
あなたはMattの回答を受け入れたので、あなたの問題が解決されたと思われますか?しかし、あなたはコマンドリンクを使用したくないと述べました。本当に本当の問題は何だったのですか?それをどのように正確に解決しましたか?それとも解決されない場合は、完全なSSCCEを含めるように質問を編集してください。これは可能な限り最小の**完全な**コードスニペットで、問題を見るためにコピー&ペーストすることはできません。あなたが問題を再現できる限り、 ''、 ''などの無関係なタグ/属性を可能な限り削除してください。次に、全体のビューとBeanをコピーします。 – BalusC