public
String getClientId(FacesContext context)
...
{
if (context == null)
throw new NullPointerException("context");
if (_clientId != null)
return _clientId;
boolean idWasNull = false;
String id = getId();
if (id == null) ...{
// Although this is an error prone side effect, we automatically
// create a new id
// just to be compatible to the RI
UIViewRoot viewRoot = context.getViewRoot();
if (viewRoot != null) ...{
id = viewRoot.createUniqueId();
} else ...{
context.getExternalContext().log(
"ERROR: Cannot automatically create an id for component of type "
+ getClass().getName()
+ " because there is no viewRoot in the current facesContext!");
id = "ERROR";
}
setId(id);
// We remember that the id was null and log a warning down below
idWasNull = true;
}
UIComponent namingContainer = _ComponentUtils
.findParentNamingContainer(this, false);
if (namingContainer != null) ...{
if (context == null)
throw new NullPointerException("context");
if (_clientId != null)
return _clientId;
boolean idWasNull = false;
String id = getId();
if (id == null) ...{
// Although this is an error prone side effect, we automatically
// create a new id
// just to be compatible to the RI
UIViewRoot viewRoot = context.getViewRoot();
if (viewRoot != null) ...{
id = viewRoot.createUniqueId();
} else ...{
context.getExternalContext().log(
"ERROR: Cannot automatically create an id for component of type "
+ getClass().getName()
+ " because there is no viewRoot in the current facesContext!");
id = "ERROR";
}
setId(id);
// We remember that the id was null and log a warning down below
idWasNull = true;
}
UIComponent namingContainer = _ComponentUtils
.findParentNamingContainer(this, false);
if (namingContainer != null) ...{
//在此处要添加form的前缀
_clientId = namingContainer.getClientId(context)
+ NamingContainer.SEPARATOR_CHAR + id;
} else ...{
_clientId = id;
}
Renderer renderer = getRenderer(context);
if (renderer != null) ...{
_clientId = renderer.convertClientId(context, _clientId);
}
if (idWasNull) ...{
context.getExternalContext().log(
"WARNING: Component "
+ _clientId
+ " just got an automatic id, because there was no id assigned yet. "
+ "If this component was created dynamically (i.e. not by a JSP tag) you should assign it an "
+ "explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot "
+ "component right after creation!");
}
return _clientId;
}
_clientId = namingContainer.getClientId(context)
+ NamingContainer.SEPARATOR_CHAR + id;
} else ...{
_clientId = id;
}
Renderer renderer = getRenderer(context);
if (renderer != null) ...{
_clientId = renderer.convertClientId(context, _clientId);
}
if (idWasNull) ...{
context.getExternalContext().log(
"WARNING: Component "
+ _clientId
+ " just got an automatic id, because there was no id assigned yet. "
+ "If this component was created dynamically (i.e. not by a JSP tag) you should assign it an "
+ "explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot "
+ "component right after creation!");
}
return _clientId;
}
jsf的客户端的id生成,_clientId = namingContainer.getClientId(context) + NamingContainer.SEPARATOR_CHAR + id;
在此处要添加前缀,所以生成的客户端表示都是这样的form:id