4
I own a List:
private List<Geracao> lista;
This list will be filled with data from a database:
lista = dao.findAll();
The method findAll()
:
@SuppressWarnings("unchecked")
@Override
public List<Geracao> findAll() throws Exception {
log.info("Encontrando todas as Gerações");
return em.createQuery("from Geracao").getResultList();
}
These data after being completed in lista
will go to the screen (JSF). I would like to make a formatting in the text before going to the screen, example: I have an attribute called nome
in class Geracao
. How can I take the amount that will come from the bank, edit and then play to the lista
?
My ultimate goal is that in the text that will come from the database before going to the screen, make a check if there is a word x. If there is x in the text, x will be formatted, example as in bold before going to the screen. Ex:
texto = texto.replace(palavra, "<b>"+palavra+"</b>");
What kind of formatting? Are you looking to apply some business rule (for example, putting the last name in front of the name)? Or you are wanting to do something purely cosmetic (for example, limit the quandity of characters). The answer is important because it defines the best component (business class, bean Managed, etc.) is most suitable for handling
– Anthony Accioly
@Anthonyaccioly edited the question with the information.
– Roknauta
Man, it particularly seems to me that what you want to do should be done in the view, so I would do in direct JSF:
<h:outputText value="#{fn:replace('palavra', ')', '<b>palavra</b>')}" />
– Sorack
@Sorack the problem is that it is not the same word, and depending on the word will receive different formatting, in my case I will do a check along with a list coming from Enum.
– Roknauta
Oh got it @Douglas. The best thing seems to me is to do it in the bean, but I think Giovane’s answer should fall like a glove to you
– Sorack
Related questions: http://answall.com/q/165766/132 and http://answall.com/q/165762/132
– Victor Stafusa