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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -