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 How to save inputText value to a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to save inputText value to a file" Watch "How to save inputText value to a file" New topic
Author

How to save inputText value to a file

Daniel Vlad
Greenhorn

Joined: Aug 07, 2011
Posts: 29
as the title of my question states, I need to figure out a way to write the contents of a JSF inputText to a file. I want to build a small UI which will offer the user the posibility to write some math formulas in an easier way(hence the UI) and be able to save them to a .txt (or something similar) file. I have been trying for about 8-10 hours now and the best i've got is:



And the Bean:




I'm pretty sure most of what i did there is wrong so any help would be appreciated, even if it is some directions to posts which treat simmilar issues so i can try and get it from there. I don't want to be spoonfed or anything, the problem is i have never worked with JSF(i started reading about it yesterday) so as i said, even some links to some documentation which could help me(i've been googling like crazy since i started) or guide me a bit will be greatly appreciated.

Thanks,
Daniel
Marcos Silvestri
Ranch Hand

Joined: Dec 06, 2009
Posts: 62

Hello from Brazil, Daniel!

Your code is not as much wrong as you think, you demonstrate to have read the JSF documentation and is correctly wiring the view with its respective bean, as shown in the code.

I've recently achieved what you want as follows:

I first created an array of bytes to store the text I wanted:



One note is that "listaLinhasArquivo" in the code above had all the text I wanted, data gathered with the help of the class StringBuilder, something specific to my scenario.

After creating the array of bytes, I created a file called "marcos.txt" on the server and filled it with the data of my array, as follows:



With that code, I successfully created a file on the server with the content I wanted. In your scenario, try to replace the content of the 'try' block for something similar and check to see if it works for you.

Best regards!


DJ aspirant, Engineering undergraduate, Tokusatsus addicted, fond of English language and Asia's, Buddhist, blogger, etc. I'll need to insert all these attributes in a Java class and manage to create methods for handling my overwhelming life
Daniel Vlad
Greenhorn

Joined: Aug 07, 2011
Posts: 29
Thanks, it worked . Now I'm working on adding the selected values from a couple of "selectOneMenu's" to the file.
Marcos Silvestri
Ranch Hand

Joined: Dec 06, 2009
Posts: 62

That's great man!

In the end, you did not have a JSF specific problem. You're good to go now, up and away

Cheers from Brazil!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to save inputText value to a file