简体   繁体   English

从菜单栏primefaces 3和jsf 2 ajax更新内容页面

[英]update content page from menubar primefaces 3 and jsf 2 ajax

well first ill explain what im tryng to do, i have a index.xhtml page where i include menu.xhtml with a menubar of primefaces, in menu.xhtml in have a panel id=contenido where i want to update depending of the menuitem clicked, i already get update that panel but the problem is when i update to another page for example in default is home.xhtml and i update to enviarsol.xhtml then the command button from enviarsol.xhtml is not working, im new at this and i already tried some different ways of updating the panel, im thinking that the problem is that the bean of enviarsol.xhtml is not managed or something like that,also im doing this way because i want to refresh only that panel and not all the page, someone help me please. 首先,我要解释一下我想做什么,我有一个index.xhtml页面,其中包含带有素面菜单栏的menu.xhtml,在menu.xhtml中,有一个面板ID = contenido,我要根据单击的菜单项进行更新,我已经更新了该面板,但是问题是当我更新到另一个页面(例如默认情况下是home.xhtml)并且我更新到enviarsol.xhtml时,enviarsol.xhtml的命令按钮不起作用,即时通讯在这个和我上已经尝试了几种更新面板的方法,我认为问题是enviarsol.xhtml的bean没有被管理或类似的东西,我也这样做是因为我只想刷新该面板而不是刷新整个页面,有人请帮我。

index.xhtml: index.xhtml:

<h:form>
    <img src="resources/homeheader.jpg" width="300" height="113" alt="homeheader"/>
    <div style="background-color: white">
    <img src="resources/Logos.jpg" width="1024" height="166" alt="homeheader"/>
    </div>
     <p:panel id="centerpage" >
        <ui:include src="WEB-INF/menu.xhtml"/>
    </p:panel>
</h:form>`

menu.xhtml: menu.xhtml:

<p:menuitem value="Contactos" icon="ui-icon-arrowreturnthick-1-w" actionListener="#{bnmenu.btnEditarContacto(e)}" update="contenido"/>  
<p:panel id="contenido" >
    <ui:include  src="#{bnmenu.url}"/>
</p:panel>

bnmenu.java: bnmenu.java:

private String url;

public bnmenu() {
    url="home.xhtml";
}

 public void btnEditarContacto(ActionEvent e)
{
  url="enviarsol.xhtml";
}

home.xhtml: home.xhtml:

<p:panelGrid columns="2" style="border-width: 0px">
        <p:commandButton  value="Consultar" actionListener="#{bnhome.btnlogin(e)}" update="txt1"/>
    <p:inputText id="txt1" value="#{bnhome.txtUsuario}"/>
    </p:panelGrid>

enviarsol.xhtml: enviarsol.xhtml:

<p:panelGrid columns="2" style="border-width: 0px">
        <p:outputLabel for="txtcorreo" value="Correo: "/>
        <p:inputText id="txtcorreo" value="#{bnSolicitud.correo}"/>
         <p:outputLabel for="txtmensaje" value="Mensaje: "/>
         <p:inputText id="txtmensaje" value="#{bnSolicitud.mensaje}"/>
         <p:commandButton  value="Enviar" actionListener="#{bnSolicitud.btnSolicitar(e)}" update="messages"/>        
</p:panelGrid>`

i included this: 我包括这个:

<context-param> 
    <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name> 
    <param-value>false</param-value> 
</context-param>

and now it is working but i dont know what more effects will this cause well now it works but only once when i click in commandbutton from enviarsol.xhtml Finally it appears working fine, i changed @RequestScoped by @SessionScoped in bnmenu 现在它正在工作,但是我不知道这会导致什么效果,但是现在只能工作一次,但是当我单击enviarsol.xhtml中的commandbutton时,它一次只能工作正常,我在bnmenu中将@RequestScoped更改为@SessionScoped

Are you sure that you really want ajax navigation? 您确定您确实想要Ajax导航吗? It is very frustrating for a user not being able to use the browsers urlfield or navigation buttons, and it will be harder for you to code aswell. 对于无法使用浏览器的urlfield或导航按钮的用户来说,这非常令人沮丧,并且您也很难编写代码。 Consider transforming index.xhtml into a template file as described at http://www.mkyong.com/jsf2/jsf-2-templating-with-facelets-example and using normal navigation. 考虑按照http://www.mkyong.com/jsf2/jsf-2-templating-with-facelets-example中的描述将index.xhtml转换为模板文件,并使用常规导航。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM