1

A quick question, which is better performance and memory wise:

<t:outputText escape="false" value='<tr><td>'/>

or just a straight

<tr><td>

I ask because I haven't found any documentation regarding which is best performance wise and for general maintainability of the JSFs. I believe the latter results in more maintainable code (you can identify mismatched tags easier), but I'm unaware if there are reasons someone would want to explicitly output html elements using outputText.

jhutton
  • 13
  • 1
  • 3

2 Answers2

0

I am afraid the first example won't work at all:

  1. outputText is usually generated as <span> tag with the text inside so it will not do what you want EDIT: See comments
  2. It is possible that it will escape the < and > characters so it will not create html tags tr and td at all, just the text: &lt;tr&gt;&lt;td&gt; (see escape attribute)

The second is generally not a good idea since the tag is intended to output text to the page and not html tags.

Jan Zyka
  • 17,460
  • 16
  • 70
  • 118
  • Statement 1 is not true per se. It will only do that when there are attributes which have to end up in the HTML, e.g. `id`, `styleClass`, etc. – BalusC Mar 22 '11 at 21:19
0

Just put HTML straight in the view. Not only have the components indeed an extra memory/resource overhead which you'd like to minimize, but it's also much better readable.

The example as you posted will by the way also not parse when you're using Facelets instead of JSP as view technology.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I actually received the code that this is used from a non-existent group in my company. I just didn't know if there was any performance implications that would have led the team to develop it this way. – jhutton Mar 23 '11 at 20:58
  • In ancient JSF 1.0 and 1.1 it was not possible to inline HTML directly in a JSF page. It's maybe related, but still then, the proper approach would be using `` for this. See also http://stackoverflow.com/questions/3623911/what-are-the-main-disadvantages-of-java-server-faces-2-0 for a good starting point to dive into the history around JSF specific oddities. – BalusC Mar 23 '11 at 20:59