0
votes

Hi I´m doing a document managment system with primefaces 5. y made a search feature, the search buton is located in the template in the left side menu, the results of the search are showed in the center unit layout. the searching feature run good if I search , but when Im whatching the results and try to search again the results are not refreshed

my template file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">

<f:view contentType="text/html">
    <h:head>
        <f:facet name="first">
            <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
            <title>Sysged</title>
            response.setHeader("Content-Disposition", "inline");
        </f:facet>
    </h:head>

    <h:body>

        <p:layout fullPage="true">

            <p:layoutUnit position="north" size="100" resizable="true" closable="true"collapsible="true">     
                <h:graphicImage library="images" name="logo.png" ></h:graphicImage>
                 <h:graphicImage library="images" name="footer.jpg" ></h:graphicImage>
            </p:layoutUnit>



            <p:layoutUnit position="west" size="270" header="Main menu"   collapsible="true" resizable="true">
            <h:form>
            <p:menu>

                <p:submenu label="Import">
                    <p:menuitem value="Local" icon="ui-icon-disk"   url="UIlocalImport.xhtml"/>
                    <p:menuitem value="URL" icon="ui-icon-arrowrefresh-1-w"
                        url="UIlurlImport.xhtml" />
                </p:submenu>
                <p:submenu label="Search">
                    <p:menuitem>
                        <h:panelGrid columns="3" cellpadding="5"
                            style="margin-bottom:10px">

                            <p:inputText id="paramSearch" value="# {documentBean.paramSearch}"
                                required="true" label="Keyword"  />
                            <p:watermark for="paramSearch" value="Search with a keyword"
                                id="watermark" />
                        </h:panelGrid>

                        <p:commandButton action="#{documentBean.search2}"  value="Search"  update=":content"/>

                    </p:menuitem>

                </p:submenu>



                <p:submenu label="Administrator">
                    <p:menuitem value="Category manager" url="UIadminCategories.xhtml">
                    </p:menuitem>

                    <p:submenu label="Close sesion">
                        <p:menuitem>
                            <p:commandButton action="#{userBean.logout}" value="exit"
                                icon="ui-icon-close" />
                        </p:menuitem>
                    </p:submenu>

                </p:submenu>

            </p:menu>
            </h:form>
            </p:layoutUnit>

            <p:layoutUnit position="center">
            <h:panelGroup id="content" >
                <ui:insert  name="UIlocalImport" ></ui:insert>

                <ui:insert name="Uisearch"></ui:insert>
                <ui:insert name="UiadminCategories"></ui:insert>
                <ui:insert name="UIlurlImport"></ui:insert>
                </h:panelGroup>
            </p:layoutUnit>

        </p:layout>

    </h:body>

   </f:view>
 </html>

One of the xhtml where I can search

<ui:define name="UIlurlImport">

    <h:panelGrid columns="1" cellpadding="5">
        <h:form>
            <p:growl id="messages" showDetail="true" />

            <p:panel id="panel" header="URL import" syle="vertical-align:top;">

                <p:outputLabel for="url" value="URL" />
                <p:inputText id="url" value="#{urlImportBean.url}" required="true"
                    label="URL">
                    <f:validateLength minimum="5" />
                    <p:ajax update="msgOutput" event="keyup" />
                </p:inputText>
                <p:message for="category" id="msgOutput" display="icon" />
                <p:outputLabel for="category" value="Category" style="padding:10px" />
                <p:selectOneMenu id="category" value="#{urlImportBean.category}"
                    label="category" filter="true">
                    <f:selectItems value="#{categorieBean.items}" id="selectCategoy" />
                    <p:ajax />
                </p:selectOneMenu>
                <p:commandButton value="Import" update="messages"
                    icon="ui-icon-home" action="#{urlImportBean.importImage}" />

            </p:panel>
        </h:form>


     </h:panelGrid>
    </ui:define>
</ui:composition>

where the results are displayed but if I search, nothing is updated

<ui:define name="Uisearch">
    <h:outputScript library="js" name="pdfobject.js" target="head" />
    <h:panelGrid columns="1" cellpadding="2">

        <p:panel id="panelResults" header="Results">

            <p:dataList value="#{documentBean.documentsMatched}" var="document"
                type="definition">

                <h:outputLink value="file/#{document.pdfPath}" target="_blank">view  document</h:outputLink>   
                <div id="pdf2">
                    <object data='file/#{document.pdfPath}' type='application/pdf'
                        width='1000px' height='400px'>

                        <p>
                            It appears your Web browser is not configured to display  PDF
                            files. No worries, just <a href='file/#  document.pdfPath}'>click
                                here to download the PDF file.</a>
                        </p>

                    </object>
                </div>


            </p:dataList>

         </p:panel>

     </h:panelGrid>

  </ui:define>

</ui:composition>

the method that the boton calls

    public String search2()
 {
    System.out.println("searching "+ paramSearch);

    DocumentModel doc = new DocumentModel();
    this.setDocumentsMatched(doc.searchText(this.paramSearch));
    System.out.println("search");
    return "UIsearch";

}

Thanks in advance for your time and aswers

1
Im not sure if I understand wath do you mean, but the console doesn´t show any errorJuan Camilo Mejia
no man the console doesnt´t show error. I know that I have a jsf mistake, but don´t know why have that behaviorJuan Camilo Mejia
yes you are rigth is a pasting error, I´m editing the question to solve thatJuan Camilo Mejia
Man that´s working!! Thakyou so muchJuan Camilo Mejia

1 Answers

-1
votes

Use a redirect from the action method:

return "UIsearch?faces-redirect=true"; 

I'm not sure why its working, but my guess is that the browser was caching the page and is now forced to reload.