In my project, I take raw text from user and send it to server to do the following
decide what type of each word is
add a
span
around it with a related CSS classkeep the original text structure (i.e
\r\n
means paragraph-end so i can wrap it in ap
)display the result back to the user
using
<h:outputText value="#{wordTypeBean.wordTypeValues}" escape="false" />
In short, I am doing all the html markup at server-side. The return
ed result is something like this (of course as a long String, the result indented for readability):
<span> <!-- from h:outputText -->
<p> <!-- the returned String coming from the Bean starts here -->
<span class="interjection">Hello</span>
<span class="noun">World</span>
!
</p>
<p>
<span class="noun">Life</span>
<span class="verb">is</span>
<span class="adjective">beautiful</span>
.
</p> <!-- the returned String coming from the Bean ends here -->
</span> <!-- from h:outputText -->
But h:outputText
generates span
element around the text. Even though I have seen no problems, so far. But, I have a feeling that it is not right as I read that in html it is illegal to place p
inside span
.
Is there any way to force h:outputText
to generate div
around the text coming from Bean or is there a legal/better way to accomplish this?
h:inputHidden
to capture any edits made on the displayed text and send it (as is) back to my Bean viap:commandButton
usingonmousedown="$('#topF\\:tabview\\:wordsToSubmit').val($('#topF\\:tabview\\:wordTypeEditor').html());"
– Ahmet Feb 11 '16 at 13:23