dataTableのJSF2に:アヤックス時間では動作しない属性をレンダリング
質問
私はいくつかの問題はJSF 2.0で簡単なアプリケーションを持っています。
私は、AjaxサポートでのToDoリストを作成してみてください。私はデータテーブルを使用して表示し、いくつかのTODO文字列を持っています。このデータテーブルの中に私は、タスクを削除するのcommandLinkを持っています。問題は、今のDataTableが再描画されませんということです。
<h:dataTable id="todoList" value="#{todoController.todos}" var="todo">
<h:column>
<h:commandLink value="X" action="#{todoController.removeTodo(todo)}">
<f:ajax execute="@this" render="todoList" />
</h:commandLink>
</h:column>
<h:column>
<h:outputText value="#{todo}"/>
</h:column>
</h:dataTable>
ご協力いただきありがとうございます。
編集(TodoController):
@ManagedBean
@SessionScoped
public class TodoController {
private String todoStr;
private ArrayList<String> todos;
public TodoController() {
todoStr="";
todos = new ArrayList<String>();
}
public void addTodo() {
todos.add(todoStr);
}
public void removeTodo(String deleteTodo) {
todos.remove(deleteTodo);
}
/* getter / setter */
}
解決
は(私は他の人の回答にコメントするのに十分な評判を持っていないように見えます)の
私はFRotthoweは別の要素を持つテーブルをラップして(つまり、文書のルートからすべての親コンテナを命名。)から
このような何かます:
<h:form id="form">
<h:panelGroup id ="wrapper">
<h:dataTable value="#{backingBean.data}" var="list">
<h:column>
<h:commandButton value="-" action="#{backingBean.data}">
<f:ajax render=":form:wrapper"/>
</h:commandButton>
</h:column>
</h:dataTable>
</h:panelGroup>
</h:form>
しかし、ビューが大きくなるにつれて絶対参照を使用することは常に問題と増加のソース指数関数的にリファクタリング時間である。
タグ(迷惑それらを追加することから、JSFを防ぐ「:number_of_row」AJAXイベントで)?ちょうど
他のヒント
私は仮定するの
しばらくの間、この問題で苦労した後、私は簡単で、クリーンなソリューションをGoogleで検索:<:AJAX f>の<ののの の属性のレンダリングにの@formの追加します/ strong>の出来上がり!
全例:
<h:form id="theForm">
<h:dataTable id="table" value="#{tasksMgr.allTasks}" var="task">
<h:column>
#{task.name}
</h:column>
<h:column>
<h:commandButton id="removeTaskButton" value="X" action="#{tasksMgr.removeTask(task)}">
<f:ajax render="@form" />
</h:commandButton>
</h:column>
</h:dataTable>
</h:form>
私を助けた記事全文はこちらです: http://blogs.steeplesoft.com/2009/10/jsf-2-hdatatable-and-ajax-updates/する
このコードを使用します:
<h:form id="form">
<h:panelGroup id="panel">
<h:dataTable id="todoList" value="#{todoController.todos}" var="todo">
<h:column>
<h:commandLink value="X" action="#{todoController.removeTodo(todo)}">
<f:ajax render=":form:panel" />
</h:commandLink>
</h:column>
<h:column>
<h:outputText value="#{todo}"/>
</h:column>
</h:dataTable>
</h:panelGroup>
</h:form>
<時間> 私は同じ問題に遭遇し、あなたがテーブルの周りとその再レンダリング要素(例えば)を入れた場合、それが動作することを考え出しました。しかし私はそれがそのようである理由はかなりわかりません。誰ですか?
JSFが
<h:form id="form">
<h:commandButton value="Button">
<f:ajax render="table"/>
</h:commandButton>
<h:dataTable id="table" value="#{tableData.data}">
<h:column>
<h:commandButton value="Button">
<f:ajax render="tocoto"/>
</h:commandButton>
</h:column>
</h:dataTable>
</h:form>
私はこのHTMLを取得します:
<form id="j_idt7" name="j_idt7" method="post" action="/WebApplication1/faces/index.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt7" value="j_idt7" />
<input id="j_idt7:j_idt8" type="submit" name="j_idt7:j_idt8" value="Button" onclick="mojarra.ab(this,event,'action',0,'j_idt7:table');return false" />
<table id="j_idt7:table"><tbody>
<tr>
<td><input id="j_idt7:table:0:j_idt10" type="submit" name="j_idt7:table:0:j_idt10" value="Button" onclick="mojarra.ab(this,event,'action',0,'j_idt7:table:0');return false" /></td>
</tr>
</tbody></table>
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-7634557012794378167:1020265910811114103" autocomplete="off" />
</form>
お知らせ番目のボタンのidがあることを私が取得するために期待していながら、「j_idt7:0:テーブル」。:私は最初の1でそうであるように「j_idt7テーブルを」
その問題を解決していませんが、回避策を見つけるのに役立つことがあります。
あなたはあなたの時間にprependId = "false" に追加する必要があります。フォーム
私は同じ問題に遭遇します。
"作品" は、プロジェクトに RichFacesのの追加、および交換されていることの一つ。
h:datatable
タグにより、
rich:datatable.
のidの正しいを生成します。