NSMutableDictionary headers = new NSMutableDictionary();
headers.setObjectForKey(new NSArray(language), "accept-language");
// WORequest will answer true when method request.isUsingWebServer() is called and so will use Host and Port
headers.setObjectForKey("4.5", "x-webobjects-adaptor-version");
// Host for the url
String host = ERXProperties.stringForKeyWithDefault("yourdomain", app.host());
headers.setObjectForKey(host, "host");
// Port for Url
String port = ERXProperties.stringForKey("portsettings");
if (port != null)
headers.setObjectForKey(port, WORequest.ServerPortHeaderX);
WORequest request =
new WORequest(
"GET", app.adaptorPath() +
"/" +
app.name() +
".woa",
"HTTP/1.1", headers,
new NSData(),
new NSDictionary());
WOContext ctx = new WOContext(request);
ctx.generateCompleteURLs();
// Init template
WOComponent page = ERXApplication.erxApplication().pageWithName(templateClass, ctx);
…
ERMailDeliveryHTML message = new ERMailDeliveryHTML();
message.setComponent(page);
…
Philippe
On 29 oct. 2011, at 14:12, Ken Anderson wrote:
Thanks Paul. Unfortunately, currentContext() will return null, since this will not be running inside a request/response loop. I'm probably just going to create a context to use…
Ken
On Oct 28, 2011, at 6:51 PM, Paul Hoadley wrote:
Hi Ken,
On 26/10/2011, at 11:40 PM, Ken Anderson wrote:
I would like to be able send emails generated by components in the background without a user (or a context).
Does anyone have a chunk of code for creating a WOContext to be populated for generating email from a WOComponent?
This is how I do it (Wonder-based app):
SomeEmailComponent component = ERXApplication.erxApplication().pageWithName(SomeEmailComponent.class,
(WOContext) ERXWOContext.currentContext().clone());
Then later:
ERMailDeliveryHTML mail = new ERMailDeliveryHTML();
mail.setComponent(component);
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden