tnaires 10 de nov. de 2008
Olá
Estaria você se referindo à classe ResourceBundle ?
Giulliano 10 de nov. de 2008
na web (jsf) eu uso assim
<f:loadBundle basename=“nomedobundle” var=“bundle” />
sendo que esse “nomedobundle” deve ser um arquivo com o seguinte nome “nomedobundl_pt_BR.properties”
pra português…para outras libguâs basta mudar o fim do arquivo…
Soulslinux 10 de nov. de 2008
Sim é a classe ResourceBundle…
o meu codigo esta assim…
<?xml version='1.0' encoding='ISO-8859-1'?>
<ui:composition template= "/layout/el-layout.xhtml" >
<ui:define name= "corpo" >
<body onload= "focu('form:valNome')" >
<table width= "620" height= "68" border= "0" cellspacing= "0" cellpadding= "0" >
<tr>
<td align= "center" >
<h:outputText id= "descricao" value= "#{bundle.EXPLICACAO}" styleClass= "fontMenuAlt" />
<br>
<br>
<h:outputText id= "instrucao" value= "#{bundle.INSTRUCAO}" styleClass= "fontMenuAlt" />
</br>
</br>
</td>
</tr>
<tr>
<td align= "center" >
<br>
<h:outputText id= "nome" value= "#{bundle.CHAVE}" styleClass= "fontMenuAlt" />
</br>
</td>
</tr>
<tr>
<td align= "center" >
<br>
<h:inputText id= "valNome" value= "#{arquivoChaveFaces.chave}" size= "15" maxlength= "10" styleClass= "formtext" onkeypress= "return Numero(event);" />
</br>
</td>
</tr>
<tr>
<td align= "center" >
<br>
<h:commandButton id= "validar" action= "#{arquivoChaveFaces.pesquisa}" value= "Verificar" styleClass= "botao" />
</br>
</td>
</tr>
<tr>
<td align= "center" >
<br>
<h:outputText id= "message" value= "#{(arquivoChaveFaces.mensagem == '' ? '' : (arquivoChaveFaces.mensagem == 'valido' ? 'bundle.VALIDO' : 'bundle.INVALIDO'))}" styleClass= "#{(arquivoChaveFaces.mensagem == 'valido' ? 'mensagemValida' : 'mensagemInValida')}" />
</br>
</td>
</tr>
</table>
<div id= "panelMessage" ><h:outputText value= "#{bundle.MESSAGE_CAMPO_OBRIGATORIO}::" styleClass= "formlabel" /></div>
</body>
</ui:define>
</ui:composition>
Possuo o arquivo
Message.properties
en - inglês
pt - portugues
pt_br - potuguês (Brasil)
como proceder agora…
Giulliano 10 de nov. de 2008
< ? xml version = '1.0' encoding = 'ISO-8859-1' ? >
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns = "http://www.w3.org/1999/xhtml"
xmlns : ui = "http://java.sun.com/jsf/facelets"
xmlns : f = "http://java.sun.com/jsf/core"
xmlns : h = "http://java.sun.com/jsf/html"
xmlns : t = "http://myfaces.apache.org/tomahawk"
xmlns : a4j = "https://ajax4jsf.dev.java.net/ajax" >
< ui : composition template = "/layout/el-layout.xhtml" >
< ui : define name = "corpo" >
< f : loadBundle basename = "nomedobundle" var = "bundle" />
< body onload = "focu('form:valNome')" >
< table width = "620" height = "68" border = "0" cellspacing = "0" cellpadding = "0" >
< tr >
< td align = "center" >
< h : outputText id = "descricao" value = "#{bundle.EXPLICACAO}" styleClass = "fontMenuAlt" />
< br >
< br >
< h : outputText id = "instrucao" value = "#{bundle.INSTRUCAO}" styleClass = "fontMenuAlt" />
</ br >
</ br >
</ td >
</ tr >
< tr >
< td align = "center" >
< br >
< h : outputText id = "nome" value = "#{bundle.CHAVE}" styleClass = "fontMenuAlt" />
</ br >
</ td >
</ tr >
< tr >
< td align = "center" >
< br >
< h : inputText id = "valNome" value = "#{arquivoChaveFaces.chave}" size = "15" maxlength = "10" styleClass = "formtext" onkeypress = "return Numero(event);" />
</ br >
</ td >
</ tr >
< tr >
< td align = "center" >
< br >
< h : commandButton id = "validar" action = "#{arquivoChaveFaces.pesquisa}" value = "Verificar" styleClass = "botao" />
</ br >
</ td >
</ tr >
< tr >
< td align = "center" >
< br >
< h : outputText id = "message" value = "#{(arquivoChaveFaces.mensagem == '' ? '' : (arquivoChaveFaces.mensagem == 'valido' ? 'bundle.VALIDO' : 'bundle.INVALIDO'))}" styleClass = "#{(arquivoChaveFaces.mensagem == 'valido' ? 'mensagemValida' : 'mensagemInValida')}" />
</ br >
</ td >
</ tr >
</ table >
< div id = "panelMessage" >< h : outputText value = "#{bundle.MESSAGE_CAMPO_OBRIGATORIO}::" styleClass = "formlabel" /></ div >
</ body >
</ ui : define >
</ ui : composition >
</ html >
Giulliano 10 de nov. de 2008
vc pode criar um cara seu…tipo meuBundle.properties e chamar de lá…
se vc quer usar o defaul do jsf acho q é só criar o seu arquivo na pasta src q ele acha sozinho…
Soulslinux 10 de nov. de 2008
Caro amigo muito obrigado pela dica porem esta dando o seguinte erro…
<f:loadBundle basename=“MessagesResources”> Can’t find bundle for base name MessagesResources, locale pt_BR
vc pode me ajudar…
desde já agradeço.
Soulslinux 10 de nov. de 2008
Caro amigo consegui resolver graças a sua ajuda muito obrigado o meu codigo na parte do bundle ficou assim.
<f:loadBundle basename=“br.com.ass.resources.MessagesResources” var=“bundle” />
ou seja eu tinha que colocar o endereço todo rsrsrsrsr
Show de bola…
Muito obrigado a todos…fiquem com DEUS e ate a proxima duvida hehehehe