• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to download primefaces tree in csv file?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to download primefaces tree in csv file?
 
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Vivek!

What do you mean "download primefaces tree in csv file"? What would that benefit you? For that matter, what would you expect to see when you attempt to download a tree structure into a table format?
 
Vivek maini
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I want to export Tree structure(primefaces) into csv file
 
Tim Holloway
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That doesn't make any more sense now than when you first said it.
 
Vivek maini
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a bean class in which i have written the code for a tree (primefaces tree <p:tree> ) and now i want to save/download that tree data into a csv file on my pc.
Hope now you get my question.
 
Tim Holloway
Saloon Keeper
Posts: 27807
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah. When you said "Primefaces tree", I thought you meant the JSF component tree for a Primefaces webpage. You're actually asking about a Primefaces control.

You can't download controls. They are graphical and they are ephemeral. What you want to download is the data behind the control. Its Model. Primefaces isn't designed to simply cough up the raw model data to an end user (it would probably be a security issue, if nothing else). But you can implement code to download the model data itself and for that, not only do you not need Primefaces, you don't even need JSF. You can do that with a simple JSP or servlet. And would be better doing so, since you want data and JSF is intended to return HTML.

The first requirement is that you make the model object for the control be in Session scope, since any lower scope would be destroyed when you dispatched the page that downloads your data and since you're going to be referencing the data from a different view, you need a common source. JSF session scope and J2EE session scope are the same thing (just different ways of constructing beans), so session scope will do it.

You can output a CSV from the model by simply prototyping the CSV lines on a JSP template (set content-type to text/csv or something like that). For example:


There is a catch, however. CSV files are expected to contain a homogeneous set of rows. Trees can contain model elements in all sorts of different formats. For that reason, it's common to output tree-structured data in JSON, YAML or XML formats.
 
Something must be done about this. Let's start by reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic