* @param rc the relevant <code>RenderContext</code>
* @param button the button
*/
private void renderInitDirective(RenderContext rc, AbstractButton button) {
String elementId = ContainerInstance.getElementId(button);
ServerMessage serverMessage = rc.getServerMessage();
FillImage backgroundImage = (FillImage) button.getRenderProperty(AbstractButton.PROPERTY_BACKGROUND_IMAGE);
boolean rolloverEnabled = ((Boolean) button.getRenderProperty(AbstractButton.PROPERTY_ROLLOVER_ENABLED,
Boolean.FALSE)).booleanValue();
boolean pressedEnabled = ((Boolean) button.getRenderProperty(AbstractButton.PROPERTY_PRESSED_ENABLED,
Boolean.FALSE)).booleanValue();
String pressedStyle = "";
String rolloverStyle = "";
String defaultIconUri = null;
String rolloverIconUri = null;
String pressedIconUri = null;
if (rolloverEnabled || pressedEnabled) {
boolean hasIcon = button.getRenderProperty(AbstractButton.PROPERTY_ICON) != null;
if (hasIcon) {
defaultIconUri = ImageTools.getUri(rc, this, button, IMAGE_ID_ICON);
}
if (rolloverEnabled) {
CssStyle rolloverCssStyle = new CssStyle();
BorderRender.renderToStyle(rolloverCssStyle,
(Border) button.getRenderProperty(AbstractButton.PROPERTY_ROLLOVER_BORDER));
ColorRender.renderToStyle(rolloverCssStyle,
(Color) button.getRenderProperty(AbstractButton.PROPERTY_ROLLOVER_FOREGROUND),
(Color) button.getRenderProperty(AbstractButton.PROPERTY_ROLLOVER_BACKGROUND));
FontRender.renderToStyle(rolloverCssStyle,
(Font) button.getRenderProperty(AbstractButton.PROPERTY_ROLLOVER_FONT));
if (backgroundImage != null) {
FillImageRender.renderToStyle(rolloverCssStyle, rc, this, button, IMAGE_ID_ROLLOVER_BACKGROUND,
(FillImage) button.getRenderProperty(AbstractButton.PROPERTY_ROLLOVER_BACKGROUND_IMAGE),
FillImageRender.FLAG_DISABLE_FIXED_MODE);
}
if (rolloverCssStyle.hasAttributes()) {
rolloverStyle = rolloverCssStyle.renderInline();
}
if (hasIcon) {
ImageReference rolloverIcon = (ImageReference) button.getRenderProperty(AbstractButton.PROPERTY_ROLLOVER_ICON);
if (rolloverIcon != null) {
rolloverIconUri = ImageTools.getUri(rc, this, button, IMAGE_ID_ROLLOVER_ICON);
}
}
}
if (pressedEnabled) {
CssStyle pressedCssStyle = new CssStyle();
BorderRender.renderToStyle(pressedCssStyle,
(Border) button.getRenderProperty(AbstractButton.PROPERTY_PRESSED_BORDER));
ColorRender.renderToStyle(pressedCssStyle,
(Color) button.getRenderProperty(AbstractButton.PROPERTY_PRESSED_FOREGROUND),
(Color) button.getRenderProperty(AbstractButton.PROPERTY_PRESSED_BACKGROUND));
FontRender.renderToStyle(pressedCssStyle,
(Font) button.getRenderProperty(AbstractButton.PROPERTY_PRESSED_FONT));
if (backgroundImage != null) {
FillImageRender.renderToStyle(pressedCssStyle, rc, this, button, IMAGE_ID_PRESSED_BACKGROUND,
(FillImage) button.getRenderProperty(AbstractButton.PROPERTY_PRESSED_BACKGROUND_IMAGE),
FillImageRender.FLAG_DISABLE_FIXED_MODE);
}
if (pressedCssStyle.hasAttributes()) {
pressedStyle = pressedCssStyle.renderInline();
}
if (hasIcon) {
ImageReference pressedIcon = (ImageReference) button.getRenderProperty(AbstractButton.PROPERTY_PRESSED_ICON);
if (pressedIcon != null) {
pressedIconUri = ImageTools.getUri(rc, this, button, IMAGE_ID_PRESSED_ICON);
}
}
}
}
CssStyle defaultCssStyle = renderDefaultStyle(rc, button);
String defaultStyle = defaultCssStyle.renderInline();
Element itemizedUpdateElement = serverMessage.getItemizedDirective(ServerMessage.GROUP_ID_POSTUPDATE,
"EchoButton.MessageProcessor", "init", BUTTON_INIT_KEYS, new String[]{defaultStyle, rolloverStyle, pressedStyle});
Element itemElement = serverMessage.getDocument().createElement("item");
itemElement.setAttribute("eid", elementId);
if (defaultIconUri != null) {
itemElement.setAttribute("default-icon", defaultIconUri);
}
if (rolloverIconUri != null) {