4 Replies Latest reply on Jun 29, 2007 2:01 AM by milli

    Asynchronous seam mail can not get the base URL dynamically

    milli

      Hi,

      While creating a user account, I'm trying to invoke an asynchronous method in my SLSB to send the activation mail. In my activation mail template, I'm trying to resolve the activation URL dynamically instead of having a static one.

      I tried the following methods and none of them gets the correct URL:

      <s:link> - resolves to /project/activation.seam - I don't know where the project is coming from 'cause that is not my application context path

      #{facesContext.externalContext.requestContextPath} - resolves to null

      defined a factory variable and try to use #{basePath} - resolves to null

      <factory name="basePath" scope="APPLICATION" value="#{facesContext.externalContext.request.scheme}://#{facesContext.externalContext.request.serverName}:#{facesContext.externalContext.request.serverPort}#{facesContext.externalContext.request.contextPath}/"/>


      finally tried to inject facesContext in the SLSB that renders the mail template, and it fails to inject.

      Finally concluded that it is 'cause of asynchronous method. I think it looses all the contexts when it is run. If I make it synchronous, everything works fine.

      Has anyone come across this problem? Is there a way to set contexts for asynchronous methods?

      Thanks