// buttonAttributes contains only action reference for given button
// action is used for creating fresh button attributes with
// unique id.
// buttonAttributes can contains also more data than action reference
ButtonAttributes refButtonAttributes = (ButtonAttributes)
this.actionsButtonsMapping.get(actionName);
// new attributes created to avoid duplicated ID.
// ButtondefaultRenderer.renderOpen create id if don't exist
// so reusing of the same attriubtes leads to duplicated ID.
final ButtonAttributes buttonAttributes = new ButtonAttributes();
buttonAttributes.setActionReference(refButtonAttributes.getActionReference());
if(null == buttonAttributes){
throw new ProtocolException();
}
DOMOutputBuffer buffer = getCurrentBuffer();
// Take styles for button element from the pseudo-element.
Styles buttonStyles = xfGroupStyles.removeNestedStyles(pseudoElement);
// If they does not exist, create styles inheriting from parent ones.
if (buttonStyles == null) {
buttonStyles = StylingFactory.getDefaultInstance()
.createInheritedStyles(protocol.getMarinerPageContext().getStylingEngine().getStyles(),
DisplayKeywords.INLINE);
}
// Set default button colour.
if (buttonStyles.getPropertyValues().getSpecifiedValue(StylePropertyDetails.COLOR) == null) {
StyleValue color = (StyleValue) buttonColors.get(pseudoElement);
if (color != null) {
buttonStyles.getPropertyValues().setComputedValue(StylePropertyDetails.COLOR, color);
}
}
// styles calculated so set it on buttonAttriubutes
buttonAttributes.setStyles(buttonStyles);
String id = buttonAttributes.getId();
if(null == id){
buttonAttributes.setId(protocol.getMarinerPageContext().generateUniqueFCID());
}
// Get and clear the content property for button styles.
// The content will be inserted after element is created.
StyleValue contentValue = buttonStyles.getPropertyValues().getSpecifiedValue(StylePropertyDetails.CONTENT);
if (contentValue != null) {
buttonStyles.getPropertyValues().clearPropertyValue(StylePropertyDetails.CONTENT);
}
// Special button renderer is created that use RemovableJavascriptContainer
// RemovableJavascriptContainer is removed when associated buutton is removed
// Otherwise there will be erros on result page because of attempts to access
// not-existing buttons.
ButtonDefaultRenderer internalButtonRenderer = new ButtonDefaultRenderer(){
private JavaScriptContainer lastCreated;
protected JavaScriptContainer createJavaScriptContainer(VolantisProtocol protocol) throws ProtocolException {
// RemovableJavaScriptContainerFactory used because it creates containers
// without storing them internally without removing.
JavaScriptContainer container =
RemovableJavaScriptContainerFactory.getInstance().createJavaScriptContainer();
internalButtonsJavascriptContainer.put(buttonAttributes.getId(),
container);
lastCreated = container;
return container;
}