Re: Html Email Messages

2006-12-14 Thread explido

thanks dave, 

the difference seems to be that i'm using Tap 4.1.1 S and there is no way to
store a ResponseBuilder via RequestGlobals

http://tapestry.apache.org/tapestry4.1/tapestry-framework/apidocs/org/apache/tapestry/services/RequestGlobals.html
4.1.1 API Doc 

... still struggling

marco


-- 
View this message in context: 
http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7869987
Sent from the Tapestry - User mailing list archive at Nabble.com.


Re: Html Email Messages

2006-12-14 Thread Jesse Kuhnert

It works that way on purpose. You aren't supposed to be storing it or
thinking about how to store it. If you follow the advice I gave
earlier in this thread on the approach involving hivemind you'll
probably have better luck.

On 12/14/06, explido [EMAIL PROTECTED] wrote:


thanks dave,

the difference seems to be that i'm using Tap 4.1.1 S and there is no way to
store a ResponseBuilder via RequestGlobals

http://tapestry.apache.org/tapestry4.1/tapestry-framework/apidocs/org/apache/tapestry/services/RequestGlobals.html
4.1.1 API Doc

... still struggling

marco


--
View this message in context: 
http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7869987
Sent from the Tapestry - User mailing list archive at Nabble.com.





--
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Html Email Messages

2006-12-13 Thread explido

i'm concerned with the same problem and have tried to examine your solution
without getting it to work.

My first problem seems to imagine the EmailResponseBuilder class. I derived
the EmailResponseBuilder from the DefaultResponseBuilder overriding
renderResponse, render and getWriter without success. Your constructor
carries the cycle, how is this uses inside the EmailResponseBuilder?

My second Problem is your getRequestGlobals(IRequestCycle cycle) method.
Where do you get it from?
I've tried with the following injection:

   @InjectObject(service:tapestry.globals.RequestGlobals)
public abstract RequestGlobals getRequestGlobals();

... but there is no way to store the ResponseBuilder like you do.

where is the magic? can you give me a some advice? thx.

Marco
-- 
View this message in context: 
http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7857759
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Html Email Messages

2006-12-13 Thread Jesse Kuhnert

This could be made more transparent by using the
ResponseDelegateFactory services to configure your specific type of
builder within tapestry proper.

http://tapestry.apache.org/tapestry4.1/tapestry-framework/hivedoc/service/tapestry.services.ResponseDelegateFactory.html

All you would need to do then is make sure your builder knew which
types of requests it can handle and it would magically work with all
core tapestry services.

On 12/13/06, explido [EMAIL PROTECTED] wrote:


i'm concerned with the same problem and have tried to examine your solution
without getting it to work.

My first problem seems to imagine the EmailResponseBuilder class. I derived
the EmailResponseBuilder from the DefaultResponseBuilder overriding
renderResponse, render and getWriter without success. Your constructor
carries the cycle, how is this uses inside the EmailResponseBuilder?

My second Problem is your getRequestGlobals(IRequestCycle cycle) method.
Where do you get it from?
I've tried with the following injection:

   @InjectObject(service:tapestry.globals.RequestGlobals)
public abstract RequestGlobals getRequestGlobals();

... but there is no way to store the ResponseBuilder like you do.

where is the magic? can you give me a some advice? thx.

Marco
--
View this message in context: 
http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7857759
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Html Email Messages

2006-12-13 Thread Dave Kallstrom

getRequestGlobals is injected into our BasePage as in the following...
@InjectObject(service:tapestry.globals.RequestGlobals)
   public abstract RequestGlobals getRequestGlobals();
the getRequestGlobals() is just a convenience method for returning
requestGlobals from the underlying page.
And attached is the EmailResponseBuilder as an example of how to implement
ResponseBuilder. I too tried extending the DefaultResponseBuilder but could
not get that to work.

On 12/13/06, explido [EMAIL PROTECTED] wrote:



i'm concerned with the same problem and have tried to examine your
solution
without getting it to work.

My first problem seems to imagine the EmailResponseBuilder class. I
derived
the EmailResponseBuilder from the DefaultResponseBuilder overriding
renderResponse, render and getWriter without success. Your
constructor
carries the cycle, how is this uses inside the EmailResponseBuilder?

My second Problem is your getRequestGlobals(IRequestCycle cycle) method.
Where do you get it from?
I've tried with the following injection:

   @InjectObject(service:tapestry.globals.RequestGlobals)
public abstract RequestGlobals getRequestGlobals();

... but there is no way to store the ResponseBuilder like you do.

where is the magic? can you give me a some advice? thx.

Marco
--
View this message in context:
http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7857759
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Dave Kallstrom
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Re: Html Email Messages

2006-12-13 Thread explido

hi Dave,

that's just the same injection i've done, but i can't do calls like

getRequestGlobals(cycle).store(builder);

i can not pass a cycle and can not store a ResponseBuilder since
getRequestGlobals().store() does only accept
an IRequestCycle

Instead i've tried:

innerCycle.setResponseBuilder(rb);

but still no fun.

... my implementation of EMailResponseBuilder looks like this:

public class EMailResponseBuilder extends DefaultResponseBuilder {
IMarkupWriter _writer;
AssetFactory _assetFactory;

private final static Log LOG =
LogFactory.getLog(EMailResponseBuilder.class);

public EMailResponseBuilder() {
this(null);
}

public EMailResponseBuilder(IMarkupWriter writer) {
super(writer);
_writer = writer;
}

@Override
public IMarkupWriter getWriter() {
if (_writer == null)
return NullWriter.getSharedInstance();
return _writer;
}

@Override
public IMarkupWriter getWriter(String id, String type) {
if (_writer == null)
return NullWriter.getSharedInstance();
return _writer;
}

@Override
public void render(IMarkupWriter writer, IRender render, IRequestCycle
cycle) {
if (writer == null)
render.render(_writer, cycle);
else
render.render(writer, cycle);
}

@Override
public void renderResponse(IRequestCycle cycle) throws IOException {
if (_writer == null) {
IPage page = cycle.getPage();
ContentType contentType = page.getResponseContentType();
String encoding = 
contentType.getParameter(ENCODING_KEY);
if (encoding == null)
{
encoding = 
cycle.getEngine().getOutputEncoding();
contentType.setParameter(ENCODING_KEY, 
encoding);
}

MarkupFilter filter = new AsciiMarkupFilter();
CharArrayWriter charArrayWriter = new CharArrayWriter();
PrintWriter printWriter = new 
PrintWriter(charArrayWriter);
_writer = new MarkupWriterImpl(text/html, 
printWriter, filter);
}
// render response
cycle.renderPage(this);
_writer.close();
}
}






Dave Kallstrom wrote:
 
 getRequestGlobals is injected into our BasePage as in the following...
 @InjectObject(service:tapestry.globals.RequestGlobals)
 public abstract RequestGlobals getRequestGlobals();
 the getRequestGlobals() is just a convenience method for returning
 requestGlobals from the underlying page.
 And attached is the EmailResponseBuilder as an example of how to implement
 ResponseBuilder. I too tried extending the DefaultResponseBuilder but
 could
 not get that to work.
 
 On 12/13/06, explido [EMAIL PROTECTED] wrote:


 i'm concerned with the same problem and have tried to examine your
 solution
 without getting it to work.

 My first problem seems to imagine the EmailResponseBuilder class. I
 derived
 the EmailResponseBuilder from the DefaultResponseBuilder overriding
 renderResponse, render and getWriter without success. Your
 constructor
 carries the cycle, how is this uses inside the EmailResponseBuilder?

 My second Problem is your getRequestGlobals(IRequestCycle cycle) method.
 Where do you get it from?
 I've tried with the following injection:

@InjectObject(service:tapestry.globals.RequestGlobals)
 public abstract RequestGlobals getRequestGlobals();

 ... but there is no way to store the ResponseBuilder like you do.

 where is the magic? can you give me a some advice? thx.

 Marco
 --
 View this message in context:
 http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7857759
 Sent from the Tapestry - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 
 -- 
 Dave Kallstrom
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-- 
View this message in context: 
http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7858611
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Html Email Messages

