You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by roquejo <ro...@yahoo.com> on 2010/01/08 07:48:05 UTC

@Insert not working when converting tapestry page into a byteoutputstream

Hi,

I'm suing tapestry 4.0.2

Kindly help as I've been stuck for a week already, I've been trying to
convert the tapestry page into a byte output stream to save it into a file,
below is the code:

--------------------------------------------------------------------------------------
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        IMarkupWriter subwriter = new MarkupWriterImpl("text/html", new
PrintWriter(bout), new AsciiMarkupFilter());
        renderPage(subwriter, cycle);
        subwriter.flush();
        String body = new String(bout.toByteArray());
        

        File file = new File("c:\\test.html");
        try{
        	FileOutputStream out = new FileOutputStream(file);
        	out.write(bout.toByteArray());
        	out.flush();
        	out.close();
        }catch(Exception e){
        	e.printStackTrace();
       }

-----------------------------------------------------------------------

The page did save into the file but the problem is all the @Insert text are
missing, the page do keep track other things like static texts and size of
the list as it displays the correct number of entries.. the only problem is
the dynamic text representing the records are missing.

But when I finally redirect to the page using the "return IPage", the
@Insert are populated, only the html saved in the file have their @Insert
dynamic content missing  

This is similar to the solution of sending tapestry page as an html format
mail, but this time, it saves the html to the disk instead of emailing it.
-- 
View this message in context: http://old.nabble.com/%40Insert-not-working-when-converting-tapestry-page-into-a-byteoutputstream-tp27071981p27071981.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: @Insert not working when converting tapestry page into a byteoutputstream

Posted by roquejo <ro...@yahoo.com>.
I got it to work already..

I used cycle.render instead of page.render..thanks for your reply 

Andreas Andreou-4 wrote:
> 
> When a form is submitted, Tapestry 4 enters the rewind phase (note that T5
> doesn't need/use this concept)
> That's similar to a normal render and it helps Tapestry find out what
> values
> were submitted and by which controls. Many components can behave
> differently when rendering and when rewinding - @Insert is such a case,
> during rewind it does nothing!
> 
> Anyway, what is happening in your case, is that you're capturing the
> rewind
> (just check the value of cycle.isRewinding() )... also, you're
> probably rendering
> the page twice (once to save as file and once to return to client). I
> believe there's
> some code in the wiki that describes how to do this in a more efficient
> manner.
> 
> 
> On Fri, Jan 8, 2010 at 11:32, roquejo <ro...@yahoo.com> wrote:
>>
>> I just found out that this happens when the submission was made by the
>> @Form
>> component, but if it was submitted by the @Directlink component, it
>> worked
>> fine.
>>
>> Do the @Form component accept a paramater to let it bahave like a
>> DirectLink? That  @Insert component will be rendered immediately?
>> --
>> View this message in context:
>> http://old.nabble.com/%40Insert-not-working-when-converting-tapestry-page-into-a-byteoutputstream-tp27071981p27073383.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
>>
>>
> 
> 
> 
> -- 
> Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
> Tapestry / Tacos developer
> Open Source / JEE Consulting
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/%40Insert-not-working-when-converting-tapestry-page-into-a-byteoutputstream-tp27071981p27086517.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: @Insert not working when converting tapestry page into a byteoutputstream

Posted by Andreas Andreou <an...@di.uoa.gr>.
When a form is submitted, Tapestry 4 enters the rewind phase (note that T5
doesn't need/use this concept)
That's similar to a normal render and it helps Tapestry find out what values
were submitted and by which controls. Many components can behave
differently when rendering and when rewinding - @Insert is such a case,
during rewind it does nothing!

Anyway, what is happening in your case, is that you're capturing the rewind
(just check the value of cycle.isRewinding() )... also, you're
probably rendering
the page twice (once to save as file and once to return to client). I
believe there's
some code in the wiki that describes how to do this in a more efficient manner.


On Fri, Jan 8, 2010 at 11:32, roquejo <ro...@yahoo.com> wrote:
>
> I just found out that this happens when the submission was made by the @Form
> component, but if it was submitted by the @Directlink component, it worked
> fine.
>
> Do the @Form component accept a paramater to let it bahave like a
> DirectLink? That  @Insert component will be rendered immediately?
> --
> View this message in context: http://old.nabble.com/%40Insert-not-working-when-converting-tapestry-page-into-a-byteoutputstream-tp27071981p27073383.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
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

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


Re: @Insert not working when converting tapestry page into a byteoutputstream

Posted by roquejo <ro...@yahoo.com>.
I just found out that this happens when the submission was made by the @Form
component, but if it was submitted by the @Directlink component, it worked
fine.

Do the @Form component accept a paramater to let it bahave like a
DirectLink? That  @Insert component will be rendered immediately?
-- 
View this message in context: http://old.nabble.com/%40Insert-not-working-when-converting-tapestry-page-into-a-byteoutputstream-tp27071981p27073383.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