use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class AjaxDefaultSubmitButton method appendToResponse.
@Override
public void appendToResponse(WOResponse response, WOContext context) {
WOComponent component = context.component();
String formName = (String) valueForBinding("formName", component);
String formReference = "this.form";
if (formName != null) {
formReference = "document." + formName;
}
StringBuilder onClickBuffer = new StringBuilder();
String onClickBefore = (String) valueForBinding("onClickBefore", component);
if (onClickBefore != null) {
onClickBuffer.append("if (");
onClickBuffer.append(onClickBefore);
onClickBuffer.append(") {");
}
// PROTOTYPE EFFECTS
String updateContainerID = AjaxUpdateContainer.updateContainerID(this, component);
String beforeEffect = (String) valueForBinding("beforeEffect", component);
if (beforeEffect != null) {
onClickBuffer.append("new ");
onClickBuffer.append(AjaxUpdateLink.fullEffectName(beforeEffect));
onClickBuffer.append("('");
String beforeEffectID = (String) valueForBinding("beforeEffectID", component);
if (beforeEffectID == null) {
beforeEffectID = AjaxUpdateContainer.currentUpdateContainerID();
if (beforeEffectID == null) {
beforeEffectID = updateContainerID;
}
}
onClickBuffer.append(beforeEffectID);
onClickBuffer.append("', { ");
String beforeEffectDuration = (String) valueForBinding("beforeEffectDuration", component);
if (beforeEffectDuration != null) {
onClickBuffer.append("duration: ");
onClickBuffer.append(beforeEffectDuration);
onClickBuffer.append(", ");
}
onClickBuffer.append("queue:'end', afterFinish: function() {");
}
if (updateContainerID != null) {
onClickBuffer.append("ASB.update('" + updateContainerID + "',");
} else {
onClickBuffer.append("ASB.request(");
}
onClickBuffer.append(formReference);
onClickBuffer.append(",null,");
NSMutableDictionary options = createAjaxOptions(component);
AjaxUpdateLink.addEffect(options, (String) valueForBinding("effect", component), updateContainerID, (String) valueForBinding("effectDuration", component));
String afterEffectID = (String) valueForBinding("afterEffectID", component);
if (afterEffectID == null) {
afterEffectID = AjaxUpdateContainer.currentUpdateContainerID();
if (afterEffectID == null) {
afterEffectID = updateContainerID;
}
}
AjaxUpdateLink.addEffect(options, (String) valueForBinding("afterEffect", component), afterEffectID, (String) valueForBinding("afterEffectDuration", component));
AjaxOptions.appendToBuffer(options, onClickBuffer, context);
onClickBuffer.append(')');
String onClick = (String) valueForBinding("onClick", component);
if (onClick != null) {
onClickBuffer.append(';');
onClickBuffer.append(onClick);
}
if (beforeEffect != null) {
onClickBuffer.append("}});");
}
if (onClickBefore != null) {
onClickBuffer.append('}');
}
onClickBuffer.append("; return false;");
response.appendContentString("<input ");
appendTagAttributeToResponse(response, "tabindex", "");
appendTagAttributeToResponse(response, "type", "submit");
String name = nameInContext(context, component);
appendTagAttributeToResponse(response, "name", name);
appendTagAttributeToResponse(response, "value", valueForBinding("value", component));
appendTagAttributeToResponse(response, "accesskey", valueForBinding("accesskey", component));
// Suppress modal box focus ring if used inside of modal dialog
if (AjaxModalDialog.isInDialog(context)) {
StringBuilder sb = new StringBuilder("MB_notFocusable ");
Object cssClass = valueForBinding("class", component);
if (cssClass != null) {
sb.append(cssClass);
}
appendTagAttributeToResponse(response, "class", sb.toString());
} else {
appendTagAttributeToResponse(response, "class", valueForBinding("class", component));
}
appendTagAttributeToResponse(response, "style", "position:absolute;left:-10000px");
appendTagAttributeToResponse(response, "id", valueForBinding("id", component));
appendTagAttributeToResponse(response, "onclick", onClickBuffer.toString());
response.appendContentString(" />");
// fix for IE < 9 that deactivates the standard submit routine of the form and
// triggers the onClick handler of this submit element instead if the return key
// is pressed within a textfield, radiobutton, checkbox or select
ERXBrowser browser = ERXBrowserFactory.factory().browserMatchingRequest(context.request());
if (browser.isIE() && browser.majorVersion().compareTo(Integer.valueOf(9)) < 0) {
if (!hasBinding("formName")) {
formName = ERXWOForm.formName(context, "");
}
AjaxUtils.appendScriptHeader(response);
response.appendContentString("\nEvent.observe(document." + formName + ", 'keypress', function(e){");
// return key
response.appendContentString("if(e.keyCode==13){");
response.appendContentString("var shouldFire=false;var t=e.target;var tn=t.tagName.toLowerCase();");
response.appendContentString("if(tn==='select'){shouldFire=true;}");
response.appendContentString("else if(tn==='input'){var ty=t.type.toLowerCase();");
response.appendContentString("if(ty==='text' || ty==='radio' || ty==='checkbox'){shouldFire=true;}}");
response.appendContentString("if(shouldFire){$$('[name=" + name + "]')[0].fireEvent('onClick');e.returnValue=false;}");
response.appendContentString("}});");
AjaxUtils.appendScriptFooter(response);
}
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class ERXComponentRequestHandler method _dispatchWithPreparedPage.
private WOResponse _dispatchWithPreparedPage(WOComponent aPage, WOSession aSession, WOContext aContext, NSDictionary someElements) {
WORequest aRequest = aContext.request();
WOApplication anApplication = WOApplication.application();
WOResponse aResponse = anApplication.createResponseInContext(aContext);
String aSenderID = aContext.senderID();
String oldContextID = aSession._contextIDMatchingIDs(aContext);
aResponse.setHTTPVersion(aRequest.httpVersion());
aResponse.setHeader("text/html", "content-type");
aContext._setResponse(aResponse);
if (oldContextID == null) {
if (aSenderID != null) {
if (aRequest._hasFormValues()) {
anApplication.takeValuesFromRequest(aRequest, aContext);
}
}
aContext._setPageChanged(false);
if (aSenderID != null) {
WOActionResults anActionResults = anApplication.invokeAction(aRequest, aContext);
if ((anActionResults == null) || ((anActionResults instanceof WOComponent))) {
WOComponent aResultComponent = (WOComponent) anActionResults;
if ((aResultComponent != null) && (aResultComponent.context() != aContext)) {
aResultComponent._awakeInContext(aContext);
}
boolean didPageChange = false;
if ((aResultComponent != null) && (aResultComponent != aContext._pageElement())) {
didPageChange = true;
}
aContext._setPageChanged(didPageChange);
if (didPageChange) {
aContext._setPageElement(aResultComponent);
}
} else {
WOResponse theResponse = anActionResults.generateResponse();
return theResponse;
}
}
} else {
WOComponent responsePage = _restorePageForContextID(oldContextID, aSession);
aContext._setPageElement(responsePage);
}
anApplication.appendToResponse(aResponse, aContext);
return aResponse;
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class WOMethodInvocation method invokeAction.
@Override
public WOActionResults invokeAction(WORequest aRequest, WOContext aContext) {
WOComponent aComponent = aContext.component();
_invoke.valueInComponent(aComponent);
return null;
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class WOMethodInvocation method appendToResponse.
@Override
public void appendToResponse(WOResponse aResponse, WOContext aContext) {
WOComponent aComponent = aContext.component();
_invoke.valueInComponent(aComponent);
}
use of com.webobjects.appserver.WOComponent in project wonder-slim by undur.
the class WOMethodInvocation method takeValuesFromRequest.
@Override
public void takeValuesFromRequest(WORequest aRequest, WOContext aContext) {
WOComponent aComponent = aContext.component();
_invoke.valueInComponent(aComponent);
}
Aggregations