f: convert inside h: output text does not work

0

I have this code, I'm pulling from a string of type String and drawing dynamically, in view I want it to be shown with a dollar sign but I can not make it happen.

Is it because I'm using a string ?

<h:outputText value="#{o.cadenaString}" style="color: #{o.colorCadena};">       
<f:convertNumber type="currency" currencyCode="USD" currencySymbol="$" locale="en_US" />
</h:outputText>
    
asked by IvttAN 28.06.2017 в 23:06
source

1 answer

0

Indeed, you can not assign the symbol "$" (dollar) for the same, to avoid generating an attribute in the bean, in the methods of the class create one that converts the String to double, and in the Value it you use:

// En la clase...
public double getStringToDouble(){
    double amount = Double.parseDouble(this.cadenaString);  
    return amount;          
}

// En el xhtml
<h:outputText value="#{o.getStringToDouble()}" style="color: #{o.colorCadena};"> 

I hope your answer will help, greetings.

    
answered by 28.06.2017 / 23:15
source