I am sending some variables from an .xhtml page to a controller which sends data to another page that has another controller that handles the data of that page I have tried to use the setters and getters. the problem is that I don't really know to do with @PostConstruct.
XHTML file
<h:form id="frmStart">
<p:growl id="growl" sticky="true" showDetail="true" />
<p:panel id="pnlDatos">
<p:dataTable id="tblObjeto" var="object"
value="#{parentControlador.listObjects}"
widgetVar="tblObjeto"
emptyMessage="No hay datos">
<f:facet name="header">
Objetos
</f:facet>
<p:column headerText="Contar" width="20">
<p:commandButton class="pi pi-list" id="openDialogContar" value="Ver"
action="#{parentControlador.FindItems(object)}"
/>
</p:column>
</p:dataTable>
</p:panel>
</h:form>
ParentControlador controller code
@Inject Item item;
public String FindItems(ObjectParent objectParent) {
String type="";
String result="";
//variable that i am going to send
ItemControlador itemControlador = new ItemControlador();
itemControlador.setCorte(objectParent);
try {
if(item.listarItemsA(objectParent.getCorte_id()).isEmpty()){
this.listaItems = item.listarItemsB(objectParent.getCorte_id());
type = "A";
}else{
this.listaItems = item.listarItemA(objectParent.getCorte_id());
type = "B";
}
this.objeto = objectParent;
result = type == "A"? "A.xhtml":"B.xhtml";
} catch (Exception e) {
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error",
"The objectParent doesn't have items "+e.getMessage()));
}
return result;
}
This is the controller that handles the view for "A.xhtml", "B.xhtml"Item
@PostConstruct
private Parent parent;
public void init() {
//From what I see, this is executed when a .xhtml page is using the controller to retrieve the dataTable
//
if(item.listarItemsB(objectParent.getCorte_id()).isEmpty()){
this.listaObjetos = item.listarItemA(objectParent.getCorte_id());
}else{
this.listaObjetos = item.listarItemsA(objectParent.getCorte_id());
}
}
public Parent getCorte() {
return corte;
}
public void setCorte(Parent parent) {
this.parent = parent;
}
How do I send data form an xhtml view that handles one controller X to view the data, send to another xhtml page that uses another controller Y, and show in the other page that uses Y controller to view the data of the data sent?