<af:inputText id="it1" />
The
id
attribute rendered in the browser is obviously not the same as the value set in the ADF apge. This new id
is the clientId
and is produced by the UIComponent.getClientId(FacesContext) method.public String getClientId(String componentId) {
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot root = context.getViewRoot();
UIComponent c = findComponent(root, componentId);
return c.getClientId(context);
}
One good example of using client id is to display error message on a specific field.
The field will has a red border and mouse over to see the error message.
public static void displayMessage(Severity messageType,
String messageTitle, String messageText,
String componentId) {
String clientId = null;
if (componentId != null) {
clientId = getClientId(componentId);
}
FacesContext fc = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage(messageTitle, messageText);
message.setSeverity(messageType);
fc.addMessage(clientId, message);
}