jsf 2 - how to initialize jsf 2.0 textfield on runtime? -
i initialize textfield @ runtime. example, have primefaces inputtext this:
<p:inputtext value="#{mybean.value}" id="inputtext" /> and bean class:
@postconstruct public void onpageload() { .... .... inputtext.setmaxlength(15); inputtext.setstyle("....."); } is possible jsf 2.0?
you binding component bean:
<p:inputtext binding="#{bean.input}" ... /> with
private inputtext input; // +getter+setter @postconstruct public void init() { input = new inputtext(); input.setmaxlength(15); input.setstyle("background: pink;"); } // ... this not recommended approach. should rather bind individual attributes bean property instead.
<p:inputtext ... maxlength="#{bean.maxlength}" style="#{bean.style}" /> with
private integer maxlength; private string style; @postconstruct public void init() { maxlength = 15; style = "background: pink;"; } // ... even more, if app designed, should have such bean object (why/how else able specify during runtime?). make property of managed bean instead can like:
<p:inputtext ... maxlength="#{bean.attributes.maxlength}" style="#{bean.attributes.style}" />
Comments
Post a Comment