Tapestry Export functionality Problem

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Tapestry Export functionality Problem

Siddharth Tyagi
Hi Team,

I need to develop a export functionality so that i can export the viewed
HTML page into word document.
I have achieved the same functionality in JSP (below is the code), but
unable to develop the same in Tapestry.
Can you please help me so that i can develop the same functionality in
Tapestry.

--------------------------------------------------------------------
JSP Code
--------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Export to Word - Demo</title>
</head>
<body>
    <%
    String exportToWord;
        exportToWord = request.getParameter("exportToWord");
        if (exportToWord != null
                && exportToWord.toString().equalsIgnoreCase("YES")) {
            response.setContentType("application/vnd.ms-word");
            response.setHeader("Content-Disposition", "inline;
filename="
                    + "word.doc");
 
        }
    %>
    This is the plain text.
    <p>
    <i>This is the italic text. </i>
    <p>
    <b>This is the bold text. </b>
    <p>
    <s>This is the strike text.</s>
    <p>
    <font color="green">This is the color text. </font>
    <p>
    <a href="#">This is hyperlink. </a>
    <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%
        if (exportToWord == null) {
    %>
    <a href="word.jsp?exportToWord=YES">Export to Word</a>
    <%
        }
    %>
</body>
</html>
-----------------------------------------------------------------


Thanks
Siddharth


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Tapestry Export functionality Problem

Thiago H de Paula Figueiredo
On Fri, 24 Apr 2015 05:48:04 -0300, Siddharth Tyagi  
<[hidden email]> wrote:

> Hi Team,

Hi!

> I need to develop a export functionality so that i can export the viewed
> HTML page into word document.
> I have achieved the same functionality in JSP (below is the code), but
> unable to develop the same in Tapestry.

Really? Without any library? Just outputting HTML with MIME type  
"application/vnd.ms-word" and naming the result file name as  
something.doc? I'm sorry, but I need to see some example of this working  
to believe it and I'd like to be proven wrong.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Tapestry Export functionality Problem

Siddharth Tyagi
Thiago H de Paula Figueiredo <thiagohp <at> gmail.com> writes:

>
> On Fri, 24 Apr 2015 05:48:04 -0300, Siddharth Tyagi  
> <siddharth.tyagi <at> niit-tech.com> wrote:
>
> > Hi Team,
>
> Hi!
>
> > I need to develop a export functionality so that i can export the
viewed
> > HTML page into word document.
> > I have achieved the same functionality in JSP (below is the code), but
> > unable to develop the same in Tapestry.
>
> Really? Without any library? Just outputting HTML with MIME type  
> "application/vnd.ms-word" and naming the result file name as  
> something.doc? I'm sorry, but I need to see some example of this working  
> to believe it and I'd like to be proven wrong.
>


Hi!,

I Have uploaded the same example in the above query, you can run the same
program as a web application and check the result.



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Tapestry Export functionality Problem

Siddharth Tyagi
In reply to this post by Thiago H de Paula Figueiredo
Thiago H de Paula Figueiredo <thiagohp <at> gmail.com> writes:

>
> On Fri, 24 Apr 2015 05:48:04 -0300, Siddharth Tyagi  
> <siddharth.tyagi <at> niit-tech.com> wrote:
>
> > Hi Team,
>
> Hi!
>
> > I need to develop a export functionality so that i can export the
viewed
> > HTML page into word document.
> > I have achieved the same functionality in JSP (below is the code),
but
> > unable to develop the same in Tapestry.
>
> Really? Without any library? Just outputting HTML with MIME type  
> "application/vnd.ms-word" and naming the result file name as  
> something.doc? I'm sorry, but I need to see some example of this
working  
> to believe it and I'd like to be proven wrong.
>


Hi,

Did you check the code i have copied in my question.?
If not then please try that as a web application and check if it is
working or not.?
As for me its working fine.
If yo have any work around in Tapestry 4 then please share

Thanks
Siddharth


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Tapestry Export functionality Problem

Chris Poulsen
In reply to this post by Siddharth Tyagi
I think that Thiago means that you cannot expect to create a "real" word
document simply by altering the response type, attachment filename and
still be returning html. You will receive something that word attempts to
parse into something "meaningful" - but it is not a "real" word document
(binary or xml format or what they use these days).

That aside; if you want to control the response stream you can use
StreamResponse (the wiki has some examples for returning images/pdf as far
as I remember).

If you want to use tapestry templates for generating your content, there
are some different possibilities (there are threads on the mailinglist
about generating stuff like emails from templates, maybe tapestry-offline).

Basically there are many possible ways of applying your hack, depending on
where you get your content from - I think it may even be possible to keep
tapestry from knowing about this by using a normal http filter around it.

--
Chris

On Wed, Apr 29, 2015 at 7:32 AM, Siddharth Tyagi <
[hidden email]> wrote:

> Thiago H de Paula Figueiredo <thiagohp <at> gmail.com> writes:
>
> >
> > On Fri, 24 Apr 2015 05:48:04 -0300, Siddharth Tyagi
> > <siddharth.tyagi <at> niit-tech.com> wrote:
> >
> > > Hi Team,
> >
> > Hi!
> >
> > > I need to develop a export functionality so that i can export the
> viewed
> > > HTML page into word document.
> > > I have achieved the same functionality in JSP (below is the code), but
> > > unable to develop the same in Tapestry.
> >
> > Really? Without any library? Just outputting HTML with MIME type
> > "application/vnd.ms-word" and naming the result file name as
> > something.doc? I'm sorry, but I need to see some example of this working
> > to believe it and I'd like to be proven wrong.
> >
>
>
> Hi!,
>
> I Have uploaded the same example in the above query, you can run the same
> program as a web application and check the result.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Tapestry Export functionality Problem

Siddharth Tyagi
Hi Chris,

Thanks you for taking time form your schedule and answer my question.
The problem i am facing to develop this functionality is version of
Tapestry which is 4.16.
I got some link in which i have found the solution, but they all are
achieved in Tapestry5.
So it would be really grateful if you can help to find the solution in
Tapestry4.

Siddharth





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]