Re: WOMailDelivery and Component E-Mails
"Jerry W. Walker" <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Jeff,
It seems that the sendNoDocMail method is being activated outside the
Request-Response (R-R) loop. Are you messaging it from the code in
the long running thread covered by the WOLongResponsePage? If that
question makes sense to you, then just fix it by not doing so. If it
fails to make sense, keep reading.
The WOLongResponsePage is used to maintain the browser connection
(through an HTML hack, actually) while you create another thread of
your application to go off and do some job whose completion time
would normally exceed the browser's response timeout period. Let's
call this second long running thread the LongThread and call the
thread that is responding to, and sending out, WOLongResponsePages
the RRThread.
The browser connection is maintained by inserting a Refresh header in
the WOLongResponsePage's HTML. This causes the browser to delay for a
period of time typically set in the Refresh header, and then send
another request to the server to start another Request-Response loop.
When the browser's subsequent request is received by the WOAdaptor,
it establishes another WOContext object to describe the page that is
sending the request to the WO application and reactivates your
RRThead which typically repeats the cycle. It should continue to do
this until the code in your LongThread finishes its job and so
notifies the WOLongResponsePage through the setResult method.
The WO application needs the context encapsulated in the WOContext
object to figure out which values in the takeValuesForRequest phase
are associated with which fields on that page, and which links or
buttons triggered an action in the invokeAction phase.
However, if you send a message to your WOLongResponsePage subclass
from your code in LongThread, that LongThread code has already been
disconnected from the Request-Response loop, and so, has no
associated WOContext. To resolve the situation, send the result of
your LongThread execution to the WOLongResponsePage through its
setStatus method and make the WOLongResponsePage message its own
sendNoDocMail the next time the browser returns. That way, the
sendNoDocMail method will be activated from within the RRThread and
will have the necessary WOContext.
HTH
Regards,
Jerry
On Jan 18, 2006, at 3:23 PM, Jeff Dunnett wrote:
> Hello,
>
> Since many people on this list have been extremely helpful I
> figured I would ask another questions:
>
> I have the following method which is called from a WOLongResponse
> page:
>
>
> private void sendNoDocMail(UUser curUser)
> {
> emailTemplate page = (emailTemplate)pageWithName("emailTemplate");
> page.setSendNoDocNotification(true);
> page.setAUser(curUser);
> WOMailDelivery sharedInstance = WOMailDelivery.sharedInstance();
> sharedInstance.composeComponentEmail(Application.CS_GIRL_EMAIL,
> new NSArray(curUser.email()), new NSArray
> (Application.CS_GIRL_EMAIL), Application.NOTIFICATION_SUBJECT,
> page, true);
>
> System.out.println("Send No Doc Mail Completed");
> }
>
> This method uses WOMailDelivery to create a component email. The
> problem I am having is that an exception is being thrown by the line:
>
> emailTemplate page = (emailTemplate)pageWithName("emailTemplate");
>
> I am getting the following error message:
>
> [2006-01-18 15:18:30 EST] <Thread-1> Session.context() evaluates to
> null. You may be trying to get the context object from an archived
> session object. there is no context object outside of the request-
> response loop.
>
> A stack trace of the exception provides:
>
> java.lang.IllegalArgumentException: <Application>: Unable to create
> page 'emailTemplate'. No context was passed.
> at com.webobjects.appserver.WOApplication.pageWithName
> (WOApplication.java:1934)
> at com.webobjects.appserver.WOComponent.pageWithName
> (WOComponent.java:1200)
> at sendNotificationEmail.sendNoDocMail(sendNotificationEmail.java:
> 181)
> at sendNotificationEmail.executeNotifyMissingDoc
> (sendNotificationEmail.java:99)
> at longResponse.performAction(longResponse.java:66)
> at com.webobjects.woextensions.WOLongResponsePage.run
> (WOLongResponsePage.java:155)
> at java.lang.Thread.run(Thread.java:552)
>
> I am not sure why it says no context is being passed. I am
> creating the emailTemplate component like I do for pretty much
> every component. Does this have something to do with the
> WOLongResponsePage? Thanks for you help.
>
>
> Regards,
> Jeff
>
>
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial
Strength Internet Enabled Systems
[email protected]
203 278-4085 office
_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev