You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Mylonas <ch...@opencsta.org> on 2012/04/03 11:23:28 UTC

Readable HTML output

Hi Tap List,


I've got production mode set to false and the parts of the html document that I haven't created come out quite nicely.
The parts I have rendered in my component (below) are coming out on one line.  It's the eye-sore of the document!!

How do I fix this?


I'm also wondering what the advantages are of using code to generate the html if I've already built the template in html?
This 

		writer.element("div", "class", "userbackground");
		writer.element("div","id",currentPhone.getNumber(), "class","user");
		writer.element("div","class","infoline1");
		writer.element("div","class","name");
		writer.write(currentPhone.getName() + " " + currentPhone.getNumber());
		writer.end();
		writer.end();
		writer.element("div","class","infoline2");
		writer.element("div","class","voicemail");
		writer.element("img","src","email.png");
		writer.end();
		writer.end();
		writer.end();
		writer.element("div", "class","currentcall currentcallplaceholder");
		writer.writeRaw("&nbsp;");
		writer.end();
		writer.end();
		writer.end();
		writer.element("div","class","spacer");
		writer.end();

VS
this

		writer.writeRaw("" +
		"<div class=\"userbackground\">" +
"<div id=\"" + currentPhone.getNumber() + "\" class=\"user\">" +
    "<div class=\"infoline1\">" +
        "<div class=\"name\">" + currentPhone.getName() + " " + currentPhone.getNumber() + "</div>" +
        "</div>" +
    "<div class=\"infoline2\">" +
        "<div class=\"voicemail\"><img src=\"email.png\" /></div>" +
        "</div>" +
    "<div class=\"currentcall currentcallplaceholder\">&nbsp;" +
    "</div>" +
"</div>" +
"</div>" +
"<div class=\"spacer\">" +
"</div>");



It's just a copy paste, run over it with some backslashes where I need to.

Cheers
Chris

Re: Readable HTML output

Posted by Chris Mylonas <ch...@opencsta.org>.
Hi Thaigo,

oh yeah good point.  i associate firebug with css only really from my drupal days.  i was going to get onto that next now that i've sorted out my asset:context:layout/images/email.png stuff.
i have a several plugins in firefox for privacy and no tracking that most of the b.s. internet is broken with it - and with it, my train of thought - i hadn't even thought about firebug for html!

Thanks - it led to a few good things brought up in the email-trail whilst you were away anyway.
It can't all be efficient web-development ;)

Cheers
Chris




On 03/04/2012, at 9:25 PM, Thiago H. de Paula Figueiredo wrote:

> On Tue, 03 Apr 2012 06:23:28 -0300, Chris Mylonas <ch...@opencsta.org> wrote:
> 
>> Hi Tap List,
> 
> Hi!
> 
>> I've got production mode set to false and the parts of the html document that I haven't created come out quite nicely.
>> The parts I have rendered in my component (below) are coming out on one line.  It's the eye-sore of the document!!
> 
> Why don't you use some tool like Firebug (Firefox) or Dragonfly (Opera) or the Chrome development tools? They provide a nice tree vie of the HTML (most accurately, the client-side DOM) regardless of how the HTML is written.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br


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


Re: Readable HTML output

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 03 Apr 2012 06:23:28 -0300, Chris Mylonas <ch...@opencsta.org>  
wrote:

> Hi Tap List,

Hi!

> I've got production mode set to false and the parts of the html document  
> that I haven't created come out quite nicely.
> The parts I have rendered in my component (below) are coming out on one  
> line.  It's the eye-sore of the document!!

Why don't you use some tool like Firebug (Firefox) or Dragonfly (Opera) or  
the Chrome development tools? They provide a nice tree vie of the HTML  
(most accurately, the client-side DOM) regardless of how the HTML is  
written.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Readable HTML output

Posted by Chris Mylonas <ch...@opencsta.org>.
Thanks Lance, but not quite what I'm after.  It's only given new lines but no indentation (which I presume will disappear in production mode)
It's made my code look a bit ugly.  Maybe I should look at a .tml file set up.

		writer.element("div", "class", "userbackground");
		writer.writeRaw(NEWLINE);
		writer.element("div","id",currentPhone.getNumber(), "class","user");
		writer.writeRaw(NEWLINE);
		writer.element("div","class","infoline1");
		writer.writeRaw(NEWLINE);
		writer.element("div","class","name");
		writer.writeRaw(NEWLINE);
		writer.write(currentPhone.getName() + " " + currentPhone.getNumber());
		writer.writeRaw(NEWLINE);
		writer.end();
		writer.writeRaw(NEWLINE);
		writer.end();
		writer.writeRaw(NEWLINE);
		writer.element("div","class","infoline2");
		writer.writeRaw(NEWLINE);
		writer.element("div","class","voicemail");
		writer.writeRaw(NEWLINE);
		writer.element("img","src","email.png");
		writer.end();
		writer.writeRaw(NEWLINE);
		writer.end();
		writer.writeRaw(NEWLINE);
		writer.end();
		writer.writeRaw(NEWLINE);
		writer.element("div", "class","currentcall currentcallplaceholder");
		writer.writeRaw("&nbsp;");
		writer.end();
		writer.writeRaw(NEWLINE);
		writer.end();
		writer.writeRaw(NEWLINE);
		writer.end();
		writer.writeRaw(NEWLINE);
		writer.element("div","class","spacer");
		writer.writeRaw(NEWLINE);
		writer.end();


Because I don't have the luxury of having a web designer pass me a template, what happens in this case.  You're given a shit-hot template from the designer - you just put it into .tml fragments to go along with the component?




On 03/04/2012, at 7:34 PM, Lance Java wrote:

> This should work:
> 
> private static final String NEWLINE = System.getProperty("line.separator");
> ...
> 
> writer.element("div", "class", "userbackground");
> writer.writeRaw(NEWLINE);
> writer.element("div","id",currentPhone.getNumber(), "class","user");
> ...
> 
> On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
>> Hi Tap List,
>> 
>> 
>> I've got production mode set to false and the parts of the html document
> that I haven't created come out quite nicely.
>> The parts I have rendered in my component (below) are coming out on one
> line.  It's the eye-sore of the document!!
>> 
>> How do I fix this?
>> 
>> 
>> I'm also wondering what the advantages are of using code to generate the
> html if I've already built the template in html?
>> This
>> 
>>               writer.element("div", "class", "userbackground");
>>               writer.element("div","id",currentPhone.getNumber(),
> "class","user");
>>               writer.element("div","class","infoline1");
>>               writer.element("div","class","name");
>>               writer.write(currentPhone.getName() + " " +
> currentPhone.getNumber());
>>               writer.end();
>>               writer.end();
>>               writer.element("div","class","infoline2");
>>               writer.element("div","class","voicemail");
>>               writer.element("img","src","email.png");
>>               writer.end();
>>               writer.end();
>>               writer.end();
>>               writer.element("div", "class","currentcall
> currentcallplaceholder");
>>               writer.writeRaw("&nbsp;");
>>               writer.end();
>>               writer.end();
>>               writer.end();
>>               writer.element("div","class","spacer");
>>               writer.end();
>> 
>> VS
>> this
>> 
>>               writer.writeRaw("" +
>>               "<div class=\"userbackground\">" +
>> "<div id=\"" + currentPhone.getNumber() + "\" class=\"user\">" +
>>   "<div class=\"infoline1\">" +
>>       "<div class=\"name\">" + currentPhone.getName() + " " +
> currentPhone.getNumber() + "</div>" +
>>       "</div>" +
>>   "<div class=\"infoline2\">" +
>>       "<div class=\"voicemail\"><img src=\"email.png\" /></div>" +
>>       "</div>" +
>>   "<div class=\"currentcall currentcallplaceholder\">&nbsp;" +
>>   "</div>" +
>> "</div>" +
>> "</div>" +
>> "<div class=\"spacer\">" +
>> "</div>");
>> 
>> 
>> 
>> It's just a copy paste, run over it with some backslashes where I need to.
>> 
>> Cheers
>> Chris


Re: Readable HTML output

Posted by Chris Mylonas <ch...@opencsta.org>.
I like the .tml approach better so far by a mile.
I can see it easily and it's not too much brain work to get it onto "paper" so to speak.



On 03/04/2012, at 8:12 PM, Lance Java wrote:

> I would still use .tml to generate XML. Tapestry is tied to http, it is
> implemented as a http request filter.
> 
> The only way to use tapestry without http is using tapx-templating, even
> then you would still probably choose .tml for generating XML
> 
> On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
>> I guess the MarkupWriter comes in handy for generating XML documents as
> well
>> 
>> does tapestry allow the output of say,
>> 
>> <xml version=1.0 utf>
>> 
>> </xml>
>> 
>> 
>> That would come in handy for submitting xml documents to other services
> without HTTP.
>> 
>> 
>> On 03/04/2012, at 7:54 PM, Lance Java wrote:
>> 
>>> I always favour .tml for generating markup.
>>> 
>>> The MarkupWriter gives you complete control but in this case, I think
> that
>>> .tml would suit your use case better
>>> 
>>> On Tuesday, 3 April 2012, Lance Java <la...@googlemail.com> wrote:
>>>> This should work:
>>>> 
>>>> private static final String NEWLINE =
>>> System.getProperty("line.separator");
>>>> ...
>>>> 
>>>> writer.element("div", "class", "userbackground");
>>>> writer.writeRaw(NEWLINE);
>>>> writer.element("div","id",currentPhone.getNumber(), "class","user");
>>>> ...
>>>> 
>>>> On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
>>>>> Hi Tap List,
>>>>> 
>>>>> 
>>>>> I've got production mode set to false and the parts of the html
> document
>>> that I haven't created come out quite nicely.
>>>>> The parts I have rendered in my component (below) are coming out on one
>>> line.  It's the eye-sore of the document!!
>>>>> 
>>>>> How do I fix this?
>>>>> 
>>>>> 
>>>>> I'm also wondering what the advantages are of using code to generate
> the
>>> html if I've already built the template in html?
>>>>> This
>>>>> 
>>>>>              writer.element("div", "class", "userbackground");
>>>>>              writer.element("div","id",currentPhone.getNumber(),
>>> "class","user");
>>>>>              writer.element("div","class","infoline1");
>>>>>              writer.element("div","class","name");
>>>>>              writer.write(currentPhone.getName() + " " +
>>> currentPhone.getNumber());
>>>>>              writer.end();
>>>>>              writer.end();
>>>>>              writer.element("div","class","infoline2");
>>>>>              writer.element("div","class","voicemail");
>>>>>              writer.element("img","src","email.png");
>>>>>              writer.end();
>>>>>              writer.end();
>>>>>              writer.end();
>>>>>              writer.element("div", "class","currentcall
>>> currentcallplaceholder");
>>>>>              writer.writeRaw("&nbsp;");
>>>>>              writer.end();
>>>>>              writer.end();
>>>>>              writer.end();
>>>>>              writer.element("div","class","spacer");
>>>>>              writer.end();
>>>>> 
>>>>> VS
>>>>> this
>>>>> 
>>>>>              writer.writeRaw("" +
>>>>>              "<div class=\"userbackground\">" +
>>>>> "<div id=\"" + currentPhone.getNumber() + "\" class=\"user\">" +
>>>>>  "<div class=\"infoline1\">" +
>>>>>      "<div class=\"name\">" + currentPhone.getName() + " " +
>>> currentPhone.getNumber() + "</div>" +
>>>>>      "</div>" +
>>>>>  "<div class=\"infoline2\">" +
>>>>>      "<div
> class=---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 


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


Re: Readable HTML output

Posted by Lance Java <la...@googlemail.com>.
I would still use .tml to generate XML. Tapestry is tied to http, it is
implemented as a http request filter.

The only way to use tapestry without http is using tapx-templating, even
then you would still probably choose .tml for generating XML

On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
> I guess the MarkupWriter comes in handy for generating XML documents as
well
>
> does tapestry allow the output of say,
>
> <xml version=1.0 utf>
>
> </xml>
>
>
> That would come in handy for submitting xml documents to other services
without HTTP.
>
>
> On 03/04/2012, at 7:54 PM, Lance Java wrote:
>
>> I always favour .tml for generating markup.
>>
>> The MarkupWriter gives you complete control but in this case, I think
that
>> .tml would suit your use case better
>>
>> On Tuesday, 3 April 2012, Lance Java <la...@googlemail.com> wrote:
>>> This should work:
>>>
>>> private static final String NEWLINE =
>> System.getProperty("line.separator");
>>> ...
>>>
>>> writer.element("div", "class", "userbackground");
>>> writer.writeRaw(NEWLINE);
>>> writer.element("div","id",currentPhone.getNumber(), "class","user");
>>> ...
>>>
>>> On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
>>>> Hi Tap List,
>>>>
>>>>
>>>> I've got production mode set to false and the parts of the html
document
>> that I haven't created come out quite nicely.
>>>> The parts I have rendered in my component (below) are coming out on one
>> line.  It's the eye-sore of the document!!
>>>>
>>>> How do I fix this?
>>>>
>>>>
>>>> I'm also wondering what the advantages are of using code to generate
the
>> html if I've already built the template in html?
>>>> This
>>>>
>>>>               writer.element("div", "class", "userbackground");
>>>>               writer.element("div","id",currentPhone.getNumber(),
>> "class","user");
>>>>               writer.element("div","class","infoline1");
>>>>               writer.element("div","class","name");
>>>>               writer.write(currentPhone.getName() + " " +
>> currentPhone.getNumber());
>>>>               writer.end();
>>>>               writer.end();
>>>>               writer.element("div","class","infoline2");
>>>>               writer.element("div","class","voicemail");
>>>>               writer.element("img","src","email.png");
>>>>               writer.end();
>>>>               writer.end();
>>>>               writer.end();
>>>>               writer.element("div", "class","currentcall
>> currentcallplaceholder");
>>>>               writer.writeRaw("&nbsp;");
>>>>               writer.end();
>>>>               writer.end();
>>>>               writer.end();
>>>>               writer.element("div","class","spacer");
>>>>               writer.end();
>>>>
>>>> VS
>>>> this
>>>>
>>>>               writer.writeRaw("" +
>>>>               "<div class=\"userbackground\">" +
>>>> "<div id=\"" + currentPhone.getNumber() + "\" class=\"user\">" +
>>>>   "<div class=\"infoline1\">" +
>>>>       "<div class=\"name\">" + currentPhone.getName() + " " +
>> currentPhone.getNumber() + "</div>" +
>>>>       "</div>" +
>>>>   "<div class=\"infoline2\">" +
>>>>       "<div
class=---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Readable HTML output

Posted by Lance Java <la...@googlemail.com>.
Nope, it must be XML as MarkupWriter is backed by a DOM.

Consider a tempting language such as Freemarker and a StreamResponse for
non-XML text formats

On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
> wow! cool....so you could essentially respond with csv files as well?
>
> On 03/04/2012, at 8:11 PM, trsvax wrote:
>
>> It works fine for generating XML. I have many rest style web services
that
>> are really Tapestry pages, but I have not tried to put <xml version="">
at
>> the top of the document. I think that might be tricky but doable one way
or
>> another.
>>
>> --
>> View this message in context:
http://tapestry.1045711.n5.nabble.com/Readable-HTML-output-tp5614619p5614703.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
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Readable HTML output

Posted by trsvax <tr...@gmail.com>.
I have not tried to use MarkupWriter to generate a CSV but I do return CSVs
with StreamResponse. I usually use StreamReponse for XML also but sometimes
it's more work than necessary. For example if you just want something like

<status>OK</status>

MarkupWriter is much easier than either StreamResponse or a .tml file.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Readable-HTML-output-tp5614619p5614765.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: Readable HTML output

Posted by Chris Mylonas <ch...@opencsta.org>.
wow! cool....so you could essentially respond with csv files as well?

On 03/04/2012, at 8:11 PM, trsvax wrote:

> It works fine for generating XML. I have many rest style web services that
> are really Tapestry pages, but I have not tried to put <xml version=""> at
> the top of the document. I think that might be tricky but doable one way or
> another.
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Readable-HTML-output-tp5614619p5614703.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
> 


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


Re: Readable HTML output

Posted by trsvax <tr...@gmail.com>.
It works fine for generating XML. I have many rest style web services that
are really Tapestry pages, but I have not tried to put <xml version=""> at
the top of the document. I think that might be tricky but doable one way or
another.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Readable-HTML-output-tp5614619p5614703.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: Readable HTML output

Posted by Chris Mylonas <ch...@opencsta.org>.
I guess the MarkupWriter comes in handy for generating XML documents as well

does tapestry allow the output of say,

<xml version=1.0 utf>

</xml>


That would come in handy for submitting xml documents to other services without HTTP.


On 03/04/2012, at 7:54 PM, Lance Java wrote:

> I always favour .tml for generating markup.
> 
> The MarkupWriter gives you complete control but in this case, I think that
> .tml would suit your use case better
> 
> On Tuesday, 3 April 2012, Lance Java <la...@googlemail.com> wrote:
>> This should work:
>> 
>> private static final String NEWLINE =
> System.getProperty("line.separator");
>> ...
>> 
>> writer.element("div", "class", "userbackground");
>> writer.writeRaw(NEWLINE);
>> writer.element("div","id",currentPhone.getNumber(), "class","user");
>> ...
>> 
>> On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
>>> Hi Tap List,
>>> 
>>> 
>>> I've got production mode set to false and the parts of the html document
> that I haven't created come out quite nicely.
>>> The parts I have rendered in my component (below) are coming out on one
> line.  It's the eye-sore of the document!!
>>> 
>>> How do I fix this?
>>> 
>>> 
>>> I'm also wondering what the advantages are of using code to generate the
> html if I've already built the template in html?
>>> This
>>> 
>>>               writer.element("div", "class", "userbackground");
>>>               writer.element("div","id",currentPhone.getNumber(),
> "class","user");
>>>               writer.element("div","class","infoline1");
>>>               writer.element("div","class","name");
>>>               writer.write(currentPhone.getName() + " " +
> currentPhone.getNumber());
>>>               writer.end();
>>>               writer.end();
>>>               writer.element("div","class","infoline2");
>>>               writer.element("div","class","voicemail");
>>>               writer.element("img","src","email.png");
>>>               writer.end();
>>>               writer.end();
>>>               writer.end();
>>>               writer.element("div", "class","currentcall
> currentcallplaceholder");
>>>               writer.writeRaw("&nbsp;");
>>>               writer.end();
>>>               writer.end();
>>>               writer.end();
>>>               writer.element("div","class","spacer");
>>>               writer.end();
>>> 
>>> VS
>>> this
>>> 
>>>               writer.writeRaw("" +
>>>               "<div class=\"userbackground\">" +
>>> "<div id=\"" + currentPhone.getNumber() + "\" class=\"user\">" +
>>>   "<div class=\"infoline1\">" +
>>>       "<div class=\"name\">" + currentPhone.getName() + " " +
> currentPhone.getNumber() + "</div>" +
>>>       "</div>" +
>>>   "<div class=\"infoline2\">" +
>>>       "<div class=\"voicemail\"><img src=\"email.png\" /></div>" +
>>>       "</div>" +
>>>   "<div class=\"currentcall currentcallplaceholder\">&nbsp;" +
>>>   "</div>" +
>>> "</div>" +
>>> "</div>" +
>>> "<div class=\"spacer\">" +
>>> "</div>");
>>> 
>>> 
>>> 
>>> It's just a copy paste, run over it with some backslashes where I need
> to.
>>> 
>>> Cheers
>>> Chris


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


Re: Readable HTML output

Posted by Lance Java <la...@googlemail.com>.
I always favour .tml for generating markup.

The MarkupWriter gives you complete control but in this case, I think that
.tml would suit your use case better

On Tuesday, 3 April 2012, Lance Java <la...@googlemail.com> wrote:
> This should work:
>
> private static final String NEWLINE =
System.getProperty("line.separator");
> ...
>
> writer.element("div", "class", "userbackground");
> writer.writeRaw(NEWLINE);
> writer.element("div","id",currentPhone.getNumber(), "class","user");
> ...
>
> On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
>> Hi Tap List,
>>
>>
>> I've got production mode set to false and the parts of the html document
that I haven't created come out quite nicely.
>> The parts I have rendered in my component (below) are coming out on one
line.  It's the eye-sore of the document!!
>>
>> How do I fix this?
>>
>>
>> I'm also wondering what the advantages are of using code to generate the
html if I've already built the template in html?
>> This
>>
>>                writer.element("div", "class", "userbackground");
>>                writer.element("div","id",currentPhone.getNumber(),
"class","user");
>>                writer.element("div","class","infoline1");
>>                writer.element("div","class","name");
>>                writer.write(currentPhone.getName() + " " +
currentPhone.getNumber());
>>                writer.end();
>>                writer.end();
>>                writer.element("div","class","infoline2");
>>                writer.element("div","class","voicemail");
>>                writer.element("img","src","email.png");
>>                writer.end();
>>                writer.end();
>>                writer.end();
>>                writer.element("div", "class","currentcall
currentcallplaceholder");
>>                writer.writeRaw("&nbsp;");
>>                writer.end();
>>                writer.end();
>>                writer.end();
>>                writer.element("div","class","spacer");
>>                writer.end();
>>
>> VS
>> this
>>
>>                writer.writeRaw("" +
>>                "<div class=\"userbackground\">" +
>> "<div id=\"" + currentPhone.getNumber() + "\" class=\"user\">" +
>>    "<div class=\"infoline1\">" +
>>        "<div class=\"name\">" + currentPhone.getName() + " " +
currentPhone.getNumber() + "</div>" +
>>        "</div>" +
>>    "<div class=\"infoline2\">" +
>>        "<div class=\"voicemail\"><img src=\"email.png\" /></div>" +
>>        "</div>" +
>>    "<div class=\"currentcall currentcallplaceholder\">&nbsp;" +
>>    "</div>" +
>> "</div>" +
>> "</div>" +
>> "<div class=\"spacer\">" +
>> "</div>");
>>
>>
>>
>> It's just a copy paste, run over it with some backslashes where I need
to.
>>
>> Cheers
>> Chris

Re: Readable HTML output

Posted by Chris Mylonas <ch...@opencsta.org>.
Hmmm....

.tml fragments for the components seems to be the way to go for me in this instance, I'll look further down this track.
I've already knocked up most of the html/css/js from some prototyping the UI last year - I'd rather just keep it XML-like rather than do it in code for this particular task.

Thanks for your suggestion - I saw it in jumpstart and thought it was Geoff's variable out of his utils package and didn't want to go down that alley :)

Chris



On 03/04/2012, at 7:34 PM, Lance Java wrote:

> This should work:
> 
> private static final String NEWLINE = System.getProperty("line.separator");
> ...
> 
> writer.element("div", "class", "userbackground");
> writer.writeRaw(NEWLINE);
> writer.element("div","id",currentPhone.getNumber(), "class","user");
> ...
> 
> On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
>> Hi Tap List,
>> 
>> 
>> I've got production mode set to false and the parts of the html document
> that I haven't created come out quite nicely.
>> The parts I have rendered in my component (below) are coming out on one
> line.  It's the eye-sore of the document!!
>> 
>> How do I fix this?
>> 
>> 
>> I'm also wondering what the advantages are of using code to generate the
> html if I've already built the template in html?
>> This
>> 
>>               writer.element("div", "class", "userbackground");
>>               writer.element("div","id",currentPhone.getNumber(),
> "class","user");
>>               writer.element("div","class","infoline1");
>>               writer.element("div","class","name");
>>               writer.write(currentPhone.getName() + " " +
> currentPhone.getNumber());
>>               writer.end();
>>               writer.end();
>>               writer.element("div","class","infoline2");
>>               writer.element("div","class","voicemail");
>>               writer.element("img","src","email.png");
>>               writer.end();
>>               writer.end();
>>               writer.end();
>>               writer.element("div", "class","currentcall
> currentcallplaceholder");
>>               writer.writeRaw("&nbsp;");
>>               writer.end();
>>               writer.end();
>>               writer.end();
>>               writer.element("div","class","spacer");
>>               writer.end();
>> 
>> VS
>> this
>> 
>>               writer.writeRaw("" +
>>               "<div class=\"userbackground\">" +
>> "<div id=\"" + currentPhone.getNumber() + "\" class=\"user\">" +
>>   "<div class=\"infoline1\">" +
>>       "<div class=\"name\">" + currentPhone.getName() + " " +
> currentPhone.getNumber() + "</div>" +
>>       "</div>" +
>>   "<div class=\"infoline2\">" +
>>       "<div class=\"voicemail\"><img src=\"email.png\" /></div>" +
>>       "</div>" +
>>   "<div class=\"currentcall currentcallplaceholder\">&nbsp;" +
>>   "</div>" +
>> "</div>" +
>> "</div>" +
>> "<div class=\"spacer\">" +
>> "</div>");
>> 
>> 
>> 
>> It's just a copy paste, run over it with some backslashes where I need to.
>> 
>> Cheers
>> Chris


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


Re: Readable HTML output

Posted by Lance Java <la...@googlemail.com>.
This should work:

private static final String NEWLINE = System.getProperty("line.separator");
...

writer.element("div", "class", "userbackground");
writer.writeRaw(NEWLINE);
writer.element("div","id",currentPhone.getNumber(), "class","user");
...

On Tuesday, 3 April 2012, Chris Mylonas <ch...@opencsta.org> wrote:
> Hi Tap List,
>
>
> I've got production mode set to false and the parts of the html document
that I haven't created come out quite nicely.
> The parts I have rendered in my component (below) are coming out on one
line.  It's the eye-sore of the document!!
>
> How do I fix this?
>
>
> I'm also wondering what the advantages are of using code to generate the
html if I've already built the template in html?
> This
>
>                writer.element("div", "class", "userbackground");
>                writer.element("div","id",currentPhone.getNumber(),
"class","user");
>                writer.element("div","class","infoline1");
>                writer.element("div","class","name");
>                writer.write(currentPhone.getName() + " " +
currentPhone.getNumber());
>                writer.end();
>                writer.end();
>                writer.element("div","class","infoline2");
>                writer.element("div","class","voicemail");
>                writer.element("img","src","email.png");
>                writer.end();
>                writer.end();
>                writer.end();
>                writer.element("div", "class","currentcall
currentcallplaceholder");
>                writer.writeRaw("&nbsp;");
>                writer.end();
>                writer.end();
>                writer.end();
>                writer.element("div","class","spacer");
>                writer.end();
>
> VS
> this
>
>                writer.writeRaw("" +
>                "<div class=\"userbackground\">" +
> "<div id=\"" + currentPhone.getNumber() + "\" class=\"user\">" +
>    "<div class=\"infoline1\">" +
>        "<div class=\"name\">" + currentPhone.getName() + " " +
currentPhone.getNumber() + "</div>" +
>        "</div>" +
>    "<div class=\"infoline2\">" +
>        "<div class=\"voicemail\"><img src=\"email.png\" /></div>" +
>        "</div>" +
>    "<div class=\"currentcall currentcallplaceholder\">&nbsp;" +
>    "</div>" +
> "</div>" +
> "</div>" +
> "<div class=\"spacer\">" +
> "</div>");
>
>
>
> It's just a copy paste, run over it with some backslashes where I need to.
>
> Cheers
> Chris