11/10/2008

git-svn-id: https://svn.coded.pt/svn/SIPRP@775 bb69d46d-e84e-40c8-a05a-06db0d633741
lxbfYeaa
L Luís = 17 years ago
parent 67bac141fe
commit c0edf313c7

@ -2,10 +2,13 @@
<Scene Scope="Project" version="2"> <Scene Scope="Project" version="2">
<Scope Scope="Faces Configuration Only"/> <Scope Scope="Faces Configuration Only"/>
<Scope Scope="Project"> <Scope Scope="Project">
<Node id="ListaPlanos.jsp" x="127" y="211" zoom="true"/> <Node id="ListaPlanos.jsp" x="349" y="128" zoom="false"/>
<Node id="Erro.jsp" x="150" y="150" zoom="true"/> <Node id="Erro.jsp" x="257" y="64" zoom="true"/>
<Node id="EditarPlano.jsp" x="400" y="150" zoom="true"/> <Node id="Footer.jsp" x="650" y="150" zoom="true"/>
<Node id="Login.jsp" x="161" y="299" zoom="false"/> <Node id="EditarPlano.jsp" x="609" y="83" zoom="false"/>
<Node id="Dummy.jsp" x="867" y="46" zoom="true"/>
<Node id="ViewPlano.jsp" x="400" y="150" zoom="true"/>
<Node id="Login.jsp" x="348" y="307" zoom="false"/>
</Scope> </Scope>
<Scope Scope="All Faces Configurations"/> <Scope Scope="All Faces Configurations"/>
</Scene> </Scene>

@ -1,8 +1,8 @@
build.xml.data.CRC32=0b61db7f build.xml.data.CRC32=a8b7045a
build.xml.script.CRC32=fa3993b7 build.xml.script.CRC32=fa3993b7
build.xml.stylesheet.CRC32=cfd7ba16 build.xml.stylesheet.CRC32=cfd7ba16
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=0b61db7f nbproject/build-impl.xml.data.CRC32=a8b7045a
nbproject/build-impl.xml.script.CRC32=64f15e59 nbproject/build-impl.xml.script.CRC32=64f15e59
nbproject/build-impl.xml.stylesheet.CRC32=8926891b nbproject/build-impl.xml.stylesheet.CRC32=8926891b

@ -2,7 +2,7 @@
<project xmlns="http://www.netbeans.org/ns/project/1"> <project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.project</type> <type>org.netbeans.modules.web.project</type>
<configuration> <configuration>
<creator-data xmlns="http://www.sun.com/creator/ns" jsf.current.theme="woodstock-theme-default" jsf.pagebean.package="planosactuacao" jsf.project.libraries.dir="lib" jsf.project.version="4.0" jsf.startPage="Login.jsp"/> <creator-data xmlns="http://www.sun.com/creator/ns" jsf.current.theme="woodstock-theme-default" jsf.pagebean.package="planosactuacao" jsf.project.libraries.dir="lib" jsf.project.version="4.0" jsf.startPage="Dummy.jsp"/>
<data xmlns="http://www.netbeans.org/ns/web-project/3"> <data xmlns="http://www.netbeans.org/ns/web-project/3">
<name>PlanosActuacao</name> <name>PlanosActuacao</name>
<minimum-ant-version>1.6</minimum-ant-version> <minimum-ant-version>1.6</minimum-ant-version>

@ -36,6 +36,13 @@ public class Db {
return connection; return connection;
} }
public Connection getConnection()
{
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
connection = (Connection) session.getAttribute("connection");
return connection;
}
public Statement createStatement() public Statement createStatement()
{ {
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false); HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false);

