Reputation: 301
I would like to know how I can change a view since a bean, and it is my code:
principal.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<link rel="shortcut icon" type="image/x-icon" href="/resources/images/logoconsorcio.ico"/>
<f:facet name="first">
<h:outputStylesheet name="css/default.css"/>
<h:outputScript name="scripts/scripts.js" />
<title>Consorcio JM</title>
</f:facet>
</h:head>
<h:body>
<p:layout fullPage="true">
<ui:include src="/pages/main/session_time_out.xhtml"/>
<!-- Header Panel-->
<p:layoutUnit position="north" size="40" resizable="true" closable="true"
collapsible="true" collapseSize="20">
<ui:include src="/pages/main/header.xhtml" />
</p:layoutUnit>
<!-- Tree Panel-->
<p:layoutUnit position="west" size="205" collapsible="true" header="Menu">
<ui:include src="/pages/main/page_menu.xhtml" />
</p:layoutUnit>
<!-- Content Panel-->
<p:layoutUnit id="idCenterLayout" position="center" >
<p:outputPanel id="idCentroPagina">
<ui:include src="#{menuBean.paginaCentral}"/>
</p:outputPanel>
</p:layoutUnit>
</p:layout>
</h:body>
in #{menuBean.paginaCentral}
I put the path of the a view like /pages/logistica/movimientos/orden_ingreso/orden_ingreso.xhtml
orden_ingreso.xhtml
<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" >
<h:form id="idFormOrdenIngreso" onkeypress="if (event.keyCode == 13) { return false; }">
<p:growl id="idGrowlOI" showDetail="true" life="2500" for="keyOrdenIngreso" globalOnly="true"/>
<p:panel header="Orden de Ingreso" styleClass="texto-panel"/>
<ui:include src="/pages/logistica/movimientos/orden_ingreso/toolbar_orden_ingreso.xhtml"/>
<ui:include src="#{ordenIngresoBean.pathBodyOrdenIngreso}"/>
</h:form>
</ui:composition>
OrdenIngresoBean.java
@ManagedBean(name = "ordenIngresoBean")
@SessionScoped
public class OrdenIngresoBean implements Serializable {
private static final long serialVersionUID = 1L;
private final String strBusiness = "OrdenIngresoBO";
private String pathBodyOrdenIngreso;
private OrdenIngresoBO ordenIngresoBO;
private OrdenIngresoUtil oiu;
private OrdenIngresoDTO oiVista;
private final HttpServletRequest httpServletRequest;
private final FacesContext facesContext;
private final Empresa empresa;
private final UsuarioLO usuario;
public OrdenIngresoBean () {
facesContext = FacesContext.getCurrentInstance();
httpServletRequest = (HttpServletRequest)facesContext.getExternalContext().getRequest();
empresa = (Empresa)httpServletRequest.getSession().getAttribute("empresaSession");
usuario = (UsuarioLO)httpServletRequest.getSession().getAttribute("usuario");
initBusiness();
oiu = new OrdenIngresoUtil();
oiu.setVista("LISTA");
oiVista = new OrdenIngresoDTO();
pathBodyOrdenIngreso = "/pages/logistica/movimientos/orden_ingreso/lista_orden_ingreso.xhtml";
}
private void initBusiness() {
ServletContext servletContext = (ServletContext)facesContext.getExternalContext().getContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
ordenIngresoBO = (OrdenIngresoBO)ctx.getBean(strBusiness);
}
...
public void actualizarVista() {
if(oiu.getIdEmisorComprobante().intValue() < 0){
ProveedorBean proveedorBean = new ProveedorBean();
proveedorBean.limpiarProveedorVista();
proveedorBean.setPathBodyProveedor("/pages/logistica/proveedor/crear_proveedor.xhtml");
RequestContext.getCurrentInstance().update(":idCentroPagina");
}
}
in "actualizarVista" I want to change to other view, to /pages/logistica/proveedor/crear_proveedor.xhtml
that is of another bean, but to do it I have to update the component "idCentroPagina" that is in principal.xhtml
. I works with RequestContext.getCurrentInstance().update(":idCentroPagina")
, but it doesn't work.
Upvotes: 0
Views: 909
Reputation: 1885
Remove the leading colon. The leading colon is only usable when you are inside a naming container. So change
RequestContext.getCurrentInstance().update(":idCentroPagina")
into
RequestContext.getCurrentInstance().update("idCentroPagina")
Upvotes: 1