2006-12-13 Thread explido

my intention was simply to implement a listener on a page in order to send an
email.
the body of this email in turn should be generated out of another tapestry
page.

so the main problem is to simply return a rendered page as a string or
similar, instead of writing it to a response.

is there no simple way to achieve this?




Jessek wrote:
 
 This could be made more transparent by using the
 ResponseDelegateFactory services to configure your specific type of
 builder within tapestry proper.
 
 http://tapestry.apache.org/tapestry4.1/tapestry-framework/hivedoc/service/tapestry.services.ResponseDelegateFactory.html
 
 All you would need to do then is make sure your builder knew which
 types of requests it can handle and it would magically work with all
 core tapestry services.
 
 On 12/13/06, explido [EMAIL PROTECTED] wrote:

 i'm concerned with the same problem and have tried to examine your
 solution
 without getting it to work.

 My first problem seems to imagine the EmailResponseBuilder class. I
 derived
 the EmailResponseBuilder from the DefaultResponseBuilder overriding
 renderResponse, render and getWriter without success. Your
 constructor
 carries the cycle, how is this uses inside the EmailResponseBuilder?

 My second Problem is your getRequestGlobals(IRequestCycle cycle) method.
 Where do you get it from?
 I've tried with the following injection:

@InjectObject(service:tapestry.globals.RequestGlobals)
 public abstract RequestGlobals getRequestGlobals();

 ... but there is no way to store the ResponseBuilder like you do.

 where is the magic? can you give me a some advice? thx.

 Marco
 --
 View this message in context:
 http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7857759
 Sent from the Tapestry - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 
 
 -- 
 Jesse Kuhnert
 Tapestry/Dojo team member/developer
 
 Open source based consulting work centered around
 dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7858821
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Html Email Messages

2006-12-13 Thread Dave Kallstrom

getRequestGlobals(IRequestCycle cycle) simply calls cycle.getPage() to
return the our base paqe which has RequestGlobals injected into it. And if
you look at RequestGlobals you'll see the method void store(ResponseBuilder
builder) and like I mentioned earlier extending DefaultResponseBuilder did
not work for me. Which is why I created EmailResponseBuilder which is almost
identical to DefaultResponseBuilder.

On 12/13/06, explido [EMAIL PROTECTED] wrote:



hi Dave,

that's just the same injection i've done, but i can't do calls like

getRequestGlobals(cycle).store(builder);

i can not pass a cycle and can not store a ResponseBuilder since
getRequestGlobals().store() does only accept
an IRequestCycle

Instead i've tried:

innerCycle.setResponseBuilder(rb);

but still no fun.

... my implementation of EMailResponseBuilder looks like this:

public class EMailResponseBuilder extends DefaultResponseBuilder {
IMarkupWriter _writer;
AssetFactory _assetFactory;

private final static Log LOG =
LogFactory.getLog(EMailResponseBuilder.class);

public EMailResponseBuilder() {
this(null);
}

public EMailResponseBuilder(IMarkupWriter writer) {
super(writer);
_writer = writer;
}

@Override
public IMarkupWriter getWriter() {
if (_writer == null)
return NullWriter.getSharedInstance();
return _writer;
}

@Override
public IMarkupWriter getWriter(String id, String type) {
if (_writer == null)
return NullWriter.getSharedInstance();
return _writer;
}

@Override
public void render(IMarkupWriter writer, IRender render,
IRequestCycle
cycle) {
if (writer == null)
render.render(_writer, cycle);
else
render.render(writer, cycle);
}

@Override
public void renderResponse(IRequestCycle cycle) throws IOException
{
if (_writer == null) {
IPage page = cycle.getPage();
ContentType contentType =
page.getResponseContentType();
String encoding = contentType.getParameter
(ENCODING_KEY);
if (encoding == null)
{
encoding = cycle.getEngine
().getOutputEncoding();
contentType.setParameter(ENCODING_KEY,
encoding);
}

MarkupFilter filter = new AsciiMarkupFilter();
CharArrayWriter charArrayWriter = new
CharArrayWriter();
PrintWriter printWriter = new
PrintWriter(charArrayWriter);
_writer = new MarkupWriterImpl(text/html,
printWriter, filter);
}
// render response
cycle.renderPage(this);
_writer.close();
}
}






