From: Michele Silva Date: Tue, 24 Jan 2012 21:06:55 +0000 (-0200) Subject: Changed controllers to handle table row edit. X-Git-Url: http://200.18.67.61/gitweb/?p=simdecs.git;a=commitdiff_plain;h=a496c612a257cf66fd14edd13a0837cd2b683990 Changed controllers to handle table row edit. --- diff --git a/src/java/org/ufcspa/simdecs/bn/entity/Node.java b/src/java/org/ufcspa/simdecs/bn/entity/Node.java index 80cd40c..5f87808 100644 --- a/src/java/org/ufcspa/simdecs/bn/entity/Node.java +++ b/src/java/org/ufcspa/simdecs/bn/entity/Node.java @@ -23,7 +23,7 @@ public class Node implements Serializable { private NodeType nodeType; - private NodeType nodeRole; + private NodeRole nodeRole; private Integer time = 0; @@ -59,11 +59,11 @@ public class Node implements Serializable { this.nodeType = nodeType; } - public NodeType getNodeRole() { + public NodeRole getNodeRole() { return nodeRole; } - public void setNodeRole(NodeType nodeRole) { + public void setNodeRole(NodeRole nodeRole) { this.nodeRole = nodeRole; } diff --git a/src/java/org/ufcspa/simdecs/bn/ui/AnswerController.java b/src/java/org/ufcspa/simdecs/bn/ui/AnswerController.java index 3045d8c..3fee5e8 100644 --- a/src/java/org/ufcspa/simdecs/bn/ui/AnswerController.java +++ b/src/java/org/ufcspa/simdecs/bn/ui/AnswerController.java @@ -1,15 +1,10 @@ package org.ufcspa.simdecs.bn.ui; -import org.ufcspa.simdecs.bn.entity.Answer; -import org.ufcspa.simdecs.bn.ui.util.JsfUtil; -import org.ufcspa.simdecs.bn.ui.util.PaginationHelper; -import org.ufcspa.simdecs.bn.jpa.AnswerJpaController; - import java.io.Serializable; import java.util.ResourceBundle; import javax.annotation.Resource; +import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; @@ -20,9 +15,14 @@ import javax.faces.model.SelectItem; import javax.persistence.EntityManagerFactory; import javax.persistence.PersistenceUnit; import javax.transaction.UserTransaction; +import org.primefaces.event.RowEditEvent; +import org.ufcspa.simdecs.bn.entity.Answer; +import org.ufcspa.simdecs.bn.jpa.AnswerJpaController; +import org.ufcspa.simdecs.bn.ui.util.JsfUtil; +import org.ufcspa.simdecs.bn.ui.util.PaginationHelper; @ManagedBean(name = "answerController") -@SessionScoped +@ApplicationScoped public class AnswerController implements Serializable { @Resource @@ -38,6 +38,11 @@ public class AnswerController implements Serializable { public AnswerController() { } + public void rowEditListener(RowEditEvent event) throws Exception { + Answer answer = (Answer) event.getObject(); + getJpaController().edit(answer); + } + public Answer getSelected() { if (current == null) { current = new Answer(); @@ -171,6 +176,7 @@ public class AnswerController implements Serializable { public DataModel getItems() { if (items == null) { + getPagination(); items = new ListDataModel(getJpaController().findAnswerEntities()); } return items; diff --git a/src/java/org/ufcspa/simdecs/bn/ui/BayesianNetworkController.java b/src/java/org/ufcspa/simdecs/bn/ui/BayesianNetworkController.java index 019a90f..c2ce200 100644 --- a/src/java/org/ufcspa/simdecs/bn/ui/BayesianNetworkController.java +++ b/src/java/org/ufcspa/simdecs/bn/ui/BayesianNetworkController.java @@ -1,15 +1,10 @@ package org.ufcspa.simdecs.bn.ui; -import org.ufcspa.simdecs.bn.entity.BayesianNetwork; -import org.ufcspa.simdecs.bn.ui.util.JsfUtil; -import org.ufcspa.simdecs.bn.ui.util.PaginationHelper; -import org.ufcspa.simdecs.bn.jpa.BayesianNetworkJpaController; - import java.io.Serializable; import java.util.ResourceBundle; import javax.annotation.Resource; +import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; @@ -20,9 +15,14 @@ import javax.faces.model.SelectItem; import javax.persistence.EntityManagerFactory; import javax.persistence.PersistenceUnit; import javax.transaction.UserTransaction; +import org.primefaces.event.RowEditEvent; +import org.ufcspa.simdecs.bn.entity.BayesianNetwork; +import org.ufcspa.simdecs.bn.jpa.BayesianNetworkJpaController; +import org.ufcspa.simdecs.bn.ui.util.JsfUtil; +import org.ufcspa.simdecs.bn.ui.util.PaginationHelper; @ManagedBean(name = "bayesianNetworkController") -@SessionScoped +@ApplicationScoped public class BayesianNetworkController implements Serializable { @Resource @@ -38,6 +38,11 @@ public class BayesianNetworkController implements Serializable { public BayesianNetworkController() { } + public void rowEditListener(RowEditEvent event) throws Exception { + BayesianNetwork bn = (BayesianNetwork) event.getObject(); + getJpaController().edit(bn); + } + public BayesianNetwork getSelected() { if (current == null) { current = new BayesianNetwork(); @@ -171,6 +176,7 @@ public class BayesianNetworkController implements Serializable { public DataModel getItems() { if (items == null) { + getPagination(); items = new ListDataModel(getJpaController().findBayesianNetworkEntities()); } return items; diff --git a/src/java/org/ufcspa/simdecs/bn/ui/NodeController.java b/src/java/org/ufcspa/simdecs/bn/ui/NodeController.java index f8f82d3..fa1145f 100644 --- a/src/java/org/ufcspa/simdecs/bn/ui/NodeController.java +++ b/src/java/org/ufcspa/simdecs/bn/ui/NodeController.java @@ -1,15 +1,10 @@ package org.ufcspa.simdecs.bn.ui; -import org.ufcspa.simdecs.bn.entity.Node; -import org.ufcspa.simdecs.bn.ui.util.JsfUtil; -import org.ufcspa.simdecs.bn.ui.util.PaginationHelper; -import org.ufcspa.simdecs.bn.jpa.NodeJpaController; - import java.io.Serializable; import java.util.ResourceBundle; import javax.annotation.Resource; +import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; @@ -21,9 +16,13 @@ import javax.persistence.EntityManagerFactory; import javax.persistence.PersistenceUnit; import javax.transaction.UserTransaction; import org.primefaces.event.RowEditEvent; +import org.ufcspa.simdecs.bn.entity.Node; +import org.ufcspa.simdecs.bn.jpa.NodeJpaController; +import org.ufcspa.simdecs.bn.ui.util.JsfUtil; +import org.ufcspa.simdecs.bn.ui.util.PaginationHelper; @ManagedBean(name = "nodeController") -@SessionScoped +@ApplicationScoped public class NodeController implements Serializable { @Resource @@ -177,6 +176,7 @@ public class NodeController implements Serializable { public DataModel getItems() { if (items == null) { + getPagination(); items = new ListDataModel(getJpaController().findNodeEntities()); } return items; diff --git a/src/java/org/ufcspa/simdecs/bn/ui/QuestionController.java b/src/java/org/ufcspa/simdecs/bn/ui/QuestionController.java index 8c53542..64ed3bc 100644 --- a/src/java/org/ufcspa/simdecs/bn/ui/QuestionController.java +++ b/src/java/org/ufcspa/simdecs/bn/ui/QuestionController.java @@ -1,15 +1,10 @@ package org.ufcspa.simdecs.bn.ui; -import org.ufcspa.simdecs.bn.entity.Question; -import org.ufcspa.simdecs.bn.ui.util.JsfUtil; -import org.ufcspa.simdecs.bn.ui.util.PaginationHelper; -import org.ufcspa.simdecs.bn.jpa.QuestionJpaController; - import java.io.Serializable; import java.util.ResourceBundle; import javax.annotation.Resource; +import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; -import javax.faces.bean.SessionScoped; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; @@ -20,9 +15,14 @@ import javax.faces.model.SelectItem; import javax.persistence.EntityManagerFactory; import javax.persistence.PersistenceUnit; import javax.transaction.UserTransaction; +import org.primefaces.event.RowEditEvent; +import org.ufcspa.simdecs.bn.entity.Question; +import org.ufcspa.simdecs.bn.jpa.QuestionJpaController; +import org.ufcspa.simdecs.bn.ui.util.JsfUtil; +import org.ufcspa.simdecs.bn.ui.util.PaginationHelper; @ManagedBean(name = "questionController") -@SessionScoped +@ApplicationScoped public class QuestionController implements Serializable { @Resource @@ -38,6 +38,11 @@ public class QuestionController implements Serializable { public QuestionController() { } + public void rowEditListener(RowEditEvent event) throws Exception { + Question question = (Question) event.getObject(); + getJpaController().edit(question); + } + public Question getSelected() { if (current == null) { current = new Question(); @@ -171,6 +176,7 @@ public class QuestionController implements Serializable { public DataModel getItems() { if (items == null) { + getPagination(); items = new ListDataModel(getJpaController().findQuestionEntities()); } return items; diff --git a/web/bn.xhtml b/web/bn.xhtml index e4df77e..147a7d5 100644 --- a/web/bn.xhtml +++ b/web/bn.xhtml @@ -17,12 +17,12 @@ + fileUploadListener="#{fileUploadController.handleFileUpload}" + image="/img/bn/browse.png" customUI="true" + multiple="true" label="Selecione..." allowTypes="*.xml;" description="Images" + update="tabView"/> Enviar Redes Bayesianas + style="font-weight:bold;color:#616D7E">Enviar Redes Bayesianas @@ -78,7 +78,6 @@ - @@ -132,7 +131,7 @@ @@ -158,7 +157,7 @@ - +

@@ -206,7 +205,7 @@
- +