• Post Reply Bookmark Topic Watch Topic
  • New Topic

Display XML in JSF

 
nreddy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


I am stuck with displaying a xml in JSF. I am reading the XML using BufferedReader and creating a String. When I do a system.out of the string, I get the XML, but when I display the string in JSF using <hutputText../>
I am not getting the XML in proper format and also the XML is showing all hidden fields of the JSF in the broswer.

Could you please help me with this.

This is very urgent.


Thanks, in Advance
nreddy
 
Kumaresh Vidhyasagar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe you need to use facelets to face this kind of problems. Try searching and working on facelets.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nreddy wrote:
I am stuck with displaying a xml in JSF. I am reading the XML using BufferedReader and creating a String. When I do a system.out of the string, I get the XML, but when I display the string in JSF using <hutputText../>
I am not getting the XML in proper format and also the XML is showing all hidden fields of the JSF in the broswer.

Please elaborate "proper format". What happens and what happens not.

This is very urgent.

Please read this: http://faq.javaranch.com/java/EaseUp
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSF is great for what it does, but one of the things that makes it great is that you don't have to use it where it doesn't fit.

Unlike Struts, JSF is geared towards rendering all output via a specific mechanism, which is normally HTML. To get XML out of JSF, you'd have to switch in a JSF renderer for XML.

In truth, I don't know of any XML JSF renderers. However, one reason why is because most of the benefits of JSF are of no use when producing XML. JSF is in large part about maintaining a 2-way conversation with a web form, and XML is normally output-only.

So what I do is output my XML (also PDF's and other non-HTML output) using the traditional mechanisms. Usually I do the XML using JSPX, but I could just as easily write a servlet to do it.

JSF is not a control program that has to handle each and every HTTP request/response. It's a framework that makes it easier to bind JavaBeans and display pages MVC-style. You can mix JSF, servlets, JSPs, Struts, and other mechanisms and it won't have problems. The only difference is that the non-JSF components have to use the basic J2EE mechanisms to locate and store JavaBeans, but the JSF framework can handle the process for you. The beans remain beans, no matter which way you access them. The only restriction is that you can't use code that references the JSF framework in method calls from non-JSF references such as JSPs.

But since the hallmark of a good backing bean is little or no JSF-specific code, that's not as big a problem as it might seem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!