Dave Kallstrom wrote:

 getRequestGlobals is injected into our BasePage as in the following...
 @InjectObject(service:tapestry.globals.RequestGlobals)
 public abstract RequestGlobals getRequestGlobals();
 the getRequestGlobals() is just a convenience method for returning
 requestGlobals from the underlying page.
 And attached is the EmailResponseBuilder as an example of how to
implement
 ResponseBuilder. I too tried extending the DefaultResponseBuilder but
 could
 not get that to work.

 On 12/13/06, explido [EMAIL PROTECTED] wrote:


 i'm concerned with the same problem and have tried to examine your
 solution
 without getting it to work.

 My first problem seems to imagine the EmailResponseBuilder class. I
 derived
 the EmailResponseBuilder from the DefaultResponseBuilder overriding
 renderResponse, render and getWriter without success. Your
 constructor
 carries the cycle, how is this uses inside the EmailResponseBuilder?

 My second Problem is your getRequestGlobals(IRequestCycle cycle)
method.
 Where do you get it from?
 I've tried with the following injection:

@InjectObject(service:tapestry.globals.RequestGlobals)
 public abstract RequestGlobals getRequestGlobals();

 ... but there is no way to store the ResponseBuilder like you do.

 where is the magic? can you give me a some advice? thx.

 Marco
 --
 View this message in context:
 http://www.nabble.com/Html-Email-Messages-tf2776596.html#a7857759
 Sent from the Tapestry - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




 --
 Dave Kallstrom

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


--
View this message in context:
http

Re: Html Email Messages

2006-12-11 Thread Dave Kallstrom

So I'll answer my own question in case anyone else is trying to render html
emal with Tap 4.1
The underlying problem was not swapping out the DefaultResponseBuilder from
RequestGlobals and also having to implement ResponseBuilder.
Here is a snippet of code.
   ResponseBuilder defaultBuilder =
getRequestGlobals(cycle).getResponseBuilder();
   IEngine engine = cycle.getEngine();
   RequestCycleFactory factory = getRequestCycleFactory(cycle);

   IRequestCycle inner = factory.newRequestCycle(engine);
   String[] subjectAndBody = new String[2];
   BaseHTMLMessagePage sendPage = (BaseHTMLMessagePage)
getHtmlPage(inner);

   ByteArrayOutputStream out = new ByteArrayOutputStream();
   IMarkupWriter writer = new MarkupWriterImpl(text/html, new
PrintWriter(out), new AsciiMarkupFilter());
   ResponseBuilder builder = new EmailResponseBuilder(writer,
engine.getInfrastructure().getAssetFactory(), false, cycle);

   getRequestGlobals(cycle).store(builder);

   inner.activate(sendPage);
   inner.renderPage(builder);
   writer.flush();
   subjectAndBody[0] = sendPage.getSubject();
   subjectAndBody[1] = out.toString();
   inner.cleanup();

Notice the storing of the EmailResponseBuilder in requestGlobals and then
replacing it with the original DefaultResponseBuilder.
I'm not sure if all of this was necessary but it's the only way I could get
it to work. I will investigate using hivemind to wire up the
EmailResponseBuilder and also the HtmlEmailPage. But for now this is how I
got it to work.

On 12/7/06, Sam Gendler [EMAIL PROTECTED] wrote:


I don't know 4.1, but if you provide a Response and replace the
outputstream, you'll likely get what you want.  You'll just have to
ensure the headers don't get sent, but I believe that is a method you
can overload in the Response.

--sam


On 12/7/06, Dave Kallstrom [EMAIL PROTECTED] wrote:
 In tapestry versions prior to 4.1 we rendered email message using
