Pessoal com resolvo essa situação, gostaria de dentro de um alert uma mensagem do message bundles do jsf.
alert("#{msgs.mensagem}"); assim não da certo.
Pessoal com resolvo essa situação, gostaria de dentro de um alert uma mensagem do message bundles do jsf.
alert("#{msgs.mensagem}"); assim não da certo.
Na verdade isso deveria funcionar. Posta o código da sua view é a parte do faces-config.xml q declara esse messagebundle. Informe tb a posição dele dentro da estrutura de diretórios do seu projeto.
as mensagens estão funcionando corretamente, eu só que usa-las dentro do javascript também. Estou fazendo um sistema para trabalhar com duas linguas nos labels o que ja esta certo, somente dentro do javascript que não
Diz ai, vc tem esse “alert” dentro de um arquivo .js ou do xhtml?
esse é o código
<%@include file=“include/header.jsp” %>
<f:view>
<h:form id=“userForm”>
<table>
<tr>
<td colspan="2"><h:outputText value="#{msgs.includeUser}"/></td>
</tr>
<tr>
<td colspan="2"><h:inputHidden value="#{userLg.user.use_id}"/> </td>
</tr>
<tr>
<td><h:outputText value="#{msgs.name}"/></td>
<td><h:inputText value="#{userLg.user.use_name}" size="64" maxlength="64" id="name" required="true" label="#{msgs.name}"/><h:message for="name"/></td>
</tr>
<tr>
<td><h:outputText value="#{msgs.login}"/></td>
<td><h:inputText value="#{userLg.user.use_login}" size="16" maxlength="16" id="login" required="true" label="#{msgs.login}"/><h:message for="login"/></td>
</tr>
<tr>
<td><h:outputText value="#{msgs.password}"/></td>
<td><h:inputSecret value="#{userLg.user.use_password}" size="16" maxlength="16" id="password" onblur="checkPassword(this.form);" required="true" label="#{msgs.password}"/><h:message for="password"/></td>
</tr>
<tr>
<td><h:outputText value="#{msgs.passwordConfirm}"/></td>
<td><h:inputSecret value="" size="16" maxlength="16" id="passwordConfirm" onblur="checkPassword(this.form);" required="true" label="#{msgs.passwordConfirm}"/><h:message for="passwordConfirm"/></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2">
<h:commandButton value="#{msgs.send}" action="#{userLg.save}"/>
<h:commandButton value="#{msgs.back}" action="#{userLg.seaUser}" immediate="true"/>
</td>
</tr>
</table>
</h:form>
<script type="text/javascript">
function checkPassword(form){
var password = form["userForm:password"].value;
var passwordConfirm = form["userForm:passwordConfirm"].value;
if(passwordConfirm != null && passwordConfirm != "" && password != null && password != "" && passwordConfirm != password){
alert("erro");
form["userForm:password"].value = "";
form["userForm:passwordConfirm"].value = "";
}
}
</script>
</f:view>
<%@include file=“include/footer.jsp” %>
Kra, eu não consegui ver o “alert(”#{msgs.mensagem}")" q vc falou no primeiro post. E, por favor, coloque o seu código entre tags [code] pq ler código desse jeito é barra!
Cara, muito obirgado pela atenção, mas consegui resolver esse problema.
Segue abaixo o código para quem tiver a mesma duvida.
[code]<%@include file=“include/header.jsp” %>
<f:view>
<h:form id=“userForm”>
<table>
<tr>
<td colspan="2"><h:outputText value="#{msgs.includeUser}"/></td>
</tr>
<tr>
<td colspan="2"><h:inputHidden value="#{userLg.user.use_id}"/> </td>
</tr>
<tr>
<td><h:outputText value="#{msgs.name}"/></td>
<td><h:inputText value="#{userLg.user.use_name}" size="64" maxlength="64" id="name" required="true" label="#{msgs.name}"/><h:message for="name"/></td>
</tr>
<tr>
<td><h:outputText value="#{msgs.login}"/></td>
<td><h:inputText value="#{userLg.user.use_login}" size="16" maxlength="16" id="login" required="true" label="#{msgs.login}"/><h:message for="login"/></td>
</tr>
<tr>
<td><h:outputText value="#{msgs.password}"/></td>
<td><h:inputSecret value="#{userLg.user.use_password}" size="16" maxlength="16" id="password" onblur="checkPassword(this.form, '#{msgs.invalidPasswordConfirm}');" required="true" label="#{msgs.password}"/><h:message for="password"/></td>
</tr>
<tr>
<td><h:outputText value="#{msgs.passwordConfirm}"/></td>
<td><h:inputSecret value="" size="16" maxlength="16" id="passwordConfirm" onblur="checkPassword(this.form, '#{msgs.invalidPasswordConfirm}');" required="true" label="#{msgs.passwordConfirm}"/><h:message for="passwordConfirm"/></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2">
<h:commandButton value="#{msgs.send}" action="#{userLg.save}"/>
<h:commandButton value="#{msgs.back}" action="#{userLg.seaUser}" immediate="true"/>
</td>
</tr>
</table>
</h:form>
<script type="text/javascript">
function checkPassword(form, message){
var password = form["userForm:password"].value;
var passwordConfirm = form["userForm:passwordConfirm"].value;
if(passwordConfirm != null && passwordConfirm != "" && password != null && password != "" && passwordConfirm != password){
alert(message);
form["userForm:password"].value = "";
form["userForm:passwordConfirm"].value = "";
}
}
</script>
</f:view>
<%@include file=“include/footer.jsp” %>[/code]