You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Net Dawg <ne...@yahoo.com.INVALID> on 2014/08/02 23:21:39 UTC

Simpler Hello World

Here is the simplest Hello World, according to jump start:
http://jumpstart.doublenegative.com.au/jumpstart/helloworld


I would like to do something simpler.  No html, body tags etc, just pure streaming content.  Comlpletely do away with templates and components, just use the page 
class to stream "Hello World" to browser.


In above example, I tried to set HelloWorld.tml as just 


${username}

the idea being getUserName can be XML, PDF or whatever...but get the following error: 

  Content is not allowed in prolog

Re: Simpler Hello World

Posted by Net Dawg <ne...@yahoo.com.INVALID>.
Believe the answer can be derived from following wiki: 

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

use the contentType = "text/plain".  


I already had the "Hello World" streaming working in another page (in response to a button click/form submit as per above wiki) so I just did this and it seems to work fine as it is the one and only method in the page class: 


    @InjectPage
    private Index index;
    

  //
  public StreamResponse onActivate()
   {
      return index.onSelectedFromHelloWorld();
    }



On Saturday, August 2, 2014 12:22 PM, Net Dawg <ne...@yahoo.com.INVALID> wrote:
 


Thanks, Eugen, for taking the time for below.  However, that does not meet requirement.  Specifically, I am *NOT* wanting to write any HTML or tags, just stream simple text content to the browser.  In this case, just two words exactly as "Hello World".   No begin, end html tags (template would be simpler in that case).  I also tried writeRaw() method as below after looking up org.apache.tapestry5.MarkupWriter: 


      void beginRender(MarkupWriter writer) 
      {
        //writer.element("html");
        writer.writeRaw("Hello World");    
        //writer.end();
      }

Get the following error: 


Page ... did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering.

I am looking into (perhaps) some usage of org.apache.tapestry5.services.StreamPageContent...the manual seems to suggest it is possible. 



On Saturday, August 2, 2014 11:58 AM, Eugen <eu...@gmail.com> wrote:



Hi,
if You don't like to use the template (.tml) files the entire job is to be done in page class using the MarkupWriter,
a simple example:

public class Home{
    void beginRender(MarkupWriter writer) {
        writer.element("html");
        writer.write("test");
        writer.end();
    }
}

this will write to the output html the text "test".

in this case, important is to start the page with the <html> element.


Best regards

Eugen



2014-08-02 23:21 GMT+02:00 Net Dawg <ne...@yahoo.com.invalid>:

Here is the simplest Hello World, according to jump start:
>http://jumpstart.doublenegative.com.au/jumpstart/helloworld
>
>
>I would like to do something simpler.  No html, body tags etc, just pure streaming content.  Completely do away with templates and components, just use the page class to stream "Hello World" to browser.

>
>
>In above example, I tried to set HelloWorld.tml as just
>
>
>${username}
>
>the idea being getUserName can be XML, PDF or whatever...but get the following error:
>
>  Content is not allowed in prolog

Re: Simpler Hello World

Posted by Net Dawg <ne...@yahoo.com.INVALID>.
Thanks, Eugen, for taking the time for below.  However, that does not meet requirement.  Specifically, I am *NOT* wanting to write any HTML or tags, just stream simple text content to the browser.  In this case, just two words exactly as "Hello World".   No begin, end html tags (template would be simpler in that case).  I also tried writeRaw() method as below after looking up org.apache.tapestry5.MarkupWriter: 


      void beginRender(MarkupWriter writer) 
      {
        //writer.element("html");
        writer.writeRaw("Hello World");    
        //writer.end();
      }

Get the following error: 


Page ... did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering.

I am looking into (perhaps) some usage of org.apache.tapestry5.services.StreamPageContent...the manual seems to suggest it is possible. 



On Saturday, August 2, 2014 11:58 AM, Eugen <eu...@gmail.com> wrote:
 


Hi,
if You don't like to use the template (.tml) files the entire job is to be done in page class using the MarkupWriter,
a simple example:

public class Home{
    void beginRender(MarkupWriter writer) {
        writer.element("html");
        writer.write("test");
        writer.end();
    }
}

this will write to the output html the text "test".

in this case, important is to start the page with the <html> element.


Best regards

Eugen



2014-08-02 23:21 GMT+02:00 Net Dawg <ne...@yahoo.com.invalid>:

