File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes print html tag inside xhtml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "print html tag inside xhtml" Watch "print html tag inside xhtml" New topic
Author

print html tag inside xhtml

Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
I have a test.xhtml page using primefaces
I generated html tags in TestBean , and the string content = "<style> .textAreaStyle{width:200px;color:red} </style>"
I need to add the string inside the <head> </head> of html

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Please do not post the same question repeatedly. It will not get answered any faster. We don't get paid for doing this, so it can take a day or more before you get responses.

You can use the "escape" attribute on an outputText element to emit raw HTML from a backing bean.

Having said that, however, I recommend avoiding doing that whereever possible. My experience (not just in JSF) is that it can make a real mess of things.

You can also code raw HTML on the View Definition (xhtml) itself. Usually these days you just code it as straight HTML, but you can also use the "f:verbatim" tag to wrap the HTML if you have problems.


Customer surveys are for companies who didn't pay proper attention to begin with.
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
the forums site was down while i was adding the post , and i was refreshing the page, after that i found the multiple posts for the same questions and did not know how to delete it, please check your inbox, I sent you for this problem , and thank you for your answer, I will try it
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
I used the outputText

and the result was


when I used the <f:verbatim> tag

nothing was found in the html with escape=true or false

it worked fine without using this tag "f:verbatim", would please tell me what is its importance in this case?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Sorry about the issues with the CodeRanch Server. Such things happen, unfortunately.

The "verbatim" tag was designed for JSF version 1, which initially leveraged JSPs. JSPs are compiled into linear Java code, but JSF works by compiling into a 2-dimensional component tree. As a result, loose HTML (and other things) could become lost or misplaced on the resulting output page. The "verbatim" tag bundled such items up in little packages and made sure that they got attached to the component tree in the places where they would be rendered at the right location (more or less). Later JSF versions became better capable of handling such loose text without assistance.

There is no "escape" attribute for the "verbatim" tag, however. The body of the element itself is "escaped", so it would be redundant to say so.
Nesrin aboud
Ranch Hand

Joined: Feb 08, 2010
Posts: 48
Thank you very much
 
Don't get me started about those stupid light bulbs.
 
subject: print html tag inside xhtml