title: Convert inputText to byte[] in JSF
body: <p>I'm writing a web application which has a JSF page with a bean behind it. I am having trouble with it and I think it's because the bean is expecting a byte array for one particular field and it's being provided with a String.</p>
  
  <p>From what I understand, JSF provides some functionality to automatically convert whatever you enter in your inputText fields to the required data type, but I don't think it does this when you want a byte[] ...</p>
  
  <p>Is it simply a matter of writing a customer converter for JSF? Such as something like this:</p>
  
  <pre><code>public class StringToByteArray implements Converter {
  
  ...
  
  public byte[] getAsObject(FacesContext context, UIComponent component, String value) {
      if (StringUtils.isEmpty(value)){ return null;}
  
      byte[] valueAsBytes = new byte[];
  
      valueAsBytes = value.getBytes();
  
      return valueAsBytes; } } 
  </code></pre>