@ -5,14 +5,18 @@
package db.entidades; package db.entidades;
import java.util.Vector;
/** /**
* *
* @author lluis * @author lluis
*/ */
public class Medida { public class Medida {
private Integer id; private Integer id;
private Integer risco_id;
private String descricao; private String descricao;
private String activa; private String activa;
private Vector<PostoTrabalho> postos;
public Integer getId() { public Integer getId() {
return id; return id;
@ -37,4 +41,20 @@ public class Medida {
public void setActiva(String activa) { public void setActiva(String activa) {
this.activa = activa; this.activa = activa;
} }
public Integer getRisco_id() {
return risco_id;
}
public void setRisco_id(Integer risco_id) {
this.risco_id = risco_id;
}
public Vector<PostoTrabalho> getPostos() {
return postos;
}
public void setPostos(Vector<PostoTrabalho> postos) {
this.postos = postos;
}
} }

@ -5,6 +5,9 @@
package db.entidades; package db.entidades;
import java.sql.Date;
import java.util.Vector;
/** /**
* *
* @author lluis * @author lluis
@ -13,6 +16,16 @@ public class PlanoActuacao {
private Integer id; private Integer id;
private Integer estabelecimento_id; private Integer estabelecimento_id;
private Integer estado; private Integer estado;
private String descricao;
private Vector<Risco> riscos;
//
private Date data_visita;
private Integer tecnico_hs_id;
private Integer fase;
private String fase_nome;
private String tecnico_hs_nome;
private String loja_nome;
public Integer getId() { public Integer getId() {
return id; return id;
@ -37,4 +50,68 @@ public class PlanoActuacao {
public void setEstado(Integer estado) { public void setEstado(Integer estado) {
this.estado = estado; this.estado = estado;
} }
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public Vector<Risco> getRiscos() {
return riscos;
}
public void setRiscos(Vector<Risco> riscos) {
this.riscos = riscos;
}
public Date getData_visita() {
return data_visita;
}
public void setData_visita(Date data_visita) {
this.data_visita = data_visita;
}
public Integer getTecnico_hs_id() {
return tecnico_hs_id;
}
public void setTecnico_hs_id(Integer tecnico_hs_id) {
this.tecnico_hs_id = tecnico_hs_id;
}
public Integer getFase() {
return fase;
}
public void setFase(Integer fase) {
this.fase = fase;
}
public String getFase_nome() {
return fase_nome;
}
public void setFase_nome(String fase_nome) {
this.fase_nome = fase_nome;
}
public String getTecnico_hs_nome() {
return tecnico_hs_nome;
}
public void setTecnico_hs_nome(String tecnico_hs_nome) {
this.tecnico_hs_nome = tecnico_hs_nome;
}
public String getLoja_nome() {
return loja_nome;
}
public void setLoja_nome(String loja_nome) {
this.loja_nome = loja_nome;
}
} }

@ -12,6 +12,7 @@ package db.entidades;
public class PostoTrabalho { public class PostoTrabalho {
private Integer id; private Integer id;
private Integer risco_id; private Integer risco_id;
private Integer medida_id;
private String descricao; private String descricao;
private String activo; private String activo;
@ -46,4 +47,12 @@ public class PostoTrabalho {
public void setRisco_id(Integer risco_id) { public void setRisco_id(Integer risco_id) {
this.risco_id = risco_id; this.risco_id = risco_id;
} }
public Integer getMedida_id() {
return medida_id;
}
public void setMedida_id(Integer medida_id) {
this.medida_id = medida_id;
}
} }

@ -5,6 +5,8 @@
package db.entidades; package db.entidades;
import java.util.Vector;
/** /**
* *
* @author lluis * @author lluis
@ -14,6 +16,9 @@ public class Risco {
private Integer plano_id; private Integer plano_id;
private String descricao; private String descricao;
private String activo; private String activo;
private Integer valor;
private Vector<Medida> medidas;
public Integer getId() { public Integer getId() {
return id; return id;
@ -46,4 +51,20 @@ public class Risco {
public void setPlano_id(Integer plano_id) { public void setPlano_id(Integer plano_id) {
this.plano_id = plano_id; this.plano_id = plano_id;
} }
public Integer getValor() {
return valor;
}
public void setValor(Integer valor) {
this.valor = valor;
}
public Vector<Medida> getMedidas() {
return medidas;
}
public void setMedidas(Vector<Medida> medidas) {
this.medidas = medidas;
}
} }

@ -11,7 +11,7 @@ import java.util.Date;
* *
* @author lluis * @author lluis
*/ */
public class User { public class Utilizador {
private Integer id; private Integer id;
private String login; private String login;
private String password; private String password;

@ -15,7 +15,23 @@ import java.sql.Statement;
*/ */
public class GenericDataProvider { public class GenericDataProvider {
public Integer getMaxTableId(String table) public void checkConnection()
{
Db db = new Db();
if(db.getConnection() == null)
{
try
{
db.connect();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
protected Integer getMaxTableId(String table)
{ {
Statement st = createStatement(); Statement st = createStatement();
String id = table + ".id"; String id = table + ".id";

@ -9,7 +9,7 @@ import db.entidades.Medida;
import db.entidades.PlanoActuacao; import db.entidades.PlanoActuacao;
import db.entidades.PostoTrabalho; import db.entidades.PostoTrabalho;
import db.entidades.Risco; import db.entidades.Risco;
import db.entidades.User; import db.entidades.Utilizador;
import global.Global; import global.Global;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Statement; import java.sql.Statement;
@ -48,7 +48,7 @@ public class PlanosDataProvider extends GenericDataProvider{
st.execute(sql); st.execute(sql);
} }
public ArrayList getPlanosActivos(User u) throws Exception public ArrayList getPlanosActivos(Utilizador u) throws Exception
{ {
int userType = u.getTipo().intValue(); int userType = u.getTipo().intValue();
Statement st = createStatement(); Statement st = createStatement();
@ -79,7 +79,7 @@ public class PlanosDataProvider extends GenericDataProvider{
return list; return list;
} }
public ArrayList getPlanosConcluidos(User u) throws Exception public ArrayList getPlanosConcluidos(Utilizador u) throws Exception
{ {
Statement st = createStatement(); Statement st = createStatement();
String sql = "select * from planos_actuacao where estado = 6"; String sql = "select * from planos_actuacao where estado = 6";

@ -0,0 +1,46 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package db.providers;
import db.*;
import db.entidades.Utilizador;
import java.sql.ResultSet;
import java.sql.Statement;
/**
*
* @author lluis
*/
public class UtilizadoresDataProvider extends GenericDataProvider{
public Utilizador getUtilizador(Integer id) throws Exception
{
Utilizador u = new Utilizador();
Statement st = createStatement();
String sql = "SELECT * FROM utilizadores WHERE id = " + id;
ResultSet rs = st.executeQuery(sql);
rs.first();
u.setId(new Integer(rs.getInt("id")));
u.setLogin(rs.getString("login"));
u.setPassword(rs.getString("password"));
u.setData_password(rs.getDate("data_password"));
u.setEmail(rs.getString("email"));
u.setEmpresa_id(new Integer(rs.getInt("empresa_id")));
u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id")));
u.setAdministrador(rs.getString("administrador"));
u.setTipo(new Integer(rs.getInt("tipo")));
u.setNumero_cedula(rs.getString("numero_cedula"));
u.setCap(rs.getString("cap"));
u.setNome(rs.getString("nome"));
u.setMedico_id(new Integer(rs.getInt("medico_id")));
u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id")));
u.setActivo(rs.getString("activo"));
u.setResponsavel_loja(rs.getString("responsavel_loja"));
u.setGestor_geral(rs.getString("gestor_geral"));
u.setApagado(rs.getString("apagado"));
return u;
}
}

@ -13,16 +13,31 @@ public class Global {
//tipos utilizadores //tipos utilizadores
public static final int RESPONSAVEL_SEGURANCA = 1; public static final int RESPONSAVEL_SEGURANCA = 1;
public static final int RH = 2;
public static final int TECNICO_HS = 3; public static final int TECNICO_HS = 3;
public static final int GESTOR = 6;
public static final int DIRECTOR_GERAL_RH = 7;
public static final int DIRECTOR_SIPRP = 8;
public static final int DIRECTOR_LOJA = 9; public static final int DIRECTOR_LOJA = 9;
public static final int DIRECTOR_NACIONAL_SEGURANCA = 10; public static final int DIRECTOR_NACIONAL_SEGURANCA = 10;
//Estados do plano //Fases do plano
public static final int ESTADO_CRIACAO_TSHS = 1; public static final int FASE_SIPRP_EMISSAO = 1;
public static final int ESTADO_EDICAO_SEGURANCA = 2; public static final int FASE_SEGURANCA_PREENCHIMENTO = 2;
public static final int ESTADO_VALIDACAO_DIR_LOJA = 3; public static final int FASE_DIR_LOJA_VALIDACAO = 3;
public static final int ESTADO_VALIDACAO_DNS = 4; public static final int FASE_DNS_PARECER = 4;
public static final int ESTADO_VERIFICACAO_TSHS = 5; public static final int FASE_SIPRP_CONCLUSAO = 5;
public static final int ESTADO_CONCLUIDO = 6; public static final int FASE_CONCLUIDO = 6;
//Fases do plano - texto
public static final String FASE_SIPRP_EMISSAO_TXT = "SIPRP(Emissão)";
public static final String FASE_SEGURANCA_PREENCHIMENTO_TXT = "Segurança Auchan(Preenchimento)";
public static final String FASE_DIR_LOJA_VALIDACAO_TXT = "Director de loja(Validação)";
public static final String FASE_DNS_PARECER_TXT = "DNS(Parecer)";
public static final String FASE_SIPRP_CONCLUSAO_TXT = "SIPRP(Verificação/Conclusão)";
public static final String[] FASES_TEXTO = new String[]{"SIPRP(Emissão)", "Segurança Auchan(Preenchimento)", "Director de loja(Validação)", "DNS(Parecer)", "SIPRP(Verificação/Conclusão)", "Concluído"};
public static final String ANALISE_ACIDENTES_URL = "http://localhost:8084/AnaliseAcidentesTrabalho/faces/"; //testes
} }

@ -6,7 +6,7 @@
package mail; package mail;
import db.entidades.PlanoActuacao; import db.entidades.PlanoActuacao;
import db.entidades.User; import db.entidades.Utilizador;
import global.Global; import global.Global;
/** /**
@ -15,25 +15,25 @@ import global.Global;
*/ */
public class SendMail extends Mail{ public class SendMail extends Mail{
public void sendMail(User u, PlanoActuacao p) public void sendMail(Utilizador u, PlanoActuacao p)
{ {
int estado = p.getEstado().intValue(); int estado = p.getEstado().intValue();
switch(estado) switch(estado)
{ {
case Global.ESTADO_CRIACAO_TSHS: // case Global.ESTADO_CRIACAO_TSHS:
break; // break;
//
case Global.ESTADO_EDICAO_SEGURANCA: // case Global.ESTADO_EDICAO_SEGURANCA:
break; // break;
//
case Global.ESTADO_VALIDACAO_DIR_LOJA: // case Global.ESTADO_VALIDACAO_DIR_LOJA:
break; // break;
//
case Global.ESTADO_VALIDACAO_DNS: // case Global.ESTADO_VALIDACAO_DNS:
break; // break;
//
case Global.ESTADO_VERIFICACAO_TSHS: // case Global.ESTADO_VERIFICACAO_TSHS:
break; // break;
} }
} }
} }

@ -0,0 +1,88 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package phaselistener;
import javax.faces.application.NavigationHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.servlet.http.HttpServletRequest;
import planosactuacao.SessionBean1;
import utils.JSFHTTPUtils;
import utils.JSFUtils;
/**
*
* @author lluis
*/
public class MainPhaseListener implements PhaseListener{
private boolean firstEntry = true;
public void afterPhase(PhaseEvent pe) {
if(pe.getPhaseId() == PhaseId.RENDER_RESPONSE)
{
FacesContext fc = pe.getFacesContext();
SessionBean1 session = JSFUtils.getSessionBean(fc);
String view = fc.getViewRoot().getViewId();
if(view.matches("/EditarPlano.jsp"))
{
session.setDisableMenu(true);
}
else
{
session.setDisableMenu(false);
}
System.out.println("VIEW : " + view);
}
}
public void beforePhase(PhaseEvent pe) {
if(pe.getPhaseId() == PhaseId.RENDER_RESPONSE)
{
FacesContext fc = pe.getFacesContext();
SessionBean1 session = JSFUtils.getSessionBean(fc);
String referer = JSFHTTPUtils.getReferer(pe.getFacesContext());
System.out.println("REFERER >>" + referer + "<<");
//check if comes from AnalisesAcidentes. If so, set loggedIn to true:
if(referer.indexOf("AnaliseAcidentes") != -1)
{
session.setLoggedIn(true);
String user = JSFUtils.getRequestParameter(fc, "user");
System.out.println("USER >" + user.toString() + "<");
}
//Determin Session Time out
HttpServletRequest req = (HttpServletRequest) fc.getExternalContext().getRequest();
UIViewRoot view = fc.getViewRoot();
if(!req.isRequestedSessionIdValid() && view.getViewId().indexOf("Login") == -1 ){
NavigationHandler nh = fc.getApplication().getNavigationHandler();
nh.handleNavigation(fc, null, "login");
}
//Determin if user is logged in
//HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);
//SessionBean1 session = JSFUtils.getSessionBean(fc);
boolean loggedIn = session.isLoggedIn();
System.out.println("LOGGED IN : " + loggedIn);
if(!loggedIn && view.getViewId().indexOf("Login") == -1 ){
NavigationHandler nh = fc.getApplication().getNavigationHandler();
nh.handleNavigation(fc, null, "login");
}
}
}
public PhaseId getPhaseId() {
return PhaseId.ANY_PHASE;
}
}

@ -0,0 +1,170 @@
/*
* Dummy.java
*
* Created on Oct 6, 2008, 10:43:13 AM
*/
package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Calendar;
import com.sun.webui.jsf.component.TextArea;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.DefaultTableDataProvider;
import javax.faces.component.html.HtmlPanelGrid;
import tabledataproviders.*;
import javax.faces.FacesException;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
* class contains component definitions (and initialization code) for
* all components that you have defined on this page, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @author lluis
*/
public class Dummy extends AbstractPageBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
/**
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
* This method is automatically generated, so any user-specified code inserted
* here is subject to being replaced.</p>
*/
private void _init() throws Exception {
}
private HtmlPanelGrid grid = new HtmlPanelGrid();
public HtmlPanelGrid getGrid() {
return grid;
}
public void setGrid(HtmlPanelGrid hpg) {
this.grid = hpg;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public Dummy() {
}
/**
* <p>Callback method that is called whenever a page is navigated to,
* either directly via a URL, or indirectly via page navigation.
* Customize this method to acquire resources that will be needed
* for event handlers and lifecycle methods, whether or not this
* page is performing post back processing.</p>
*
* <p>Note that, if the current request is a postback, the property
* values of the components do <strong>not</strong> represent any
* values submitted with this request. Instead, they represent the
* property values that were saved for this view when it was rendered.</p>
*/
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("Dummy Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
/**
* <p>Callback method that is called after the component tree has been
* restored, but before any event processing takes place. This method
* will <strong>only</strong> be called on a postback request that
* is processing a form submit. Customize this method to allocate
* resources that will be required in your event handlers.</p>
*/
@Override
public void preprocess() {
}
/**
* <p>Callback method that is called just before rendering takes place.
* This method will <strong>only</strong> be called for the page that
* will actually be rendered (and not, for example, on a page that
* handled a postback and then navigated to a different page). Customize
* this method to allocate resources that will be required for rendering
* this page.</p>
*/
@Override
public void prerender() {
Calendar cal = new Calendar();
cal.setDateFormatPattern("dd-MM-yyyy");
grid.getChildren().add(cal);
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called (regardless of whether
* or not this was the page that was actually rendered). Customize this
* method to release resources acquired in the <code>init()</code>,
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
* acquired during execution of an event handler).</p>
*/
@Override
public void destroy() {
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean1 getRequestBean1() {
return (RequestBean1) getBean("RequestBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1) getBean("SessionBean1");
}
public String lnkAnaliseAcidentes_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
public String lnkLogout_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
}

@ -7,7 +7,21 @@
package planosactuacao; package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractPageBean; import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.Calendar;
import com.sun.webui.jsf.component.PanelGroup;
import com.sun.webui.jsf.component.StaticText;
import com.sun.webui.jsf.component.TextArea;
import com.sun.webui.jsf.component.TextField;
import db.entidades.Medida;
import db.entidades.PlanoActuacao;
import db.entidades.PostoTrabalho;
import db.entidades.Risco;
import java.util.Vector;
import javax.faces.FacesException; import javax.faces.FacesException;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.context.FacesContext;
import utils.JSFUtils;
/** /**
* <p>Page bean that corresponds to a similarly named JSP page. This * <p>Page bean that corresponds to a similarly named JSP page. This
@ -30,7 +44,85 @@ public class EditarPlano extends AbstractPageBean {
} }
// </editor-fold> // </editor-fold>
HtmlPanelGrid grid;
PanelGroup pg;
StaticText st;
private HtmlPanelGrid gridLayout = new HtmlPanelGrid();
//Plano actuacao
PlanoActuacao plano;
Vector<Medida> medidas = new Vector<Medida>();
Vector<Risco> riscos = new Vector<Risco>();
Vector<PostoTrabalho> postos = new Vector<PostoTrabalho>();
HtmlPanelGrid gridPlano = new HtmlPanelGrid();
HtmlPanelGrid gridRisco;
int risco_id = 0;
int medida_id = 0;
int posto_id = 0;
//page components
TextField txtResponsavelExecucao;
TextArea txtRecursos;
Calendar dtInicio;
Calendar dtFim;
public HtmlPanelGrid getGridLayout() {
return gridLayout;
}
public void setGridLayout(HtmlPanelGrid hpg) {
this.gridLayout = hpg;
}
private Button butGravarPlano = new Button();
public Button getButGravarPlano() {
return butGravarPlano;
}
public void setButGravarPlano(Button b) {
this.butGravarPlano = b;
}
private Button butGravarRisco = new Button();
public Button getButGravarRisco() {
return butGravarRisco;
}
public void setButGravarRisco(Button b) {
this.butGravarRisco = b;
}
private Button butEnviar = new Button();
public Button getButEnviar() {
return butEnviar;
}
public void setButEnviar(Button b) {
this.butEnviar = b;
}
private Button butLimparDados = new Button();
public Button getButLimparDados() {
return butLimparDados;
}
public void setButLimparDados(Button b) {
this.butLimparDados = b;
}
private Button butCancelar = new Button();
public Button getButCancelar() {
return butCancelar;
}
public void setButCancelar(Button b) {
this.butCancelar = b;
}
/** /**
* <p>Construct a new Page bean instance.</p> * <p>Construct a new Page bean instance.</p>
*/ */
@ -71,6 +163,7 @@ public class EditarPlano extends AbstractPageBean {
// Perform application initialization that must complete // Perform application initialization that must complete
// *after* managed components are initialized // *after* managed components are initialized
// TODO - add your own initialization code here // TODO - add your own initialization code here
} }
/** /**
@ -94,6 +187,24 @@ public class EditarPlano extends AbstractPageBean {
*/ */
@Override @Override
public void prerender() { public void prerender() {
System.out.println("PRERENDER");
FacesContext fc = getFacesContext();
//boolean isPostback = JSFUtils.isPostBack12(fc);
//boolean isPostback = JSFUtils.isPostBack(fc);
boolean isPostback = JSFUtils.isPostback();
System.out.println("POSTBACK : " + isPostback);
if(!isPostback)
{
initializePlano();
initialize();
fillPlano();
}
else
{
riscos = getSessionBean1().getRiscos();
medidas = getSessionBean1().getMedidas();
postos = getSessionBean1().getPostos();
}
} }
/** /**
@ -134,6 +245,435 @@ public class EditarPlano extends AbstractPageBean {
protected ApplicationBean1 getApplicationBean1() { protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1"); return (ApplicationBean1) getBean("ApplicationBean1");
} }
public String hyperlink1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return "lista_planos";
}
private void fillPlano()
{
String indent = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
Risco r = getNextRisco(plano.getId());
fillRisco(r);
}
private void fillRisco(Risco r)
{
String indent = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
if(gridLayout.getChildren().size() > 0)
{
gridLayout.getChildren().clear();
}
gridRisco = new HtmlPanelGrid();
gridRisco.setWidth("100%");
gridRisco.setStyle("border: solid 1px #000000");
gridRisco.setColumns(1);
gridRisco.setColumnClasses("gridColLeft");
pg = new PanelGroup();
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setStyle("color: #2c4d7a");
st.setText("RISCO 1" + ":&nbsp;");
pg.getChildren().add(st);
st = new StaticText();
st.setEscape(false);
st.setText(r.getDescricao());
pg.getChildren().add(st);
gridRisco.getChildren().add(pg);
st = new StaticText();
st.setEscape(false);
st.setText("&nbsp;");
gridRisco.getChildren().add(st);
pg = new PanelGroup();
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setText("Valor:" + "&nbsp;");
pg.getChildren().add(st);
st = new StaticText();
st.setEscape(false);
st.setText(r.getValor().toString());
pg.getChildren().add(st);
gridRisco.getChildren().add(pg);
st = new StaticText();
st.setEscape(false);
st.setText("&nbsp;");
gridRisco.getChildren().add(st);
//medidas
Vector<Medida> meds = getMedidas(r.getId());
for(int i = 0; i < meds.size(); i++)
{
Medida m = medidas.get(i);
if(m.getRisco_id().intValue() == r.getId().intValue())
{
pg = new PanelGroup();
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setText(indent + "Medida" + ":&nbsp;");
pg.getChildren().add(st);
st = new StaticText();
st.setEscape(false);
st.setText(m.getDescricao());
pg.getChildren().add(st);
gridRisco.getChildren().add(pg);
//postos trabalho
Vector<PostoTrabalho> posts = getPostosTrabalho(m.getId());
pg = new PanelGroup();
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setText(indent + indent + "Postos de trabalho afectados" + ":&nbsp;");
pg.getChildren().add(st);
st = new StaticText();
st.setEscape(false);
String spostos = "";
for(int j = 0; j < posts.size(); j++)
{
PostoTrabalho p = posts.get(j);
spostos += p.getDescricao(); // + "&nbsp;";
if(j < (posts.size() -1) )
{
spostos += ";&nbsp;";
}
}
st.setText(spostos);
pg.getChildren().add(st);
gridRisco.getChildren().add(pg);
}
}
st = new StaticText();
st.setEscape(false);
st.setText("&nbsp;");
gridRisco.getChildren().add(st);
pg = new PanelGroup();
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setText("Respons&aacute;vel de execu&ccedil;&atilde;o:");
pg.getChildren().add(st);
txtResponsavelExecucao = new TextField();
txtResponsavelExecucao.setColumns(100);
pg.getChildren().add(txtResponsavelExecucao);
gridRisco.getChildren().add(pg);
pg = new PanelGroup();
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setText("Recursos necess&aacute;rios &agrave; implementa&ccedil;&atilde;o da medida:");
pg.getChildren().add(st);
gridRisco.getChildren().add(pg);
txtRecursos = new TextArea();
txtRecursos.setColumns(200);
gridRisco.getChildren().add(txtRecursos);
HtmlPanelGrid grd = new HtmlPanelGrid();
grd.setColumns(2);
grd.setColumnClasses("gridCol15, gridCol85");
grd.setId("pgDtInicio");
grd.setStyle("width: 100%");
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setText("Data prevista de in&iacute;cio:");
grd.getChildren().add(st);
dtInicio = new Calendar();
grd.getChildren().add(dtInicio);
gridRisco.getChildren().add(grd);
grd = new HtmlPanelGrid();
grd.setColumns(2);
grd.setColumnClasses("gridCol15, gridCol85");
grd.setId("pgDtFim");
grd.setStyle("width: 100%");
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setText("Data prevista de conclus&atilde;o:");
grd.getChildren().add(st);
dtFim = new Calendar();
grd.getChildren().add(dtFim);
gridRisco.getChildren().add(grd);
gridLayout.getChildren().add(gridRisco);
}
private void initializePlano()
{
getSessionBean1().setRiscosIdx(0);
//plano
plano = new PlanoActuacao();
plano.setId(new Integer(1));
plano.setEstabelecimento_id(new Integer(1));
plano.setEstado(new Integer(1));
getSessionBean1().setPlanoId(new Integer(1));
plano.setDescricao("Plano 1");
//riscos
Risco r = new Risco();
r.setId(new Integer(1));
r.setPlano_id(new Integer(1));
r.setDescricao("Risco A");
r.setValor(new Integer(4));
riscos.add(r);
r = new Risco();
r.setId(new Integer(2));
r.setPlano_id(new Integer(1));
r.setDescricao("Risco B");
r.setValor(new Integer(6));
riscos.add(r);
r = new Risco();
r.setId(new Integer(3));
r.setPlano_id(new Integer(1));
r.setDescricao("Risco C");
r.setValor(new Integer(12));
riscos.add(r);
//medidas
Medida m = new Medida();
m.setId(new Integer(1));
m.setRisco_id(new Integer(1));
m.setDescricao("Medida a");
medidas.add(m);
m = new Medida();
m.setId(new Integer(2));
m.setRisco_id(new Integer(1));
m.setDescricao("Medida b");
medidas.add(m);
m = new Medida();
m.setId(new Integer(3));
m.setRisco_id(new Integer(2));
m.setDescricao("Medida c");
medidas.add(m);
m = new Medida();
m.setId(new Integer(4));
m.setRisco_id(new Integer(2));
m.setDescricao("Medida d");
medidas.add(m);
m = new Medida();
m.setId(new Integer(5));
m.setRisco_id(new Integer(2));
m.setDescricao("Medida e");
medidas.add(m);
m = new Medida();
m.setId(new Integer(6));
m.setRisco_id(new Integer(3));
m.setDescricao("Medida f");
medidas.add(m);
m = new Medida();
m.setId(new Integer(7));
m.setRisco_id(new Integer(3));
m.setDescricao("Medida g");
medidas.add(m);
//postos trabalho
PostoTrabalho p = new PostoTrabalho();
p.setId(new Integer(1));
p.setMedida_id(new Integer(1));
p.setDescricao("posto 1");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(2));
p.setMedida_id(new Integer(1));
p.setDescricao("posto 2");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(3));
p.setMedida_id(new Integer(1));
p.setDescricao("posto 3");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(4));
p.setMedida_id(new Integer(2));
p.setDescricao("posto 4");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(5));
p.setMedida_id(new Integer(2));
p.setDescricao("posto 5");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(6));
p.setMedida_id(new Integer(3));
p.setDescricao("posto 6");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(7));
p.setMedida_id(new Integer(3));
p.setDescricao("posto 7");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(8));
p.setMedida_id(new Integer(4));
p.setDescricao("posto 8");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(9));
p.setMedida_id(new Integer(4));
p.setDescricao("posto 9");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(10));
p.setMedida_id(new Integer(5));
p.setDescricao("posto 10");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(11));
p.setMedida_id(new Integer(5));
p.setDescricao("posto 11");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(12));
p.setMedida_id(new Integer(6));
p.setDescricao("posto 12");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(13));
p.setMedida_id(new Integer(6));
p.setDescricao("posto 13");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(14));
p.setMedida_id(new Integer(7));
p.setDescricao("posto 14");
postos.add(p);
p = new PostoTrabalho();
p.setId(new Integer(15));
p.setMedida_id(new Integer(7));
p.setDescricao("posto 15");
postos.add(p);
getSessionBean1().setRiscos(riscos);
getSessionBean1().setMedidas(medidas);
getSessionBean1().setPostos(postos);
}
private Risco getNextRisco(Integer planoId)
{
System.out.println("GET NEXT RISCO");
System.out.println("RISCOS SIZE : " + riscos.size());
riscos = getSessionBean1().getRiscos();
risco_id = getSessionBean1().getRiscosIdx();
Risco r = riscos.get(risco_id);
if(r != null)
{
if(r.getPlano_id().intValue() != planoId.intValue())
{
r = null;
risco_id = 0;
}
}
risco_id++;
getSessionBean1().setRiscosIdx(risco_id);
return r;
}
private Vector<Medida> getMedidas(Integer riscoId)
{
Vector<Medida> meds = new Vector<Medida>();
medidas = getSessionBean1().getMedidas();
for(int i = 0; i < medidas.size(); i++)
{
Medida m = medidas.get(i);
if(m.getRisco_id().intValue() == riscoId.intValue())
{
meds.add(m);
}
}
return meds;
}
private Vector<PostoTrabalho> getPostosTrabalho(Integer medidaId)
{
Vector<PostoTrabalho> posts = new Vector<PostoTrabalho>();
postos = getSessionBean1().getPostos();
for(int i = 0; i < postos.size(); i++)
{
PostoTrabalho p = postos.get(i);
if(p.getMedida_id().intValue() == medidaId.intValue())
{
posts.add(p);
}
}
return posts;
}
private void initialize()
{
gridPlano.setWidth("100%");
gridPlano.setColumns(1);
gridPlano.setColumnClasses("gridColCenter");
//plano
st = new StaticText();
st.setEscape(false);
st.setStyleClass("label");
st.setStyle("font-size: 16px");
st.setText(plano.getDescricao());
gridPlano.getChildren().add(st);
gridLayout.getChildren().add(gridPlano);
}
public String butGravarPlano_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
public String butGravarRisco_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
System.out.println("BUT NEXT RISCO");
Risco r = getNextRisco(getSessionBean1().getPlanoId());
fillRisco(r);
return null;
}
public String butEnviar_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
processEnviar();
return null;
}
private void processEnviar()
{
}
} }

@ -0,0 +1,139 @@
/*
* Footer.java
*
* Created on Oct 6, 2008, 3:01:32 PM
*/
package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import javax.faces.FacesException;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
* class contains component definitions (and initialization code) for
* all components that you have defined on this page, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @author lluis
*/
public class Footer extends AbstractPageBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
/**
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
* This method is automatically generated, so any user-specified code inserted
* here is subject to being replaced.</p>
*/
private void _init() throws Exception {
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public Footer() {
}
/**
* <p>Callback method that is called whenever a page is navigated to,
* either directly via a URL, or indirectly via page navigation.
* Customize this method to acquire resources that will be needed
* for event handlers and lifecycle methods, whether or not this
* page is performing post back processing.</p>
*
* <p>Note that, if the current request is a postback, the property
* values of the components do <strong>not</strong> represent any
* values submitted with this request. Instead, they represent the
* property values that were saved for this view when it was rendered.</p>
*/
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("Footer Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
/**
* <p>Callback method that is called after the component tree has been
* restored, but before any event processing takes place. This method
* will <strong>only</strong> be called on a postback request that
* is processing a form submit. Customize this method to allocate
* resources that will be required in your event handlers.</p>
*/
@Override
public void preprocess() {
}
/**
* <p>Callback method that is called just before rendering takes place.
* This method will <strong>only</strong> be called for the page that
* will actually be rendered (and not, for example, on a page that
* handled a postback and then navigated to a different page). Customize
* this method to allocate resources that will be required for rendering
* this page.</p>
*/
@Override
public void prerender() {
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called (regardless of whether
* or not this was the page that was actually rendered). Customize this
* method to release resources acquired in the <code>init()</code>,
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
* acquired during execution of an event handler).</p>
*/
@Override
public void destroy() {
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean1 getRequestBean1() {
return (RequestBean1) getBean("RequestBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1) getBean("SessionBean1");
}
}

@ -0,0 +1,170 @@
/*
* Header.java
*
* Created on Oct 6, 2008, 10:35:36 AM
*/
package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractFragmentBean;
import db.entidades.Utilizador;
import global.Global;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import utils.JSFHTTPUtils;
import utils.JSFUtils;
/**
* <p>Fragment bean that corresponds to a similarly named JSP page
* fragment. This class contains component definitions (and initialization
* code) for all components that you have defined on this fragment, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @author lluis
*/
public class Header extends AbstractFragmentBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
/**
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
* This method is automatically generated, so any user-specified code inserted
* here is subject to being replaced.</p>
*/
private void _init() throws Exception {
}
// </editor-fold>
public Header() {
}
/**
* <p>Callback method that is called whenever a page containing
* this page fragment is navigated to, either directly via a URL,
* or indirectly via page navigation. Override this method to acquire
* resources that will be needed for event handlers and lifecycle methods.</p>
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
FacesContext fc = getFacesContext();
String referer = JSFHTTPUtils.getReferer(fc);
System.out.println("HEADER - REFERER : " + referer);
// <editor-fold defaultstate="collapsed" desc="Visual-Web-managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("Page1 Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called. Override this
* method to release resources acquired in the <code>init()</code>
* resources that will be needed for event handlers and lifecycle methods.</p>
*
* <p>The default implementation does nothing.</p>
*/
@Override
public void destroy() {
}
public String lnkLogout_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
FacesContext fc = getFacesContext();
try
{
JSFUtils.logout(fc);
//JSFUtils.navigateTo(fc, "login");
try
{
JSFUtils.redirect(fc, "http://localhost:8084/AnaliseAcidentesTrabalho/faces/Login.jsp");
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
catch(Exception ex)
{
}
return null;
}
public String lnkAnaliseAcidentes_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
FacesContext fc = getFacesContext();
SessionBean1 session = JSFUtils.getSessionBean(fc);
Utilizador u = session.getCurrentUser();
String url = Global.ANALISE_ACIDENTES_URL;
int tipo = u.getTipo().intValue();
switch(tipo)
{
case Global.RESPONSAVEL_SEGURANCA:
url += "FormSeguranca.jsp?user=" + u.getId().intValue();
break;
case Global.RH:
url += "FormRH.jsp?user=" + u.getId().intValue();
break;
case Global.TECNICO_HS:
url += "FormHS.jsp?user=" + u.getId().intValue();
break;
case Global.GESTOR:
url += "FormGestor.jsp?user=" + u.getId().intValue();
break;
case Global.DIRECTOR_LOJA:
url += "FormGestor.jsp?user=" + u.getId().intValue();
break;
case Global.DIRECTOR_GERAL_RH:
url += "FormDirGerRh.jsp?user=" + u.getId().intValue();
break;
case Global.DIRECTOR_SIPRP:
url += "FormDirSiprp.jsp?user=" + u.getId().intValue();
break;
case Global.DIRECTOR_NACIONAL_SEGURANCA:
url += "FormGestor.jsp?user=" + u.getId().intValue();
break;
}
try
{
JSFUtils.redirect(fc.getCurrentInstance(), url);
}
catch(Exception ex)
{
ex.printStackTrace();
}
return null;
}
}

@ -7,7 +7,16 @@
package planosactuacao; package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractPageBean; import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TableRowGroup;
import db.entidades.PlanoActuacao;
import db.providers.UtilizadoresDataProvider;
import db.entidades.Utilizador;
import java.util.ArrayList;
import java.util.Calendar;
import javax.faces.FacesException; import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import utils.JSFUtils;
/** /**
* <p>Page bean that corresponds to a similarly named JSP page. This * <p>Page bean that corresponds to a similarly named JSP page. This
@ -28,6 +37,42 @@ public class ListaPlanos extends AbstractPageBean {
*/ */
private void _init() throws Exception { private void _init() throws Exception {
} }
private Table table1 = new Table();
public Table getTable1() {
return table1;
}
public void setTable1(Table t) {
this.table1 = t;
}
private TableRowGroup tableRowGroup1 = new TableRowGroup();
public TableRowGroup getTableRowGroup1() {
return tableRowGroup1;
}
public void setTableRowGroup1(TableRowGroup trg) {
this.tableRowGroup1 = trg;
}
private TableRowGroup tableRowGroup2 = new TableRowGroup();
public TableRowGroup getTableRowGroup2() {
return tableRowGroup2;
}
public void setTableRowGroup2(TableRowGroup trg) {
this.tableRowGroup2 = trg;
}
private TableRowGroup tableRowGroup3 = new TableRowGroup();
public TableRowGroup getTableRowGroup3() {
return tableRowGroup3;
}
public void setTableRowGroup3(TableRowGroup trg) {
this.tableRowGroup3 = trg;
}
// </editor-fold> // </editor-fold>
@ -94,6 +139,37 @@ public class ListaPlanos extends AbstractPageBean {
*/ */
@Override @Override
public void prerender() { public void prerender() {
//UIComponent emptyCol = tableRowGroup1.getEmptyDataText();
tableRowGroup1.setEmptyDataMsg("Sem registos");
tableRowGroup2.setEmptyDataMsg("Sem registos");
tableRowGroup3.setEmptyDataMsg("Sem registos");
FacesContext fc = getFacesContext();
String user_id = JSFUtils.getRequestParameter(fc, "user");
try
{
Integer userId = new Integer(Integer.parseInt(user_id));
try
{
UtilizadoresDataProvider udp = new UtilizadoresDataProvider();
udp.checkConnection();
Utilizador u = udp.getUtilizador(userId);
getSessionBean1().setCurrentUser(u);
}
catch(Exception ex1)
{
ex1.printStackTrace();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
initialize();
} }
/** /**
@ -134,6 +210,82 @@ public class ListaPlanos extends AbstractPageBean {
protected SessionBean1 getSessionBean1() { protected SessionBean1 getSessionBean1() {
return (SessionBean1) getBean("SessionBean1"); return (SessionBean1) getBean("SessionBean1");
} }
public String hyperlink1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return "editar_plano";
}
public String goEditarPlano_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return "editar_plano";
}
public String goImprimirPlano_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
private void initialize()
{
//Dummy : to remove later
ArrayList listActivos = new ArrayList();
PlanoActuacao pa = new PlanoActuacao();
Calendar cal = Calendar.getInstance();
cal.set( cal.YEAR, 2008 );
cal.set( cal.MONTH, cal.SEPTEMBER );
cal.set( cal.DATE, 3 );
cal.set( cal.HOUR_OF_DAY, 0 );
cal.set( cal.MINUTE, 0 );
cal.set( cal.SECOND, 0 );
cal.set( cal.MILLISECOND, 0 );
java.sql.Date dataVisita =
new java.sql.Date( cal.getTime().getTime() );
pa.setData_visita(dataVisita);
pa.setEstabelecimento_id(new Integer(12));
pa.setFase(2);
pa.setFase_nome("SIPRP (Emissão)");
pa.setLoja_nome("Setubal");
pa.setTecnico_hs_id(new Integer(7));
pa.setTecnico_hs_nome("Ana");
listActivos.add(pa);
pa = new PlanoActuacao();
cal.set( cal.YEAR, 2008 );
cal.set( cal.MONTH, cal.OCTOBER );
cal.set( cal.DATE, 12 );
cal.set( cal.HOUR_OF_DAY, 0 );
cal.set( cal.MINUTE, 0 );
cal.set( cal.SECOND, 0 );
cal.set( cal.MILLISECOND, 0 );
dataVisita =
new java.sql.Date( cal.getTime().getTime() );
pa.setData_visita(dataVisita);
pa.setEstabelecimento_id(new Integer(12));
pa.setFase(2);
pa.setFase_nome("DNS (Parecer)");
pa.setLoja_nome("Cascais");
pa.setTecnico_hs_id(new Integer(7));
pa.setTecnico_hs_nome("Sónia");
listActivos.add(pa);
getSessionBean1().getPlanosActualDataProvider().setList(listActivos);
//End Dummy
}
} }

@ -7,6 +7,11 @@
package planosactuacao; package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractSessionBean; import com.sun.rave.web.ui.appbase.AbstractSessionBean;
import db.entidades.Medida;
import db.entidades.PostoTrabalho;
import db.entidades.Risco;
import db.entidades.Utilizador;
import java.util.Vector;
import javax.faces.FacesException; import javax.faces.FacesException;
/** /**
@ -23,7 +28,19 @@ import javax.faces.FacesException;
*/ */
public class SessionBean1 extends AbstractSessionBean { public class SessionBean1 extends AbstractSessionBean {
private boolean loggedIn = false;
private Utilizador currentUser = null;
private String msg; private String msg;
private Integer planoId;
private Vector<Risco> riscos = new Vector<Risco>();
private Vector<Medida> medidas = new Vector<Medida>();
private Vector<PostoTrabalho> postos = new Vector<PostoTrabalho>();
private int riscosIdx = 0;
private tabledataproviders.PlanosActualDataProvider planosActualDataProvider;
private tabledataproviders.PlanosSeguimentoDataProvider planosSeguimentoDataProvider;
private tabledataproviders.PlanosConcluidosDataProvider planosConcluidosDataProvider;
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition"> // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
/** /**
@ -34,12 +51,26 @@ public class SessionBean1 extends AbstractSessionBean {
private void _init() throws Exception { private void _init() throws Exception {
} }
// </editor-fold> // </editor-fold>
//menu
private boolean disableMenu;
private boolean disableMenuAnalises;
private boolean disableMenuPlanos;
private boolean disableMenuUtilizadores;
private boolean disableMenuDadosUtilizador;
/** /**
* <p>Construct a new session data bean instance.</p> * <p>Construct a new session data bean instance.</p>
*/ */
public SessionBean1() { public SessionBean1() {
msg = ""; msg = "";
planosActualDataProvider = new tabledataproviders.PlanosActualDataProvider();
planosSeguimentoDataProvider = new tabledataproviders.PlanosSeguimentoDataProvider();
planosConcluidosDataProvider = new tabledataproviders.PlanosConcluidosDataProvider();
planoId = null;
} }
/** /**
@ -133,4 +164,128 @@ public class SessionBean1 extends AbstractSessionBean {
this.msg = msg; this.msg = msg;
} }
public boolean isLoggedIn() {
return loggedIn;
}
public void setLoggedIn(boolean loggedIn) {
this.loggedIn = loggedIn;
}
public tabledataproviders.PlanosActualDataProvider getPlanosActualDataProvider() {
return planosActualDataProvider;
}
public void setPlanosActualDataProvider(tabledataproviders.PlanosActualDataProvider planosActualDataProvider) {
this.planosActualDataProvider = planosActualDataProvider;
}
public tabledataproviders.PlanosSeguimentoDataProvider getPlanosSeguimentoDataProvider() {
return planosSeguimentoDataProvider;
}
public void setPlanosSeguimentoDataProvider(tabledataproviders.PlanosSeguimentoDataProvider planosSeguimentoDataProvider) {
this.planosSeguimentoDataProvider = planosSeguimentoDataProvider;
}
public tabledataproviders.PlanosConcluidosDataProvider getPlanosConcluidosDataProvider() {
return planosConcluidosDataProvider;
}
public void setPlanosConcluidosDataProvider(tabledataproviders.PlanosConcluidosDataProvider planosConcluidosDataProvider) {
this.planosConcluidosDataProvider = planosConcluidosDataProvider;
}
public Integer getPlanoId() {
return planoId;
}
public void setPlanoId(Integer planoId) {
this.planoId = planoId;
}
public Vector<Risco> getRiscos() {
return riscos;
}
public void setRiscos(Vector<Risco> riscos) {
this.riscos = riscos;
}
public Vector<Medida> getMedidas() {
return medidas;
}
public void setMedidas(Vector<Medida> medidas) {
this.medidas = medidas;
}
public Vector<PostoTrabalho> getPostos() {
return postos;
}
public void setPostos(Vector<PostoTrabalho> postos) {
this.postos = postos;
}
public int getRiscosIdx() {
return riscosIdx;
}
public void setRiscosIdx(int riscosIdx) {
this.riscosIdx = riscosIdx;
}
public Utilizador getCurrentUser() {
return currentUser;
}
public void setCurrentUser(Utilizador currentUser) {
this.currentUser = currentUser;
}
public boolean isDisableMenu() {
return disableMenu;
}
public void setDisableMenu(boolean disableMenu) {
setDisableMenuAnalises(disableMenu);
setDisableMenuPlanos(disableMenu);
setDisableMenuUtilizadores(disableMenu);
setDisableMenuDadosUtilizador(disableMenu);
this.disableMenu = disableMenu;
}
public boolean isDisableMenuAnalises() {
return disableMenuAnalises;
}
public void setDisableMenuAnalises(boolean disableMenuAnalises) {
this.disableMenuAnalises = disableMenuAnalises;
}
public boolean isDisableMenuPlanos() {
return disableMenuPlanos;
}
public void setDisableMenuPlanos(boolean disableMenuPlanos) {
this.disableMenuPlanos = disableMenuPlanos;
}
public boolean isDisableMenuUtilizadores() {
return disableMenuUtilizadores;
}
public void setDisableMenuUtilizadores(boolean disableMenuUtilizadores) {
this.disableMenuUtilizadores = disableMenuUtilizadores;
}
public boolean isDisableMenuDadosUtilizador() {
return disableMenuDadosUtilizador;
}
public void setDisableMenuDadosUtilizador(boolean disableMenuDadosUtilizador) {
this.disableMenuDadosUtilizador = disableMenuDadosUtilizador;
}
} }

@ -0,0 +1,139 @@
/*
* ViewPlano.java
*
* Created on Oct 20, 2008, 10:39:31 AM
*/
package planosactuacao;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import javax.faces.FacesException;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
* class contains component definitions (and initialization code) for
* all components that you have defined on this page, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @author lluis
*/
public class ViewPlano extends AbstractPageBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
/**
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
* This method is automatically generated, so any user-specified code inserted
* here is subject to being replaced.</p>
*/
private void _init() throws Exception {
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public ViewPlano() {
}
/**
* <p>Callback method that is called whenever a page is navigated to,
* either directly via a URL, or indirectly via page navigation.
* Customize this method to acquire resources that will be needed
* for event handlers and lifecycle methods, whether or not this
* page is performing post back processing.</p>
*
* <p>Note that, if the current request is a postback, the property
* values of the components do <strong>not</strong> represent any
* values submitted with this request. Instead, they represent the
* property values that were saved for this view when it was rendered.</p>
*/
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("ViewPlano Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
/**
* <p>Callback method that is called after the component tree has been
* restored, but before any event processing takes place. This method
* will <strong>only</strong> be called on a postback request that
* is processing a form submit. Customize this method to allocate
* resources that will be required in your event handlers.</p>
*/
@Override
public void preprocess() {
}
/**
* <p>Callback method that is called just before rendering takes place.
* This method will <strong>only</strong> be called for the page that
* will actually be rendered (and not, for example, on a page that
* handled a postback and then navigated to a different page). Customize
* this method to allocate resources that will be required for rendering
* this page.</p>
*/
@Override
public void prerender() {
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called (regardless of whether
* or not this was the page that was actually rendered). Customize this
* method to release resources acquired in the <code>init()</code>,
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
* acquired during execution of an event handler).</p>
*/
@Override
public void destroy() {
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1) getBean("SessionBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean1 getRequestBean1() {
return (RequestBean1) getBean("RequestBean1");
}
}

@ -0,0 +1,18 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tabledataproviders;
import com.sun.data.provider.impl.ObjectListDataProvider;
/**
*
* @author lluis
*/
public class PlanosActualDataProvider extends ObjectListDataProvider {
public PlanosActualDataProvider(){
}
}

@ -0,0 +1,18 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tabledataproviders;
import com.sun.data.provider.impl.ObjectListDataProvider;
/**
*
* @author lluis
*/
public class PlanosConcluidosDataProvider extends ObjectListDataProvider {
public PlanosConcluidosDataProvider(){
}
}

@ -0,0 +1,18 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tabledataproviders;
import com.sun.data.provider.impl.ObjectListDataProvider;
/**
*
* @author lluis
*/
public class PlanosSeguimentoDataProvider extends ObjectListDataProvider {
public PlanosSeguimentoDataProvider(){
}
}

@ -0,0 +1,23 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package utils;
import java.util.Map;
import javax.faces.context.FacesContext;
/**
*
* @author lluis
*/
public class JSFHTTPUtils {
public static String getReferer(FacesContext context)
{
Map headerMap = context.getCurrentInstance().getExternalContext().getRequestHeaderMap();
String referer = (String) headerMap.get("referer");
return referer;
}
}

@ -0,0 +1,103 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package utils;
import java.util.Iterator;
import java.util.Map;
import javax.faces.application.Application;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.render.ResponseStateManager;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import planosactuacao.SessionBean1;
/**
*
* @author lluis
*/
public class JSFUtils {
public static SessionBean1 getSessionBean(FacesContext fc)
{
FacesContext context = fc.getCurrentInstance();
SessionBean1 session = (SessionBean1) context.getApplication().getELResolver().getValue(context.getELContext(), null, "SessionBean1");
return session;
}
//
// isPostBack - JSF 1.1 implementation
//
public static boolean isPostBack(FacesContext fc)
{
Map parameterMap = fc.getExternalContext().getRequestParameterMap();
if(parameterMap.size() > 0)
{
Iterator iter = parameterMap.keySet().iterator();
while(iter.hasNext())
{
String par = (String) iter.next();
}
return true;
}
return false;
}
public static boolean isPostback() {
FacesContext facesContext = FacesContext.getCurrentInstance();
Map requestScope = (Map) facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{requestScope}", Map.class).getValue(facesContext.getELContext());
//Map requestScope = (Map)facesContext.getApplication().createValueBinding(?#{requestScope}?).getValue(facesContext);
boolean ispostback = ((Boolean)requestScope.get("ispostback")).booleanValue();
System.out.println("POSTBACK A : " + ispostback);
return ispostback;
}
//
// isPostBack - JSF 1.2 implementation
//
public static boolean isPostBack12(FacesContext fc)
{
ResponseStateManager rsm = fc.getRenderKit().getResponseStateManager();
if(rsm.isPostback(fc))
{
return true;
}
return false;
}
public static void logout(FacesContext fc) throws Exception
{
ExternalContext ectx = fc.getCurrentInstance().getExternalContext();
HttpSession session = (HttpSession) ectx.getSession(false);
session.invalidate();
}
public static void navigateTo(FacesContext fc, String outcome)
{
FacesContext context = fc.getCurrentInstance();
Application app = context.getApplication();
app.getNavigationHandler().handleNavigation(context, null, outcome);
}
public static void redirect(FacesContext context, String url) throws Exception
{
HttpServletResponse response = (HttpServletResponse) context.getCurrentInstance().getExternalContext().getResponse();
response.sendRedirect(url);
context.responseComplete();
}
public static String getRequestParameter(FacesContext fc, String parameter)
{
Map parameters = fc.getCurrentInstance().getExternalContext().getRequestParameterMap();
return (String) parameters.get(parameter);
}
}

@ -0,0 +1,75 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package viewhandler;
import java.io.IOException;
import java.util.Locale;
import java.util.Map;
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
/**
*
* @author lluis
*/
public class CustomViewHandler extends ViewHandler{
protected ViewHandler baseViewHandler;
public CustomViewHandler(ViewHandler viewHandler) {
super();
this.baseViewHandler = viewHandler;
}
public Locale calculateLocale(FacesContext facesContext) {
return baseViewHandler.calculateLocale(facesContext);
}
public String calculateRenderKitId(FacesContext facesContext) {
return baseViewHandler.calculateRenderKitId(facesContext);
}
public UIViewRoot createView(FacesContext facesContext, String arg1) {
setPostback(facesContext, false);
return baseViewHandler.createView(facesContext, arg1);
}
public String getActionURL(FacesContext facesContext, String arg1) {
return baseViewHandler.getActionURL(facesContext, arg1);
}
public String getResourceURL(FacesContext facesContext, String arg1) {
return baseViewHandler.getResourceURL(facesContext, arg1);
}
public void renderView(FacesContext facesContext, UIViewRoot arg1) throws IOException, FacesException {
baseViewHandler.renderView(facesContext, arg1);
}
public UIViewRoot restoreView(FacesContext facesContext, String arg1) {
setPostback(facesContext, true);
return baseViewHandler.restoreView(facesContext, arg1);
}
public void writeState(FacesContext facesContext) throws IOException {
baseViewHandler.writeState(facesContext);
}
public Map getRequestScope(FacesContext facesContext) {
//return (Map)facesContext.getApplication().createValueBinding(?#{requestScope}?).getValue(facesContext);
//return (Map)facesContext.getApplication().
return (Map) facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{requestScope}", Map.class).getValue(facesContext.getELContext());
}
public void setPostback(FacesContext facesContext, boolean value) {
getRequestScope(facesContext).put("ispostback", new Boolean(value));
}
}

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Document : Dummy
Created on : Oct 6, 2008, 10:43:13 AM
Author : lluis
-->
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/>
<f:view>
<webuijsf:page id="page1">
<webuijsf:html id="html1">
<webuijsf:head id="head1">
<webuijsf:link id="link1" url="/resources/stylesheet.css"/>
<style>
.gridCol10{
width: 10%;
}
.gridCol20{
width: 20%;
}
.gridCol80{
width: 80%;
}
.gridCol90{
width: 90%;
}
</style>
</webuijsf:head>
<webuijsf:body id="body1" style="-rave-layout: grid">
<webuijsf:form id="form1">
<h:panelGrid binding="#{Dummy.grid}" columns="1" id="grid" style="height: 72px; left: 216px; top: 24px; position: absolute; width: 96px"/>
<h:panelGrid columnClasses="gridCol30,gridCol70" columns="2" id="gridPanel1"
style="height: 24px; left: 120px; top: 192px; position: absolute; width: 80%" styleClass="centerBlock" width="552">
<webuijsf:panelGroup id="groupPanel1">
<webuijsf:image id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<webuijsf:staticText escape="false" id="staticText1" style="" text="&amp;nbsp;"/>
<webuijsf:image height="40" id="image2" style="" url="/resources/images/logo_auchan_small.jpg"/>
</webuijsf:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel2" style="height: 24px; width: 80%" styleClass="centerBlock">
<webuijsf:panelGroup id="groupPanel2" style="">
<webuijsf:hyperlink actionExpression="#{Dummy.lnkAnaliseAcidentes_action}" id="lnkAnaliseAcidentes1" text="análises acidentes&gt;&gt;"/>
</webuijsf:panelGroup>
<webuijsf:panelGroup id="groupPanel3">
<webuijsf:staticText escape="false" id="lblUser1" styleClass="label" text="#{SessionBean1.currentUser.login}"/>
<webuijsf:staticText escape="false" id="staticText2" text="&amp;nbsp;&amp;nbsp;&amp;nbsp;"/>
<webuijsf:hyperlink id="lnkPlanosActuacao1" text="planos actuação"/>
<webuijsf:staticText escape="false" id="staticText3" text="&amp;nbsp;|&amp;nbsp;"/>
<webuijsf:hyperlink id="lnkGerirUtilizadores1" style="" text="gerir utilizadores"/>
<webuijsf:staticText escape="false" id="staticText4" text="&amp;nbsp;|&amp;nbsp;"/>
<webuijsf:hyperlink id="lnkDadosUtilizador1" style="" text="alterar dados utilizador"/>
<webuijsf:staticText escape="false" id="staticText5" text="&amp;nbsp;|&amp;nbsp;"/>
<webuijsf:hyperlink actionExpression="#{Dummy.lnkLogout_action}" id="lnkLogout1" text="sair&gt;&gt;"/>
</webuijsf:panelGroup>
</h:panelGrid>
</h:panelGrid>
<webuijsf:hyperlink id="hyperlink1" style="color: #008000; left: 432px; top: 144px; position: absolute" text="Hyperlink"/>
</webuijsf:form>
</webuijsf:body>
</webuijsf:html>
</webuijsf:page>
</f:view>
</jsp:root>

@ -4,7 +4,6 @@
Created on : Aug 26, 2008, 3:10:59 PM Created on : Aug 26, 2008, 3:10:59 PM
Author : lluis Author : lluis
--> -->
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf"> <jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/> <jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/>
<f:view> <f:view>
@ -12,9 +11,37 @@
<webuijsf:html id="html1"> <webuijsf:html id="html1">
<webuijsf:head id="head1"> <webuijsf:head id="head1">
<webuijsf:link id="link1" url="/resources/stylesheet.css"/> <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
<style></style>
</webuijsf:head> </webuijsf:head>
<webuijsf:body id="body1" style="-rave-layout: grid"> <webuijsf:body id="body1">
<webuijsf:form id="form1"> <webuijsf:form id="form1">
<div style="left: 0px; top: 0px; width: 100%">
<jsp:directive.include file="Header.jspf"/>
</div>
<h:panelGrid columns="1" id="gridBaseLayout" style="left: 24px; top: 96px; width: 100%" styleClass="centerBlock">
<webuijsf:staticText escape="false" id="staticText1" style="font-size: 36px" text="&amp;nbsp;"/>
<webuijsf:staticText escape="false" id="lblTop" style="" styleClass="label" text="Plano de actuação da auditoria 02/10/2008"/>
<h:panelGrid binding="#{EditarPlano.gridLayout}" columnClasses="gridColLeft" columns="1" id="gridLayout"
style="height: 24px; width: 80%" styleClass="centerBlock"/>
<h:panelGrid columns="1" id="gridButtons1" style="height: 24px; width: 80%" styleClass="centerBlock">
<h:panelGrid columnClasses="gridColLeft,gridColRight" columns="2" id="gridPanel1" style="height: 24px; width: 100%">
<webuijsf:button binding="#{EditarPlano.butLimparDados}" id="butLimparDados" style="width: 95px" text="Limpar dados"/>
<webuijsf:panelGroup id="groupPanel1" style="width: 194px">
<webuijsf:button actionExpression="#{EditarPlano.butGravarPlano_action}" binding="#{EditarPlano.butGravarPlano}"
id="butGravarPlano" style="width: 95px" text="Gravar Plano"/>
<webuijsf:button actionExpression="#{EditarPlano.butGravarRisco_action}" binding="#{EditarPlano.butGravarRisco}"
id="butGravarRisco" style="width: 95px" text="Gravar Risco&gt;&gt;"/>
</webuijsf:panelGroup>
</h:panelGrid>
<h:panelGrid columnClasses="gridColLeft,gridColRight" columns="2" id="gridPanel2" style="height: 24px; width: 100%">
<webuijsf:button binding="#{EditarPlano.butCancelar}" id="butCancelar" style="width: 95px" text="Cancelar"/>
<webuijsf:panelGroup id="groupPanel2" style="width: 194px">
<webuijsf:button actionExpression="#{EditarPlano.butEnviar_action}" binding="#{EditarPlano.butEnviar}" id="butEnviar"
style="width: 153px" text="Enviar a Director de Loja&gt;&gt;"/>
</webuijsf:panelGroup>
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
</webuijsf:form> </webuijsf:form>
</webuijsf:body> </webuijsf:body>
</webuijsf:html> </webuijsf:html>

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Document : Footer
Created on : Oct 6, 2008, 3:01:32 PM
Author : lluis
-->
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/>
<f:subview id="footer">
<webuijsf:page id="page1">
<webuijsf:html id="html1">
<webuijsf:head id="head1">
<webuijsf:link id="link1" url="/resources/stylesheet.css"/>
</webuijsf:head>
<webuijsf:body id="body1" style="-rave-layout: grid">
<webuijsf:form id="form1">
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridPanel1" style="height: 24px; width: 100%">
<webuijsf:panelGroup id="groupPanel1">
<webuijsf:staticText escape="false" id="staticText1" text="Software desenvolvido por&amp;nbsp;"/>
<webuijsf:image id="image1" url="/resources/images/logo_evolute_small.png"/>
<webuijsf:staticText escape="false" id="staticText2" text="&amp;nbsp;&amp;copy; 2008"/>
</webuijsf:panelGroup>
</h:panelGrid>
</webuijsf:form>
</webuijsf:body>
</webuijsf:html>
</webuijsf:page>
</f:subview>
</jsp:root>

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Document : Header
Created on : Oct 6, 2008, 10:35:32 AM
Author : lluis
-->
<div style="height: 30px; width: 100%; -rave-layout: grid" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<f:subview id="Header">
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel1" style="height: 24px; left: 0px; top: 0px; position: absolute; width: 100%" styleClass="centerBlock">
<h:panelGrid columnClasses="gridCol30,gridCol70" columns="2" id="gridPanel2" style="height: 24px; width: 80%" styleClass="centerBlock" width="552">
<webuijsf:panelGroup id="groupPanel1">
<webuijsf:image id="image1" url="/resources/images/SIPRP_logo_small.jpg"/>
<webuijsf:staticText escape="false" id="staticText1" style="" text="&amp;nbsp;"/>
<webuijsf:image height="40" id="image2" style="" url="/resources/images/logo_auchan_small.jpg"/>
</webuijsf:panelGroup>
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel3" style="height: 24px; width: 80%" styleClass="centerBlock">
<webuijsf:panelGroup id="groupPanel2" style="">
<webuijsf:hyperlink actionExpression="#{Header.lnkAnaliseAcidentes_action}" disabled="#{SessionBean1.disableMenuAnalises}"
id="lnkAnaliseAcidentes1" text="análises acidentes&gt;&gt;"/>
</webuijsf:panelGroup>
<webuijsf:panelGroup id="groupPanel3">
<webuijsf:staticText escape="false" id="lblUser1" styleClass="label" text="#{SessionBean1.currentUser.login}"/>
<webuijsf:staticText escape="false" id="staticText2" text="&amp;nbsp;&amp;nbsp;&amp;nbsp;"/>
<webuijsf:hyperlink disabled="#{SessionBean1.disableMenuPlanos}" id="lnkPlanosActuacao1" text="planos actuação"/>
<webuijsf:staticText escape="false" id="staticText3" text="&amp;nbsp;|&amp;nbsp;"/>
<webuijsf:hyperlink disabled="#{SessionBean1.disableMenuUtilizadores}" id="lnkGerirUtilizadores1" style="" text="gerir utilizadores"/>
<webuijsf:staticText escape="false" id="staticText4" text="&amp;nbsp;|&amp;nbsp;"/>
<webuijsf:hyperlink disabled="#{SessionBean1.disableMenuDadosUtilizador}" id="lnkDadosUtilizador1" style="" text="alterar dados utilizador"/>
<webuijsf:staticText escape="false" id="staticText6" text="&amp;nbsp;|&amp;nbsp;"/>
<webuijsf:hyperlink id="lnkAjuda" style="" text="ajuda"/>
<webuijsf:staticText escape="false" id="staticText5" text="&amp;nbsp;|&amp;nbsp;"/>
<webuijsf:hyperlink actionExpression="#{Header.lnkLogout_action}" id="lnkLogout1" text="sair&gt;&gt;"/>
</webuijsf:panelGroup>
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
</f:subview>
</div>

@ -4,17 +4,131 @@
Created on : Aug 29, 2008, 2:57:16 PM Created on : Aug 29, 2008, 2:57:16 PM
Author : lluis Author : lluis
--> -->
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf"> <jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/> <jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/>
<f:view> <f:view locale="pt_PT">
<webuijsf:page id="page1"> <webuijsf:page id="page1">
<webuijsf:html id="html1"> <webuijsf:html id="html1">
<webuijsf:head id="head1"> <webuijsf:head id="head1">
<webuijsf:link id="link1" url="/resources/stylesheet.css"/> <webuijsf:link id="link1" url="/resources/stylesheet.css"/>
<script>
function checkEmptyTables()
{
var tableId1 = "_form1:table1:tableRowGroup1:_emptyDataColumn:_emptyDataText";
var tableId2 = "_form1:table2:tableRowGroup2:_emptyDataColumn:_emptyDataText";
var tableId3 = "_form1:table3:tableRowGroup3:_emptyDataColumn:_emptyDataText";
var t1 = document.getElementById(tableId1);
if(t1 != null)
{
//alert( t1.innerHTML );
t1.innerHTML = '';
}
}
</script>
</webuijsf:head> </webuijsf:head>
<webuijsf:body id="body1" style="-rave-layout: grid"> <webuijsf:body id="body1" onLoad="checkEmptyTables();">
<webuijsf:form id="form1"> <webuijsf:form id="form1">
<div style="height: 24px; left: 0px; top: 0px; width: 100%">
<jsp:directive.include file="Header.jspf"/>
</div>
<h:panelGrid columns="1" id="gridBaseLayout" lang="pt" style="height: 96px; width: 100%" styleClass="centerBlock" width="336">
<h:panelGrid columns="1" id="gridLayout" style="height: 24px; width: 80%" styleClass="centerBlock">
<webuijsf:staticText escape="false" id="staticText4" style="font-size: 36px" text="&amp;nbsp;"/>
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridMsg" style="height: 24px; width: 100%">
<webuijsf:staticText id="lblMsg" styleClass="labelMsg "/>
</h:panelGrid>
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridActual1" style="height: 24px; width: 100%" styleClass="gridPlanosList">
<webuijsf:staticText id="staticText1" style="font-size: 18px" text="Actual"/>
<webuijsf:staticText escape="false" id="staticText2" style="font-size: 14px" text=" "/>
<webuijsf:staticText id="staticText3" styleClass="label" text="Processos com dados pendentes"/>
<h:panelGrid columns="1" id="gridPanel1" style="height: 24px; width: 80%" styleClass="centerBlock" width="456">
<webuijsf:table augmentTitle="false" binding="#{ListaPlanos.table1}" id="table1" style="width: 100%"
styleClass="centerBlock" width="100%">
<webuijsf:tableRowGroup binding="#{ListaPlanos.tableRowGroup1}" id="tableRowGroup1" rows="10"
sourceData="#{SessionBean1.planosActualDataProvider}" sourceVar="currentRow">
<webuijsf:tableColumn headerText="Data da visita" id="tableColumn1" sort="data_visita">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goEditarPlano_action}" id="lnkDataActivo" text="#{currentRow.value['data_visita']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Técnico de HST" id="tableColumn2" sort="tecnico_hs_nome">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goEditarPlano_action}" id="lnkTecnicoHsActivo" text="#{currentRow.value['tecnico_hs_nome']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Fase" id="tableColumn3" sort="fase">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goEditarPlano_action}" id="lnkFaseActivo" text="#{currentRow.value['fase_nome']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Plano" id="tableColumn10">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goImprimirPlano_action}" id="lnkPlanoActivo" style="color: #008000;" text="imprimir"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Loja" id="tableColumn13" sort="loja_nome">
<webuijsf:hyperlink actionExpression="#{ListaPlanos.goEditarPlano_action}" id="lnkLojaActivo" text="#{currentRow.value['loja_nome']}"/>
</webuijsf:tableColumn>
</webuijsf:tableRowGroup>
</webuijsf:table>
</h:panelGrid>
</h:panelGrid>
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridSeguimento1" style="height: 24px; width: 100%" styleClass="gridPlanosList">
<webuijsf:staticText id="staticText7" style="font-size: 18px" text="Em seguimento"/>
<webuijsf:staticText escape="false" id="staticText8" style="font-size: 14px" text=" "/>
<h:panelGrid columns="1" id="gridPanel2" style="height: 24px; width: 80%" styleClass="centerBlock" width="456">
<webuijsf:table augmentTitle="false" id="table2" style="width: 100%" styleClass="centerBlock" width="100%">
<webuijsf:tableRowGroup binding="#{ListaPlanos.tableRowGroup2}" id="tableRowGroup2" rows="10"
sourceData="#{SessionBean1.planosSeguimentoDataProvider}" sourceVar="currentRow">
<webuijsf:tableColumn headerText="Data da visita" id="tableColumn4" sort="data_visita">
<webuijsf:staticText id="staticText9" text="#{currentRow.value['data_visita']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Técnico de HST" id="tableColumn5" sort="tecnico_hs_nome">
<webuijsf:staticText id="staticText10" text="#{currentRow.value['tecnico_hs_nome']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Fase" id="tableColumn6" sort="fase">
<webuijsf:staticText id="staticText11" text="#{currentRow.value['fase_nome']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Plano" id="tableColumn11">
<webuijsf:staticText id="staticText20" style="color: #008000;" text="imprimir"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Loja" id="tableColumn14">
<webuijsf:staticText id="staticText23" text="#{currentRow.value['loja_nome']}"/>
</webuijsf:tableColumn>
</webuijsf:tableRowGroup>
</webuijsf:table>
</h:panelGrid>
</h:panelGrid>
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridConcluidos" style="height: 24px; width: 100%" styleClass="gridPlanosList">
<webuijsf:staticText escape="false" id="staticText14" style="font-size: 18px" text="Conclu&amp;iacute;dos"/>
<webuijsf:staticText escape="false" id="staticText15" style="font-size: 14px" text=" "/>
<h:panelGrid columns="1" id="gridPanel4" style="height: 24px; width: 80%" styleClass="centerBlock" width="456">
<webuijsf:table augmentTitle="false" id="table3" style="width: 100%" styleClass="centerBlock" width="100%">
<webuijsf:tableRowGroup binding="#{ListaPlanos.tableRowGroup3}" id="tableRowGroup3" rows="10"
sourceData="#{SessionBean1.planosConcluidosDataProvider}" sourceVar="currentRow">
<webuijsf:tableColumn headerText="Data da visita" id="tableColumn7" sort="data_visita">
<webuijsf:staticText id="staticText16" text="#{currentRow.value['data_visita']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Técnico de HST" id="tableColumn8" sort="tecnico_hs_nome">
<webuijsf:staticText id="staticText17" text="#{currentRow.value['tecnico_hs_nome']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Fase" id="tableColumn9" sort="fase">
<webuijsf:staticText id="staticText18" text="#{currentRow.value['fase_nome']}"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Plano" id="tableColumn12">
<webuijsf:staticText id="staticText21" style="color: #008000;" text="imprimir"/>
</webuijsf:tableColumn>
<webuijsf:tableColumn headerText="Loja" id="tableColumn15">
<webuijsf:staticText id="staticText24" text="#{currentRow.value['loja_nome']}"/>
</webuijsf:tableColumn>
</webuijsf:tableRowGroup>
</webuijsf:table>
</h:panelGrid>
</h:panelGrid>
<h:panelGrid columnClasses="gridColCenter" columns="1" id="gridPanel3" style="height: 24px; width: 100%">
<webuijsf:panelGroup id="groupPanel1">
<webuijsf:staticText escape="false" id="staticText12" text="Software desenvolvido por&amp;nbsp;"/>
<webuijsf:image id="image1" url="/resources/images/logo_evolute_small.png"/>
<webuijsf:staticText escape="false" id="staticText13" text="&amp;nbsp;&amp;copy; 2008"/>
</webuijsf:panelGroup>
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
</webuijsf:form> </webuijsf:form>
</webuijsf:body> </webuijsf:body>
</webuijsf:html> </webuijsf:html>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Document : ViewPlano
Created on : Oct 20, 2008, 10:39:30 AM
Author : lluis
-->
<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1"/>
<f:view>
<webuijsf:page id="page1">
<webuijsf:html id="html1">
<webuijsf:head id="head1">
<webuijsf:link id="link1" url="/resources/stylesheet.css"/>
</webuijsf:head>
<webuijsf:body id="body1" style="-rave-layout: grid">
<webuijsf:form id="form1">
<div style="left: 0px; top: 0px; width: 100%">
<jsp:directive.include file="Header.jspf"/>
</div>
</webuijsf:form>
</webuijsf:body>
</webuijsf:html>
</webuijsf:page>
</f:view>
</jsp:root>

@ -6,6 +6,15 @@
xmlns="http://java.sun.com/xml/ns/javaee" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<application>
<view-handler>viewhandler.CustomViewHandler</view-handler>
<locale-config>
<default-locale>pt</default-locale>
</locale-config>
</application>
<lifecycle>
<phase-listener>phaselistener.MainPhaseListener</phase-listener>
</lifecycle>
<managed-bean> <managed-bean>
<managed-bean-name>SessionBean1</managed-bean-name> <managed-bean-name>SessionBean1</managed-bean-name>
<managed-bean-class>planosactuacao.SessionBean1</managed-bean-class> <managed-bean-class>planosactuacao.SessionBean1</managed-bean-class>
@ -48,4 +57,38 @@
<to-view-id>/ListaPlanos.jsp</to-view-id> <to-view-id>/ListaPlanos.jsp</to-view-id>
</navigation-case> </navigation-case>
</navigation-rule> </navigation-rule>
<navigation-rule>
<from-view-id>/ListaPlanos.jsp</from-view-id>
<navigation-case>
<from-outcome>editar_plano</from-outcome>
<to-view-id>/EditarPlano.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/EditarPlano.jsp</from-view-id>
<navigation-case>
<from-outcome>lista_planos</from-outcome>
<to-view-id>/ListaPlanos.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>Header</managed-bean-name>
<managed-bean-class>planosactuacao.Header</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>Dummy</managed-bean-name>
<managed-bean-class>planosactuacao.Dummy</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>Footer</managed-bean-name>
<managed-bean-class>planosactuacao.Footer</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>ViewPlano</managed-bean-name>
<managed-bean-class>planosactuacao.ViewPlano</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
</faces-config> </faces-config>

@ -73,7 +73,7 @@
</session-timeout> </session-timeout>
</session-config> </session-config>
<welcome-file-list> <welcome-file-list>
<welcome-file>faces/Login.jsp</welcome-file> <welcome-file>faces/Dummy.jsp</welcome-file>
</welcome-file-list> </welcome-file-list>
<error-page> <error-page>
<exception-type>javax.servlet.ServletException</exception-type> <exception-type>javax.servlet.ServletException</exception-type>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

@ -5,6 +5,8 @@
/* Style rules to make Java Server faces Standarad data tables look better */ /* Style rules to make Java Server faces Standarad data tables look better */
body {background-color: #f8f8f0;}
.list-header { .list-header {
background-color: #eeeeee; background-color: #eeeeee;
font-size: larger; font-size: larger;
@ -56,7 +58,42 @@
text-align: right; text-align: right;
} }
.gridCol10{
width: 10%;
}
.gridCol15{
width: 15%;
}
.gridCol20{
width: 20%;
}
.gridCol30{
width: 30%;
}
.gridCol70{
width: 70%;
}
.gridCol80{
width: 80%;
}
.gridCol85{
width: 85%;
}
.gridCol90{
width: 90%;
}
.gridPlanosList{
background-color: #f6f4e8;
border: solid 1px #000000;
}
/* Style rules for message severity levels */ /* Style rules for message severity levels */
.labelMsg{
font-weight : bold;
color: #cc0033;
font-size :14px ;
}
.infoMessage { .infoMessage {
font-size : 13px; font-size : 13px;

Loading…
Cancel
Save