-
1. Re: rich:NotifyMessages in Richfaces 4.5.8
michpetrov Sep 3, 2015 10:42 AM (in response to madmassa)Can you show the code you're working with?
-
2. Re: rich:NotifyMessages in Richfaces 4.5.8
madmassa Sep 3, 2015 11:42 AM (in response to michpetrov)<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
</h:head>
<ui:composition template="/WEB-INF/template/template.xhtml">
<ui:define name="content">
<h:form>
<div class="container">
<div class="row">
<div class="col-md-2">
<h:outputLabel for="nomeBusca">Nome</h:outputLabel>
</div>
<div class="col-md-6">
<h:inputText id="nomeBusca" value="#{contatoMB.contatomv.contatoBusca.nome}"></h:inputText>
</div>
</div>
<div class="row">
<div class="col-md-2">
<h:outputLabel for="departamentoBusca">Departamento</h:outputLabel>
</div>
<div class="col-md-6">
<h:selectOneMenu id="departamentoBusca" value="#{contatoMB.contatomv.contatoBusca.id}">
<f:selectItem itemValue="0" itemLabel="Selecione..."></f:selectItem>
<f:selectItems value="#{contatoMB.contatomv.departamentos}" var="departamento" itemLabel="#{departamento.nome}" itemValue="#{departamento.id}"/>
</h:selectOneMenu>
</div>
</div>
<div class="row">
<div class="col-md-2">
<h:commandButton action="#{contatoMB.contatomv.buscaContato()}" value="Buscar"></h:commandButton>
</div>
</div>
<div style="margin-top: 20px">
<rich:dataTable value="#{contatoMB.contatomv.contatos}" var="contato" styleClass="table table-striped">
<rich:column>
<f:facet name="header">
<h:outputText value="Nome"></h:outputText>
</f:facet>
<h:outputText value="#{contato.nome}"></h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Departamento"></h:outputText>
</f:facet>
<h:outputText value="#{contato.departamento.nome}"></h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Telefone"></h:outputText>
</f:facet>
<h:outputText value="#{contato.telefone}"></h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Ramal"></h:outputText>
</f:facet>
<h:outputText value="#{contato.ramal}"></h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="e-mail"></h:outputText>
</f:facet>
<h:outputText value="#{contato.email}"></h:outputText>
</rich:column>
</rich:dataTable>
</div>
</div>
</h:form>
<rich:notifyMessage showDetail="true" showSummary="true" stayTime="30000"></rich:notifyMessage>
</ui:define>
</ui:composition>
</html>
buscar.xhtml
-
3. Re: rich:NotifyMessages in Richfaces 4.5.8
madmassa Sep 3, 2015 11:43 AM (in response to michpetrov)package br.gov.sp.camaraguarulhos.mv.contatos;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import br.gov.sp.camaraguarulhos.dao.departamentos.DepartamentosDAO;
import br.gov.sp.camaraguarulhos.exceptions.ModelViewException;
import br.gov.sp.camaraguarulhos.model.contatos.Contato;
import br.gov.sp.camaraguarulhos.model.departamento.Departamento;
import br.gov.sp.camaraguarulhos.service.contatos.ContatoService;
public class ContatoMV {
private Contato contatoBusca = new Contato();
private List<Contato> contatos = new ArrayList<Contato>();
private List<Departamento> departamentos = listaDepartamentos();
public Contato getContatoBusca() {
return contatoBusca;
}
public void setContatoBusca(Contato contatoBusca) {
this.contatoBusca = contatoBusca;
}
public List<Contato> getContatos() {
return contatos;
}
public void setContatos(List<Contato> contatos) {
this.contatos = contatos;
}
public List<Departamento> getDepartamentos() {
return departamentos;
}
public void setDepartamentos(List<Departamento> departamentos) {
this.departamentos = departamentos;
}
public void buscaContato() throws ModelViewException{
ContatoService service = new ContatoService();
Integer id;
String nome;
if(contatoBusca.getId()!=null)
id = contatoBusca.getId();
else
id=null;
nome=contatoBusca.getNome();
if((nome.equals(""))&&((id==0)||(id==null))){
FacesMessage message = new FacesMessage();
message.setSummary("Falha ao consultar");
message.setDetail("Digitar campos de pesquisa");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
FacesContext.getCurrentInstance().addMessage("message",message);
//throw new ModelViewException("Digitar campos de pesquisa");
} else {
contatos = service.buscaContatos(id, nome);
}
}
public List<Departamento> listaDepartamentos(){
DepartamentosDAO dao = new DepartamentosDAO();
return dao.getDepartamentos();
}
}
-
4. Re: rich:NotifyMessages in Richfaces 4.5.8
madmassa Sep 3, 2015 11:44 AM (in response to michpetrov)<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Agenda Telefonica</title>
</f:facet>
<f:facet name="middle">
<h:outputStylesheet name="bootstrap/css/bootstrap.css" />
<h:outputStylesheet name="css/main.css" />
<h:outputScript name="bootstrap/js/bootstrap.js" />
<h:outputScript name="js/jquery.js" />
</f:facet>
<f:facet name="last">
<h:outputStylesheet name="css/font-awesome.css" />
</f:facet>
</h:head>
<h:body>
<ui:include src="header.xhtml" />
<ui:insert name="content" />
</h:body>
</html>
template.xhtml
-
5. Re: rich:NotifyMessages in Richfaces 4.5.8
michpetrov Sep 3, 2015 12:10 PM (in response to madmassa)Nwxt time include only the important bits. I see nothing wrong with the code, have you checked if the method is getting executed? Any errors in the browser console? Check the generated code if the message is there.
-
6. Re: rich:NotifyMessages in Richfaces 4.5.8
madmassa Sep 3, 2015 1:13 PM (in response to michpetrov)Yes, i have checked, and my code is getting executed. The RF javascript calls are being executed too, i have noticed that the console on chrome is displaying some javascript error messages :
Uncaught ReferenceError: RichFaces is not defined(anonymous function) @ jquery.pnotify.js:748
Uncaught TypeError: Cannot read property 'defaults' of undefined @ notifyStack.js:26
The generated html is:
<html xmlns="http://www.w3.org/1999/xhtml"><head id="j_idt2"><link type="text/css" rel="stylesheet" href="/Agenda_Telefonica/javax.faces.resource/bootstrap/css/bootstrap.css.jsf" /><link type="text/css" rel="stylesheet" href="/Agenda_Telefonica/javax.faces.resource/css/main.css.jsf" /><link type="text/css" rel="stylesheet" href="/Agenda_Telefonica/javax.faces.resource/css/theme.css.jsf?ln=bsf" /><link type="text/css" rel="stylesheet" href="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/datatable.ecss?db=eAG7ELb5HwAGqgLY" /><link type="text/css" rel="stylesheet" href="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/notify.ecss?db=eAG7ELb5HwAGqgLY" /><link type="text/css" rel="stylesheet" href="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/skinning.ecss?db=eAG7ELb5HwAGqgLY" /><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/jquery.js"></script><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/jquery.pnotify.js"></script><script type="text/javascript" src="/Agenda_Telefonica/javax.faces.resource/jsf.js.jsf?ln=javax.faces"></script><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/richfaces.js"></script><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/richfaces-base-component.js"></script><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/datatable.js"></script><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/richfaces-event.js"></script><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/notifyMessage.js"></script><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/notify.js"></script><script type="text/javascript" src="/Agenda_Telefonica/org.richfaces.resources/javax.faces.resource/org.richfaces/notifyStack.js"></script><!--[if lt IE 9]><script src="/Agenda_Telefonica/javax.faces.resource/js/html5shiv.js.jsf?ln=bsf"></script><script src="/Agenda_Telefonica/javax.faces.resource/js/respond.js.jsf?ln=bsf"></script><![endif]--><link type="text/css" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" /></head>
....
-
7. Re: rich:NotifyMessages in Richfaces 4.5.8
michpetrov Sep 4, 2015 5:24 AM (in response to madmassa)Looks like a problem with resource ordering. Can you try it without the facets in h:head?