Here is the simplest Hello World, according to jump start:
>http://jumpstart.doublenegative.com.au/jumpstart/helloworld
>
>
>I would like to do something simpler.  No html, body tags etc, just pure streaming content.  Completely do away with templates and components, just use the page class to stream "Hello World" to browser.
>
>
>In above example, I tried to set HelloWorld.tml as just
>
>
>${username}
>
>the idea being getUserName can be XML, PDF or whatever...but get the following error:
>
>  Content is not allowed in prolog

Re: Simpler Hello World

Posted by Eugen <eu...@gmail.com>.
Hi,
if You don't like to use the template (.tml) files the entire job is to be
done in page class using the MarkupWriter,
a simple example:

public class Home{
    void beginRender(MarkupWriter writer) {
        writer.element("html");
        writer.write("test");
        writer.end();
    }
}
this will write to the output html the text "test".
in this case, important is to start the page with the <html> element.

Best regards
Eugen

2014-08-02 23:21 GMT+02:00 Net Dawg <ne...@yahoo.com.invalid>:

> Here is the simplest Hello World, according to jump start:
> http://jumpstart.doublenegative.com.au/jumpstart/helloworld
>
>
> I would like to do something simpler.  No html, body tags etc, just pure
> streaming content.  Comlpletely do away with templates and components, just
> use the page
> class to stream "Hello World" to browser.
>
>
> In above example, I tried to set HelloWorld.tml as just
>
>
> ${username}
>
> the idea being getUserName can be XML, PDF or whatever...but get the
> following error:
>
>   Content is not allowed in prolog

Re: Simpler Hello World

Posted by Net Dawg <ne...@yahoo.com.INVALID>.
Yes, I may have hijacked my own thread ;-).  


Yes, I wanted to do parameterized/using flash persisted session variables.  Use case being: first do query/search for a term using HTML interface to a database, then print the result rendered also in PDF format using a button/link.  But realized that I could not even print "Hello World" using tapestry - (without HTML tags) - let alone create a fancy custom PDF!  That is how this got started... 



On Wednesday, September 3, 2014 11:12 AM, Thiago H de Paula Figueiredo <th...@gmail.com> wrote:
 


On Wed, 03 Sep 2014 17:44:20 -0300, Net Dawg <ne...@yahoo.com.invalid>  
wrote:

> Well, the thread is still open ;-).  Hopefully the tapestry framework  
> developers will see the "parameterized" streaming pattern to be equally  
> important as HTML (and not some sort of hack/gimmick that needs, as you  
> put it, to "abort the goodness").

I'm sorry, Net Dawg, but I really don't get what you're saying in this  
thread. For me, a simple Hello World in Tapestry would be this:

public class HelloWorld {
}

<html>
    <head>
    </head>
    <body>
        <p>Hello, World!</p>
    </body>
</html>

If you're generating HTML, in Tapestry the usual method is using a  
template.

Regarding what you call parameterized streaming pattern, that's not a  
Hello World anymore, and "Simpler Hello World" is the title of the thread  
you've created.

>> Thanks Chris.  The intent of this question was to get a start toward
>> streaming "pure content" - not just text, but also (and especially PDF),
>> XML, imagery - whatever - anything except HTML.  My solution finally  
>> was to mimic a previously coded button press on an HTML page.  Why?  
>> Because that> is where I get all the session variables set (search,  
>> query etc) to
>> properly construct the PDF content.

1) What do you mean by session variables?

2) If you want to use a button, you can. Just use the Form component:

<t:form t:id="pdf">
    <!-- Any form fields you'd want, if any. -->
    <input type="submit" value="Generate PDF"/>
</t:form>

StreamResponse onSuccessFromPdf() {
    StreamResponse response = ...;
    return response;
}

>> Then I hid the button and launched
>> the "pure content" page as a pagelink, instead, as follows:
>>
>> <t:pagelink page="pdf/Index" target="_blank">PDF</t:pagelink>

You can also return StreamResponse in Tapestry event handlers just like  
you do in onActivate().


>> Rather convoluted, but gets the job done....and, yes, hardly a simpler
>> hello world now...(this workaround would be more useful to say "Hello
>> Chris" -  after, say, selecting from an HTML list of users)

My concept of Hello World, which is probably the same most people have, is  
to just output "Hello, World!" using the tool of your choice. If you  
parameterize it, it's not a Hello World anymore.

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

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

Re: Simpler Hello World

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 03 Sep 2014 17:44:20 -0300, Net Dawg <ne...@yahoo.com.invalid>  
wrote:

> Well, the thread is still open ;-).  Hopefully the tapestry framework  
> developers will see the "parameterized" streaming pattern to be equally  
> important as HTML (and not some sort of hack/gimmick that needs, as you  
> put it, to "abort the goodness").