tapestry
 with the following code.

 BaseHTMLMessagePage sendPage = (BaseHTMLMessagePage) getHtmlPage(inner);
 ByteArrayOutputStream out = new ByteArrayOutputStream();
 IMarkupWriter writer = new MarkupWriterImpl(text/html, new
 PrintWriter(out), new AsciiMarkupFilter());
 inner.activate(sendPage);
 inner.renderPage(writer);
 writer.flush();
 subjectAndBody[0] = sendPage.getSubject();
 subjectAndBody[1] = out.toString();
 inner.cleanup();
 getRequestGlobals(cycle).store(cycle);

 After recently upgrading to 4.1 this method no longer works.
 RequestCycle.renderPage no longer takes an IMarkupWriter but requires a
 ResponseBuilder. I've tried the DefaultResponseBuilder which seems to
want
 to write to the WebResponse instead of the IMarkupWriter that I send it.
My
 question is how best to make this work again? Do I need to implement a
new
 ResponseBuilder somehow or extend the DefaultResponseBuilder? Or is
there a
 better way to render tapestry pages for html email?
 --
 Dave Kallstrom



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Dave Kallstrom


Re: Re: Html Email Messages

2006-12-11 Thread Sam Gendler

I just stuck a page referencing the methods in your emails and others
on the wiki here:

http://wiki.apache.org/tapestry/SendingHtmlEmailWithTap

Thanks.

--sam

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Html Email Messages

2006-12-07 Thread Dave Kallstrom

In tapestry versions prior to 4.1 we rendered email message using tapestry
with the following code.

BaseHTMLMessagePage sendPage = (BaseHTMLMessagePage) getHtmlPage(inner);
ByteArrayOutputStream out = new ByteArrayOutputStream();
IMarkupWriter writer = new MarkupWriterImpl(text/html, new
PrintWriter(out), new AsciiMarkupFilter());
inner.activate(sendPage);
inner.renderPage(writer);
writer.flush();
subjectAndBody[0] = sendPage.getSubject();
subjectAndBody[1] = out.toString();
inner.cleanup();
getRequestGlobals(cycle).store(cycle);

After recently upgrading to 4.1 this method no longer works.
RequestCycle.renderPage no longer takes an IMarkupWriter but requires a
ResponseBuilder. I've tried the DefaultResponseBuilder which seems to want
to write to the WebResponse instead of the IMarkupWriter that I send it. My
question is how best to make this work again? Do I need to implement a new
ResponseBuilder somehow or extend the DefaultResponseBuilder? Or is there a
better way to render tapestry pages for html email?
--
Dave Kallstrom


Re: Html Email Messages

2006-12-07 Thread Sam Gendler

I don't know 4.1, but if you provide a Response and replace the
outputstream, you'll likely get what you want.  You'll just have to
ensure the headers don't get sent, but I believe that is a method you
can overload in the Response.

--sam


On 12/7/06, Dave Kallstrom [EMAIL PROTECTED] wrote:

In tapestry versions prior to 4.1 we rendered email message using tapestry
with the following code.

BaseHTMLMessagePage sendPage = (BaseHTMLMessagePage) getHtmlPage(inner);
ByteArrayOutputStream out = new ByteArrayOutputStream();
IMarkupWriter writer = new MarkupWriterImpl(text/html, new
PrintWriter(out), new AsciiMarkupFilter());
inner.activate(sendPage);
inner.renderPage(writer);
writer.flush();
subjectAndBody[0] = sendPage.getSubject();
subjectAndBody[1] = out.toString();
inner.cleanup();
getRequestGlobals(cycle).store(cycle);

After recently upgrading to 4.1 this method no longer works.
RequestCycle.renderPage no longer takes an IMarkupWriter but requires a
ResponseBuilder. I've tried the DefaultResponseBuilder which seems to want
to write to the WebResponse instead of the IMarkupWriter that I send it. My
question is how best to make this work again? Do I need to implement a new
ResponseBuilder somehow or extend the DefaultResponseBuilder? Or is there a
better way to render tapestry pages for html email?
--
Dave Kallstrom




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]