Josué Alcalde González wrote:
I think I could do it if I would have access to the tree from
FacesContext.

This can be done with FacesContext.getViewRoot()


There is a function:
facesContext.getClientIdsWithMessages()
which gives me all the "clientId" which have messages.

Then, I get all the messages form all the clientIds using:
facesContext.getMessages(clientId);

No, if I have clientId as a String, is there any way to access the tree
and find the component with that clientId, and then, find its label,
with for="clientId"?


UIComponent.findComponent(id) can be used to find components.

This method is really designed to take a "JSF Component Id with path" rather than a "client id" but in basic usage I believe these are the same.

One case where I know it will not work is for components nested within tables; the same component is reused for each row with a hack used to insert a "row index" into its clientId depending upon what the current rowIndex value is for the table it is nested in - ie what getClientId() returns depends upon what rowIndex is set in the owning table.

An alternative to using findComponent is to just walk the tree manually, looking for components with clientId values that match the ones you want. Again, however, table components can cause problems. It is possible to deal with the table problem (I implemented exactly this just this week) with about 10 lines of code.

Regards,

Simon

Reply via email to