我想知道如何更改bean以来的视图,这是我的代码:
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>
在
#{menuBean.paginaCentral}
中的我将视图的路径设为/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&#34; actualizarVista&#34;我想改为其他视图,改为另一个bean的/pages/logistica/proveedor/crear_proveedor.xhtml
,但为了做到这一点,我必须更新组件&#34; idCentroPagina&#34;在principal.xhtml
中。我与RequestContext.getCurrentInstance().update(":idCentroPagina")
合作,但它不起作用。
答案 0 :(得分:1)
删除前导冒号。只有在命名容器内时,前导冒号才可用。所以改变
RequestContext.getCurrentInstance().update(":idCentroPagina")
进入
RequestContext.getCurrentInstance().update("idCentroPagina")