データテーブル内のコンポーネントのクライアントIDを取得しようとしています。問題は、jsfがコンポーネントIDの前に行インデックスを自動的に配置することです。
<a id="mappedidentifier_table:1:mappedidentifier_Update" href="#">Update</a>
2行目のリンクの場合(インデックス= 1)。
次のメソッドを使用してclientIdを取得しています
public static String findClientId(String id) {
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot view = context.getViewRoot();
if (view == null) {
throw new IllegalStateException("view == null");
}
UIComponent component = findComponent(view, id);
if (component == null) {
throw new IllegalStateException("no component has id='" + id + "'");
}
return component.getClientId(context);
}
private static UIComponent findComponent(UIComponent component, String id) {
if (id.equals(component.getId())) {
return component;
}
Iterator<UIComponent> kids = component.getFacetsAndChildren();
while (kids.hasNext()) {
UIComponent kid = kids.next();
UIComponent found = findComponent(kid, id);
if (found != null) {
return found;
}
}
return null;
}
ただし、これは
mappedidentifier_table:mappedidentifier_Update
、
それ以外の
mappedidentifier_table:1:mappedidentifier_Update
、
したがって、どの要素とも一致しないため、idの行インデックスが欠落しています。
http://illegalargumentexception.blogspot.com/2009/05/jsf-using-component-ids-in-data-table.htmlを読みました
ただし、作成者のようにTLD関数やフェイスレットではなく、より単純な実装にするつもりです。
誰か考えがありますか?
ありがとう、
dzh