I'm sorry, Net Dawg, but I really don't get what you're saying in this  
thread. For me, a simple Hello World in Tapestry would be this:

public class HelloWorld {
}

<html>
	<head>
	</head>
	<body>
		<p>Hello, World!</p>
	</body>
</html>

If you're generating HTML, in Tapestry the usual method is using a  
template.

Regarding what you call parameterized streaming pattern, that's not a  
Hello World anymore, and "Simpler Hello World" is the title of the thread  
you've created.

>> Thanks Chris.  The intent of this question was to get a start toward
>> streaming "pure content" - not just text, but also (and especially PDF),
>> XML, imagery - whatever - anything except HTML.  My solution finally  
>> was to mimic a previously coded button press on an HTML page.  Why?   
>> Because that> is where I get all the session variables set (search,  
>> query etc) to
>> properly construct the PDF content.

1) What do you mean by session variables?

2) If you want to use a button, you can. Just use the Form component:

<t:form t:id="pdf">
	<!-- Any form fields you'd want, if any. -->
	<input type="submit" value="Generate PDF"/>
</t:form>

StreamResponse onSuccessFromPdf() {
	StreamResponse response = ...;
	return response;
}

>> Then I hid the button and launched
>> the "pure content" page as a pagelink, instead, as follows:
>>
>> <t:pagelink page="pdf/Index" target="_blank">PDF</t:pagelink>

You can also return StreamResponse in Tapestry event handlers just like  
you do in onActivate().

>> Rather convoluted, but gets the job done....and, yes, hardly a simpler
>> hello world now...(this workaround would be more useful to say "Hello
>> Chris" -  after, say, selecting from an HTML list of users)

My concept of Hello World, which is probably the same most people have, is  
to just output "Hello, World!" using the tool of your choice. If you  
parameterize it, it's not a Hello World anymore.

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

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


Re: Simpler Hello World

Posted by Net Dawg <ne...@yahoo.com.INVALID>.
Well, the thread is still open ;-).  Hopefully the tapestry framework developers will see the "parameterized" streaming pattern to be equally important as HTML (and not some sort of hack/gimmick that needs, as you put it, to "abort the goodness").  



On Tuesday, September 2, 2014 10:07 PM, Chris Mylonas <ch...@opencsta.org> wrote:
 


I was wondering if you'd want to get the last word in Net Dawg ;)



On Wed, Sep 3, 2014 at 5:26 PM, Net Dawg <ne...@yahoo.com.invalid> wrote:

