jsf - How to add a String to ValueExpresion programatically -
hi i'm trying add string value value expresion. in xhtml code used things this:
<h:outputtext value="#{mybean.value} %" />
it easy way add '%' symbol outputtext.
how can accomplish programatically.
i'm able add value expresion:
final htmloutputtext outputtext = jsfutils.createcomponent(htmloutputtext.component_type); final valueexpression exp = jsfutils.valueexpresion("gasto.porcentajetotal"); outputtext.setvalueexpresion("value", exp);
but don't know how add '%' symbol
thank you.
it looks problem in utility method, not allow specifying #{
, }
because "automatically" wraps it. if move responsibility caller, should able achieve task.
below canonical way create value expression (copied omnifaces components
):
public static valueexpression createvalueexpression(string expression, class<?> type) { facescontext context = facescontext.getcurrentinstance(); return context.getapplication().getexpressionfactory().createvalueexpression( context.getelcontext(), expression, type); }
this can used as:
valueexpression ve = createvalueexpresion("#{mybean.value} %", string.class);
Comments
Post a Comment