use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class ERXComponentUtilities method appendHtmlAttributes.
/**
* Appends a dictionary of associations as HTML attributes.
*
* @param associations
* the associations dictionary
* @param response
* the response to write to
* @param context
* the context
*/
public static void appendHtmlAttributes(NSDictionary<String, WOAssociation> associations, WOResponse response, WOContext context) {
WOComponent component = context.component();
ERXComponentUtilities.appendHtmlAttributes(associations, response, component);
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class ERXComponentUtilities method componentTree.
/**
* Returns an array of the current component names.
*
* @return array of current component names
*/
public static NSArray<String> componentTree() {
WOContext context = ERXWOContext.currentContext();
NSMutableArray<String> result = new NSMutableArray<>();
if (context != null) {
WOComponent c = context.component();
while (c != null) {
result.addObject(c.name());
c = c.parent();
}
}
return result;
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class AjaxFunctionLink method _appendAttributesToResponse.
public static void _appendAttributesToResponse(WOResponse response, WOContext context, WOAssociation actionAssociation, WOAssociation updateContainerIDAssociation) {
WOComponent component = context.component();
if (actionAssociation != null) {
String action = (String) actionAssociation.valueInComponent(component);
String updateContainerID;
if (updateContainerIDAssociation != null) {
updateContainerID = (String) updateContainerIDAssociation.valueInComponent(component);
} else {
updateContainerID = AjaxUpdateContainer.currentUpdateContainerID();
}
if (updateContainerID == null) {
throw new WODynamicElementCreationException("You must either set the 'updateContainerID' binding or the link must be contained inside of an AjaxUpdateContainer.");
}
response.appendContentString(" onclick = \"");
response.appendContentString(updateContainerID);
if ("edit".equalsIgnoreCase(action)) {
response.appendContentString("Edit");
} else if ("cancel".equalsIgnoreCase(action)) {
response.appendContentString("Cancel");
} else if ("save".equalsIgnoreCase(action)) {
response.appendContentString("Save");
} else if ("update".equalsIgnoreCase(action)) {
response.appendContentString("Update");
} else {
throw new WODynamicElementCreationException("Unknown AjaxInPlace action '" + action + "'. Must be one of 'edit', 'cancel', 'save', or 'Update'.");
}
response.appendContentString("()\"");
}
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class AjaxHighlight method appendToResponse.
@Override
public void appendToResponse(WOResponse response, WOContext context) {
AjaxUtils.addScriptResourceInHead(context, response, "prototype.js");
AjaxUtils.addScriptResourceInHead(context, response, "effects.js");
AjaxUtils.addScriptResourceInHead(context, response, "wonder.js");
WOComponent component = context.component();
boolean generateContainer = (_id == null || _elementName != null);
String elementName;
if (_elementName == null) {
elementName = "div";
} else {
elementName = (String) _elementName.valueInComponent(component);
}
String id;
if (_id == null) {
id = ERXWOContext.safeIdentifierName(context, false);
} else {
id = (String) _id.valueInComponent(component);
}
HighlightMetadata metadata = null;
if (_value != null) {
Object value = _value.valueInComponent(component);
if (value != null) {
metadata = highlightMetadataForObject(value);
}
}
if (generateContainer) {
response.appendContentString("<");
response.appendContentString(elementName);
response._appendTagAttributeAndValue("id", id, true);
AjaxUtils.appendTagAttributeAndValue(response, context, component, _associations, "class");
String displayStyle = null;
if (metadata != null) {
boolean hidden = false;
if (metadata.isNew() && _newHidden != null) {
hidden = _newHidden.booleanValueInComponent(component);
} else if (!metadata.isNew() && _updateHidden != null) {
hidden = _updateHidden.booleanValueInComponent(component);
} else if (_hidden != null) {
hidden = _hidden.booleanValueInComponent(component);
}
if (hidden) {
displayStyle = "display: none;";
}
}
AjaxUtils.appendTagAttributeAndValue(response, context, component, _associations, "style", displayStyle);
AjaxUtils.appendTagAttributeAndValue(response, context, component, _associations, "onMouseOver");
AjaxUtils.appendTagAttributeAndValue(response, context, component, _associations, "onMouseOut");
response.appendContentString(">");
}
super.appendToResponse(response, context);
if (generateContainer) {
response.appendContentString("</");
response.appendContentString(elementName);
response.appendContentString(">");
}
if (metadata != null) {
String effect;
if (metadata.isNew() && _newEffect != null) {
effect = (String) _newEffect.valueInComponent(component);
} else if (!metadata.isNew() && _updateEffect != null) {
effect = (String) _updateEffect.valueInComponent(component);
} else if (_effect != null) {
effect = (String) _effect.valueInComponent(component);
} else {
effect = "Highlight";
}
if (!"none".equalsIgnoreCase(effect)) {
AjaxUtils.appendScriptHeader(response);
Object duration = null;
if (metadata.isNew() && _newDuration != null) {
duration = _newDuration.valueInComponent(component);
} else if (!metadata.isNew() && _updateDuration != null) {
duration = _updateDuration.valueInComponent(component);
} else if (_duration != null) {
duration = _duration.valueInComponent(component);
}
Object delay = _delay == null ? null : _delay.valueInComponent(component);
String effectName = AjaxUpdateLink.fullEffectName(effect);
Object showDuration = _showDuration == null ? null : _showDuration.valueInComponent(component);
String showEffectName = _showEffect == null ? null : AjaxUpdateLink.fullEffectName((String) _showEffect.valueInComponent(component));
Object hideDelay = (_hideDelay == null) ? null : _hideDelay.valueInComponent(component);
Object hideDuration = _hideDuration == null ? null : _hideDuration.valueInComponent(component);
String hideEffectName = _hideEffect == null ? null : AjaxUpdateLink.fullEffectName((String) _hideEffect.valueInComponent(component));
response.appendContentString("AH.highlight(" + AjaxUtils.quote(id) + "," + delay + "," + AjaxUtils.quote(showEffectName) + "," + showDuration + "," + AjaxUtils.quote(effectName) + "," + duration + "," + hideDelay + "," + AjaxUtils.quote(hideEffectName) + "," + hideDuration + ");");
AjaxUtils.appendScriptFooter(response);
}
}
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class AjaxHyperlink method handleRequest.
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
WOComponent component = context.component();
WOActionResults results = (WOActionResults) valueForBinding("action", component);
if (results == null) {
String script = (String) valueForBinding("onClickServer", component);
if (script != null) {
WOResponse response = AjaxUtils.createResponse(request, context);
AjaxUtils.appendScriptHeader(response);
response.appendContentString(script);
AjaxUtils.appendScriptFooter(response);
results = response;
}
}
return results;
}
Aggregations