> Thanks Chris.  The intent of this question was to get a start toward
> streaming "pure content" - not just text, but also (and especially PDF),
> XML, imagery - whatever - anything except HTML.  My solution finally was to
> mimic a previously coded button press on an HTML page.  Why?  Because that
> is where I get all the session variables set (search, query etc) to
> properly construct the PDF content.   Then I hid the button and launched
> the "pure content" page as a pagelink, instead, as follows:
>
> <t:pagelink page="pdf/Index" target="_blank">PDF</t:pagelink>
>
> Rather convoluted, but gets the job done....and, yes, hardly a simpler
> hello world now...(this workaround would be more useful to say "Hello
> Chris" -  after, say, selecting from an HTML list of users)
>
>
>
> On Tuesday, September 2, 2014 4:27 PM, Chris Mylonas <ch...@opencsta.org>
> wrote:
>
>
>
> For future noobs, this is not a simpler hello world, it's making tapestry
> respond with text only, no template, nothing but pure text.
>
> I had to do this today and this thread caught my eye last month.
>
> In the standard tapestry 5.3.7 archetype, my Contact.java looks like this.
>
>
> package org.example.pages;
>
> import org.apache.tapestry5.StreamResponse;
> import org.apache.tapestry5.util.TextStreamResponse;
>
> public class Contact {
>
>     StreamResponse onActivate(){
>         return new TextStreamResponse("text/plain","some plain old text -
> no .tml file, no nothing. plain old text - yay!");
>     }
> }
>
> I wouldn't describe it as a simpler hello world at all because you're
> making tapestry end it's goodness prematurely.  Like learning how to write
> a program and the first statement in main() you learn is exit(1);
>

Re: Simpler Hello World

Posted by Chris Mylonas <ch...@opencsta.org>.
I was wondering if you'd want to get the last word in Net Dawg ;)


On Wed, Sep 3, 2014 at 5:26 PM, Net Dawg <ne...@yahoo.com.invalid> wrote:

> Thanks Chris.  The intent of this question was to get a start toward
> streaming "pure content" - not just text, but also (and especially PDF),
> XML, imagery - whatever - anything except HTML.  My solution finally was to
> mimic a previously coded button press on an HTML page.  Why?  Because that
> is where I get all the session variables set (search, query etc) to
> properly construct the PDF content.   Then I hid the button and launched
> the "pure content" page as a pagelink, instead, as follows:
>
> <t:pagelink page="pdf/Index" target="_blank">PDF</t:pagelink>
>
> Rather convoluted, but gets the job done....and, yes, hardly a simpler
> hello world now...(this workaround would be more useful to say "Hello
> Chris" -  after, say, selecting from an HTML list of users)
>
>
>
> On Tuesday, September 2, 2014 4:27 PM, Chris Mylonas <ch...@opencsta.org>
> wrote:
>
>
>
> For future noobs, this is not a simpler hello world, it's making tapestry
> respond with text only, no template, nothing but pure text.
>
> I had to do this today and this thread caught my eye last month.
>
> In the standard tapestry 5.3.7 archetype, my Contact.java looks like this.
>
>
> package org.example.pages;
>
> import org.apache.tapestry5.StreamResponse;
> import org.apache.tapestry5.util.TextStreamResponse;
>
> public class Contact {
>
>     StreamResponse onActivate(){
>         return new TextStreamResponse("text/plain","some plain old text -
> no .tml file, no nothing. plain old text - yay!");
>     }
> }
>
> I wouldn't describe it as a simpler hello world at all because you're
> making tapestry end it's goodness prematurely.  Like learning how to write
> a program and the first statement in main() you learn is exit(1);
>

Re: Simpler Hello World

Posted by Net Dawg <ne...@yahoo.com.INVALID>.
Thanks Chris.  The intent of this question was to get a start toward streaming "pure content" - not just text, but also (and especially PDF), XML, imagery - whatever - anything except HTML.  My solution finally was to mimic a previously coded button press on an HTML page.  Why?  Because that is where I get all the session variables set (search, query etc) to properly construct the PDF content.   Then I hid the button and launched the "pure content" page as a pagelink, instead, as follows: 

<t:pagelink page="pdf/Index" target="_blank">PDF</t:pagelink>

Rather convoluted, but gets the job done....and, yes, hardly a simpler hello world now...(this workaround would be more useful to say "Hello Chris" -  after, say, selecting from an HTML list of users)



On Tuesday, September 2, 2014 4:27 PM, Chris Mylonas <ch...@opencsta.org> wrote:
 


For future noobs, this is not a simpler hello world, it's making tapestry
respond with text only, no template, nothing but pure text.

I had to do this today and this thread caught my eye last month.

In the standard tapestry 5.3.7 archetype, my Contact.java looks like this.


package org.example.pages;

import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.util.TextStreamResponse;

public class Contact {

    StreamResponse onActivate(){
        return new TextStreamResponse("text/plain","some plain old text -
no .tml file, no nothing. plain old text - yay!");
    }
}

I wouldn't describe it as a simpler hello world at all because you're
making tapestry end it's goodness prematurely.  Like learning how to write
a program and the first statement in main() you learn is exit(1);

Re: Simpler Hello World

Posted by Chris Mylonas <ch...@opencsta.org>.
For future noobs, this is not a simpler hello world, it's making tapestry
respond with text only, no template, nothing but pure text.

I had to do this today and this thread caught my eye last month.

In the standard tapestry 5.3.7 archetype, my Contact.java looks like this.


package org.example.pages;

import org.apache.tapestry5.StreamResponse;
import org.apache.tapestry5.util.TextStreamResponse;

public class Contact {

    StreamResponse onActivate(){
        return new TextStreamResponse("text/plain","some plain old text -
no .tml file, no nothing. plain old text - yay!");
    }
}

I wouldn't describe it as a simpler hello world at all because you're
making tapestry end it's goodness prematurely.  Like learning how to write
a program and the first statement in main() you learn is exit(1);

Re: Simpler Hello World

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Sat, 02 Aug 2014 18:21:39 -0300, Net Dawg <ne...@yahoo.com.invalid>  
wrote:

> I would like to do something simpler.  No html, body tags etc, just pure  
> streaming content.

In this case, you shouldn't use a .tml template, because it's meant to  
generate HTML or XML, and "Hello World" isn't valid HTML or XML. Return a  
StreamResponse in onActivate(). Case closed. :D

> Comlpletely do away with templates and components, just use the page  
> class to stream "Hello World" to browser.
> In above example, I tried to set HelloWorld.tml as just ${username}

In one sentence, you said you don't want to use a template in this case,  
but in the next sentence you use one. The mind boggles.

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

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