Mailing List webobjects-dev@wocommunity.org Message #69
From: Samuel Pelletier <webobjects-dev@wocommunity.org>
Subject: Re: [WO-DEV] Stupid me but how do I generate a fully qualified direct action url for sending out via mail?
Date: Wed, 17 Feb 2021 12:40:14 -0500
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
Hi,

I submitted PR-851, merger in Feb 2018 to handle the background task host problem.

To use these, simply create a context using
ERXWOContext sessionLessContext = ERXWOContext.newContext();
sessionLessContext.generateCompleteURLs();
String url = sessionLessContext.urlWithRequestHandlerKey(...)

or create a component with ERXApplication.instantiatePage(String pageName) or ERMailUtils.instantiatePage() as both will use ERXWOContext.newContext();

Properties to enable this:

## If your WOHost is not your public host name, specify the public host to use for complete URL 
## generated without a server request like background tasks that send emails.
# er.extensions.ERXApplication.publicHost=www.yourPublicHost.com
## Set to true to switch default request used in background tasks to https
# er.extensions.ERXApplication.publicHostIsSecure=false

Regards,

Samuel



Le 17 févr. 2021 à 02:33, Stefan Gärtner <webobjects-dev@wocommunity.org> a écrit :

Two important questions should be considered:

  • Do you generate the URL inside of a request-response cycle or possibly also inside of a background task?
    • If during a request, WOContext.directActionURLForActionNamed works fine, as written by René and Ramsey. This works because the WOContext takes the URL used in the HTTP WORequest.
    • Else:
  • Is the host, which the app is running on, the one directly accessed by users via HTTP?
    • If yes, you might be able to use ERXConfigurationManager.defaultManager().hostName() as suggested by Jesse (it uses InetAddress.getLocalHost().getHostName() internally)
    • Else:
  • Just define a configuration property containing the base URL (can certainly be specified per environment) as written by Paul.

Best regards,
Stefan


Am 16.02.2021 um 15:39 schrieb Markus Ruggiero (rucotec) <webobjects-dev@wocommunity.org>:

The subject line already says all

Thanks

Markus Ruggiero

rucotec GmbH                        web https://rucotec.ch
Steinenvorstadt 79                email markus.ruggiero@rucotec.ch
4051 Basel / Switzerland         mobile +41 79 508 4701











Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster