• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Component based email without a context
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Component based email without a context


  • Subject: Re: Component based email without a context
  • From: Ken Anderson <email@hidden>
  • Date: Mon, 31 Oct 2011 16:26:31 -0400

That's perfect!  Thanks Philippe!

Ken

On Oct 30, 2011, at 2:15 PM, Philippe Rabier wrote:

Hi Ken,

We use the following code to do what you want:

…
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);
…
message.sendMail();

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);


-- 
Paul.

http://logicsquad.net/

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
References: 
 >Component based email without a context (From: Ken Anderson <email@hidden>)
 >Re: Component based email without a context (From: Paul Hoadley <email@hidden>)
 >Re: Component based email without a context (From: Ken Anderson <email@hidden>)
 >Re: Component based email without a context (From: Philippe Rabier <email@hidden>)

  • Prev by Date: Re: Why are static web resources duplicated in the app bundle?
  • Previous by thread: Re: Component based email without a context
  • Next by thread: Validating Email
  • Index(es):
    • Date
    • Thread