Note that there are some explanatory texts on larger screens.

plurals
  1. POwriting the content of JSF inputText to a file
    text
    copied!<p>I need to figure out a way to write the contents of a JSF inpuText 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:</p> <pre><code>&lt;h:inputText value="#{output.inputContent}" id="inputContent"&gt;&lt;/h:inputText&gt; </code></pre> <p>And the Bean:</p> <pre><code>import com.sun.faces.taglib.html_basic.InputTextTag; import java.awt.event.ActionListener; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.Map; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.servlet.http.HttpServletRequest; @ManagedBean(name = "output") @SessionScoped public class OutputHandler { public String inputContent; public String getinputContent() { return inputContent; } public void setinputContent(String inputContent) { this.inputContent = inputContent; } public void writeStream() { try{ FileOutputStream fos=new FileOutputStream("outputOne.txt"); ObjectOutputStream output=new ObjectOutputStream(fos); output.writeObject(inputContent); } catch(Exception ex){ System.out.println("Exception is: "+ex); } } } </code></pre> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload