I am trying to get the component client id in datatable. the problem is that jsf puts the row index before the component id automatically, i.e.
<a id="mappedidentifier_table:1:mappedidentifier_Update" href="#">Update</a>
for the link in the second line (index = 1).
I use the following methods to get 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; }
however this returns
mappedidentifier_table:mappedidentifier_Update ,
instead
mappedidentifier_table:1:mappedidentifier_Update ,
therefore, it does not match any element because there is no row index in id.
I read http://illegalargumentexception.blogspot.com/2009/05/jsf-using-component-ids-in-data-table.html
however, I intend to have a simpler implementation, rather than a TLD function or chips like the author.
Anyone have any thoughts?
thanks,
J
user181220
source share