You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Capper <mj...@avetana.de> on 2009/09/03 21:42:37 UTC

T5: Email-Component to send me current web page

Hi,

I was wondering how to properly write a component for our site, which is
supposed to appear on any page, and enables the user to mail the current
content of the page he is viewing.

We've got our MailService up and running. Now I've been trying two ways of
getting to the HTML source of the last page's source.
One being by javascript, submitting all the current content when clicking on
the email-icon. Is supposed to capture the current state of our site, which
can be changed a bit by javascript while using it (Dragging a series of
images around etc). It also tries to embedd the current images and cut the
hrefs out, which seems to work alright in FF, not IE. 

The other is by an Action-Link on the email-icon, the onAction method then
fiddles around with the Request and lets a Handler render the request into a
ResponseWrapper (exposing the byte[] of the Response). This also gives me
the HTML source, and would be usable per se, but it throws an Exception when
popping an environment.

>From what I've read, it's difficult to more or less properly style the html
in an email, as if Safari/FF/IE weren't hell enough... I am thinking about
copying all the .css-data into the header of the html-part of the mail.

The Images i either want to embed in the html, or with the multipart/inline
mime type. Well, it barely works, but it is still ugly.

Any recommondations on this topic for me?

Thanks for your time, 
Michael
-- 
View this message in context: http://www.nabble.com/T5%3A-Email-Component-to-send-me-current-web-page-tp25282810p25282810.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: Email-Component to send me current web page

Posted by Michael Capper <mj...@avetana.de>.

Michael Capper wrote:
> 
> The other is by an Action-Link on the email-icon, the onAction method then
> fiddles around with the Request and lets a Handler render the request into
> a ResponseWrapper (exposing the byte[] of the Response). This also gives
> me the HTML source, and would be usable per se, but it throws an Exception
> when popping an environment.
> 


The exception is:


09-09-04 14:46:48,597 [ERROR]
org.apache.tapestry5.services.TapestryModule.RequestExceptionHandler
(DefaultRequestExceptionHandler:62) Processing of request failed with
uncaught exception: java.util.NoSuchElementException
java.util.NoSuchElementException
	at java.util.LinkedList.remove(LinkedList.java:788)
	at java.util.LinkedList.removeFirst(LinkedList.java:134)
	at
org.apache.tapestry5.internal.services.EnvironmentImpl.pop(EnvironmentImpl.java:91)
	at $Environment_123850a00de.pop($Environment_123850a00de.java)
	at $Environment_123850a0068.pop($Environment_123850a0068.java)
	at
$ComponentRequestHandler_123850a0096.handleComponentEvent($ComponentRequestHandler_123850a0096.java)
...snip
	at
de.avetana.patientenakte.services.AppModule$1.service(AppModule.java:107)


We can continue normally as long as we don't make this exception visible,
but still, obviously something is wrong. The action handler which messes
around with the PageRenderRequestHandler is:



> 	@Inject
> 	private TypeCoercer typeCoercer;
> 
> 	@InjectPage
> 	private EmailPostPage emailPostPage;
> 
> 	//Inject more...
> 
> 	@OnEvent(component = "prepareEmail")
> 	public EmailPostPage onPrepareEmail()
> 	{
> 		Request request = requestGlobals.getRequest();
> 		Response response = requestGlobals.getResponse();
> 		String encoding =
> requestGlobals.getHTTPServletRequest().getCharacterEncoding();
> 		ResponseWrapper responseWrapper = new ResponseWrapper(response,
> 			encoding); //implements Response, exposes content
> 		requestGlobals.storeRequestResponse(request, responseWrapper);
> 
> 		Component page = componentResources.getPage();
> 		Object data = new Object(); //try to get the context by reflection
> 		try
> 		{
> 			Method onpassivate = page.getClass().getMethod("onPassivate");
> 			data = onpassivate.invoke(page);
> 		}
> 		catch (NoSuchMethodException e1)
> 		{
> 			Debug.debug("OK, no activation context.");
> 		}
> 		catch (Exception e) //shortened for mailinglist
> 		{
> 			e.printStackTrace();
> 		}
> 
> 		PageRenderRequestParameters parameters = new
> PageRenderRequestParameters(
> 			componentResources.getPageName(), new ArrayEventContext(
> 				typeCoercer, data));
> 		try
> 		{
> 			pageRenderRequestHandler.handle(parameters);
> 			requestGlobals.storeRequestResponse(request, response);
> 		}
> 		catch (IOException e)
> 		{
> 			// TODO Auto-generated catch block
> 			e.printStackTrace();
> 		}
> 		currentASO.setEmailContentRaw(responseWrapper.getContent());
> 		emailForwardPage.setRawContent(responseWrapper.getContent());
> 		emailPostPage.setData(responseWrapper.getContent());
> 		return emailPostPage;
> 	}
> 
-- 
View this message in context: http://www.nabble.com/T5%3A-Email-Component-to-send-me-current-web-page-tp25282810p25293899.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org