jsf - How to pass an object from a ViewScoped ManagedBean to another one? -


i'm starting work primefaces 5.2, ide eclipse luna 4.4.2, java 1.7 , jsf 2.1.

i have view datatable, there's column called holding 2 commandbuttons, 1 editing , 1 deleting. when edit button pressed show modal dialog filled external xhtml file has own managedbean.

i want pass selected object datatable external xhtml's managedbean fields filled information it.

my excepciones.xhtml looks this:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:f="http://java.sun.com/jsf/core"     xmlns:ui="http://java.sun.com/jsf/facelets"     xmlns:p="http://primefaces.org/ui"     template="/web-inf/facelets/templates/plantillaprincipal.xhtml">     <ui:define name="mainbody">         <h:form id="form">             <p:datatable var="excepcion" value="#{excepcionesview.lazymodel}"                 paginator="true" rows="10" paginatorposition="bottom"                 paginatortemplate="{rowsperpagedropdown} {firstpagelink} {previouspagelink} {currentpagereport} {nextpagelink} {lastpagelink}"                 rowsperpagetemplate="5,10,15" selectionmode="single"                 selection="#{excepcionesview.selectedexcepcion}" id="excepciontable"                 lazy="true">                 <p:ajax event="rowselect" listener="#{excepcionesview.onrowselect}"                     update=":form:excepciondetail"                     oncomplete="pf('excepciondialog').show()" />                 <p:column headertext="id" sortby="#{excepcion.id}">                     <h:outputtext value="#{excepcion.id}" />                 </p:column>                 ....                 <p:column headertext="acciones">                     <p:commandbutton icon="ui-icon-pencil" action="#{excepcionesview.viewexcepcioneditar}" >                         <f:setpropertyactionlistener value="#{excepcion}"                                         target="#{excepcionesview.selectedexcepcion}" />                     </p:commandbutton>                     ...                 </p:column>             </p:datatable>             ...         </h:form>     </ui:define> </ui:composition> 

it's managedbean:

@managedbean(name="excepcionesview") @viewscoped public class excepcionesview  implements serializable{      private lazydatamodel<excepcion> lazymodel;      private excepcion selectedexcepcion;      @managedproperty("#{excepcionservice}")     private excepcionservice service;      @postconstruct     public void init() {         lazymodel = new excepciondatamodel(service.createexcepciones(200));     }      public void viewexcepcioneditar() {              facescontext.getcurrentinstance().getexternalcontext().getrequestmap().put("selectedexcepcion", selectedexcepcion);          map<string,object> options = new hashmap<string, object>();         options.put("modal", true);         options.put("draggable", false);         options.put("resizable", false);         options.put("contentheight", 320);          requestcontext.getcurrentinstance().opendialog("excepcionedicion", options, null);     }       ... } 

as can see, call method viewexcepcioneditar store selected row , display dialog load excepcionedicion.xhtml:

<html xmlns="http://www.w3.org/1999/xhtml"     xmlns:p="http://primefaces.org/ui"     xmlns:ui="http://java.sun.com/jsf/facelets"     xmlns:f="http://java.sun.com/jsf/core"     xmlns:h="http://java.sun.com/jsf/html"> <h:head>         <h:outputstylesheet library="theme" name="css/style.css" /> </h:head> <h:body>     <h:form id="productoeditarform">             <p:panelgrid id="productoeditargrid" styleclass="tablasinborde" columns="2" >                 <p:outputlabel for="nombretxt"  value="nombre: "/>                 <h:inputtext id="nombretxt" value="#{editarexcepcionview.excepcion.nombre}" />                 <p:outputlabel for="ldctxt" value="línea de crédito: "/>                 <h:inputtext id="ldctxt" value="#{editarexcepcionview.excepcion.lineacredito}"/>             </p:panelgrid>              <p:commandbutton id="aceptarbtn"    value="aceptar" />             <p:commandbutton id="cancelarbtn"   value="cancelar" />     </h:form> </h:body> </html> 

and it's bean contains:

@managedbean(name="editarexcepcionview") @viewscoped public class editarexcepcionview implements serializable{     private string excepcionid;     private excepcion excepcion;      public editarexcepcionview(){          system.out.println("hey");         excepcion = (excepcion) facescontext.getcurrentinstance().getexternalcontext().getrequestmap().get("selectedexcepcion");         system.out.println("excepcion " + excepcion.getnombre());     }     .... } 

in constructor try read parameter placed comes null.

how can pass object between these beans information said object can read , displayed on modal dialog?


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -