boolean useDefaultClientPresentation,
boolean useDefaultServerPresentation) {
if (forComponentClientId == null) {
throw new NullPointerException("forComponentClientId");
}
ScriptBuilder resultScript = new ScriptBuilder();
Iterator messages = context.getMessages(forComponentClientId);
FacesMessage message = null;
if (messages.hasNext()) {
message = (FacesMessage) messages.next();
}
String css = Styles.getCSSClass(context, fim,
!fim.isNoStyle() ? fim.getStyle() : null, DEFAULT_CLASS,
!fim.isNoStyle() ? fim.getStyleClass() : null);
JSONObject events = Rendering.getEventsParam(fim, "onclick", "ondblclick", "onmousedown", "onmouseover", "onmousemove", "onmouseout", "onmouseup");
ScriptBuilder clientValidationScript = new ScriptBuilder().functionCall("O$.addClientMessageRenderer",
new NewInstanceScript("O$._FloatingIconMessageRenderer",
fim,
forComponentClientId,
getImageUrl(fim),
getOffsetTop(fim),
getOffsetLeft(fim),
css,
events,
fim.isNoImage(),
fim.isShowSummary(),
fim.isShowDetail(),
isDefaultPresentation(fim))).semicolon();
ScriptBuilder serverValidationScript = new ScriptBuilder();
if (message != null) {
serverValidationScript.onLoadScript(new ScriptBuilder().append(
ClientValidatorUtil.getScriptAddMessageById(message, forComponentClientId)).
newInstance("O$._FloatingIconMessageRenderer",
fim,
forComponentClientId,
getImageUrl(fim),
getOffsetTop(fim),
getOffsetLeft(fim),
css,
events,
fim.isNoImage(),
fim.isShowSummary(),
fim.isShowDetail(),
isDefaultPresentation(fim)).append(".update();\n"));
}
if (pageDefinedMessage) {
if (clientValidation) {
resultScript = new ScriptBuilder(clientValidationScript);
}
if (message != null) {
resultScript.append(serverValidationScript);
}
} else {
if (clientValidation && useDefaultClientPresentation) {
resultScript = new ScriptBuilder(clientValidationScript);
}
if (useDefaultServerPresentation) {
if (message != null) {
resultScript.append(serverValidationScript);
} else {
if (clientValidation) {
resultScript = new ScriptBuilder(clientValidationScript);
}
}
}
}
return resultScript;