This content has been marked as final.
Show 4 replies
-
1. Re: How to display the byte array as string in JSF?
michpetrov Apr 10, 2013 4:15 AM (in response to newuser001)You'll need to convert it, either in the backing bean or by creating a custom converter.
-
2. Re: How to display the byte array as string in JSF?
newuser001 Apr 10, 2013 4:27 AM (in response to michpetrov)hi Michal,
I need to convert it by custom converter.
-
3. Re: How to display the byte array as string in JSF?
michpetrov Apr 10, 2013 4:45 AM (in response to newuser001)Okay, it would look like this:
import javax.enterprise.context.RequestScoped; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; import javax.inject.Named; @Named @RequestScoped @FacesConverter("myConverter") public class MyConverter implements Converter { // textarea -> bean @Override public Object getAsObject(FacesContext context, UIComponent component, String value) { // do conversion… } // bean -> textarea @Override public String getAsString(FacesContext context, UIComponent component, Object value) { // do conversion… } }
You can ignore the FacesContext and the UIComponent, just take the value and convert it to what you need.
Then on your page you can just do this:
<h:inputTextarea value="#{bean.byteArray}" converter="#{myConverter}" />
-
4. Re: How to display the byte array as string in JSF?
newuser001 Apr 10, 2013 5:55 AM (in response to michpetrov)hi Michal,
Thanks a lot. its working well