0

I'm having problems in update of my panelgrid columns Below is my code in my xhtml file, datatable in treatmenthistory.xhtml is updated fine but searchresult.xhtml is not updated and you have to refresh the whole page to make it updated. So what can be the problem, two xhtml pages look like same, they both have datatables.

        <h:form>
            <p:panelGrid cellpadding="0" styleClass="results">
                <p:row>
                    <p:column colspan="1">
                        <ui:include src="/searchresult.xhtml" />
                    </p:column>
                    <p:column colspan="1">
                        <ui:include src="/treatmenthistory.xhtml" />
                    </p:column>
                </p:row>
            </p:panelGrid>
        </h:form>

users:

<ui:composition xmlns="w3.org/1999/xhtml" xmlns:f="java.sun.com/jsf/core"  xmlns:h="java.sun.com/jsf/html" xmlns:ui="java.sun.com/jsf/facelets" xmlns:p="primefaces.org/ui">
    <p:dataTable id="users" var="user1" styleClass="searchResult"
        widgetVar="userTable" value="#{KisiInfoProcess.kisiList}"
        emptyMessage="#{msg['noRecordsFound']}" dynamic="true"
        paginator="true" rows="10" rowKey="#{user1.tcidno}"
        rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'highlight1' : 'highlight2'}"
        rowIndexVar="rowIndex" selection="#{KisiInfoProcess.selectedOS}"
        selectionMode="single" paginatorPosition="bottom">
        <p:ajax event="rowSelect" listener="#{KisiInfoProcess.onRowSelect}"
            process="@this" update=":form:users2" />
        <f:facet name="header">
            <h:outputText value="#{msg['searchResultsPanel']}" />
        </f:facet>
        <p:column id="kisiid" sortBy="#{user1.kisiid}"
            filterBy="#{user1.kisiid}" styleClass="kisiid">

            <h:outputText value="#{user1.kisiid}" />
            <p:watermark for="@(.kisiid)" value="#{msg['protocolNo']}" />

        </p:column>
        <p:column id="ad" sortBy="#{user1.ad}" filterBy="#{user1.ad}"
            styleClass="ad">

            <h:outputText value="#{user1.ad}" />
            <p:watermark for="@(.ad)" value="#{msg['name']}" />

        </p:column>
        <p:column id="soyad" sortBy="#{user1.soyad}"
            filterBy="#{user1.soyad}" styleClass="soyad">

            <h:outputText value="#{user1.soyad}" />
            <p:watermark for="@(.soyad)" value="#{msg['surname']}" />

        </p:column>
        <p:column sortBy="#{user1.tcidno}" styleClass="tcidno"
            filterBy="#{user1.tcidno}" id="tcidno">

            <h:outputText value="#{user1.tcidno}" />
            <p:watermark for="@(.tcidno)" value="#{msg['identityNumber']}" />

        </p:column>
        <p:column sortBy="#{user1.ogrencino}" styleClass="ogrencino"
            filterBy="#{user1.ogrencino}" id="ogrencino">

            <h:outputText value="#{user1.ogrencino}" />
            <p:watermark for="@(.ogrencino)" value="#{msg['studentNumber']}" />

        </p:column>
        <p:column sortBy="#{user1.dogumtarihi}" styleClass="dogumtarihi"
            filterMatchMode="contains" filterBy="#{user1.dogumtarihi}"
            id="dogumtarihi">

            <h:outputText value="#{user1.dogumtarihi}">
                <f:convertDateTime type="date" pattern="dd/MM/yyyy" />
            </h:outputText>
            <p:watermark for="@(.dogumtarihi)" value="#{msg['dateOfBirth']}" />

        </p:column>

        <f:facet name="footer">
            <p:commandButton id="modalDialogButton" style="min-width:8%"
                value="#{msg['newPatient']}"
                action="#{KisiInfoProcess.resetHastakayit}" update=":form:basic"
                oncomplete="PF('dlg2').show()" />
        </f:facet>
    </p:dataTable>
</ui:composition>

users2:

<ui:composition xmlns="w3.org/1999/xhtml" xmlns:f="java.sun.com/jsf/core" xmlns:h="java.sun.com/jsf/html" xmlns:ui="java.sun.com/jsf/facelets" xmlns:p="primefaces.org/ui">
    <p:growl id="msgs" showDetail="true" />
    <p:dataTable id="users2" var="user" styleClass="patienthistory"
        emptyMessage="#{msg['noRecordsFound']}" widgetVar="muayeneTable"
        value="#{KisiInfoProcess.muayeneList}" dynamic="true"
        selection="#{KisiInfoProcess.selectedOS}" paginator="true" rows="10"
        rowKey="#{user.muayeneid2}"
        rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'highlight1' : 'highlight2'}"
        rowIndexVar="rowIndex" selectionMode="single"
        paginatorPosition="bottom">
        <p:ajax event="rowSelect"
            listener="#{KisiInfoProcess.onRowSelectMuayene}" process="@this"
            update=":form:panel2,:form:protocolNo"
            oncomplete="PF('dlg3').show()" />
        <f:facet name="header">
            <h:outputText value="#{msg['treatmentHistoryPanel']}" />
        </f:facet>
        <p:column sortBy="#{user.muayeneid2}" styleClass="muayeneid"
            filterBy="#{user.muayeneid2}" id="muayeneno2">

            <h:outputText value="#{user.muayeneid2}" style="width:5%" />
            <p:watermark for="@(.muayeneid)" value="#{msg['treatmentNo']}" />

        </p:column>
        <p:column sortBy="#{user.muayeneturuid2}" styleClass="muayeneturu"
            filterBy="#{user.muayeneturuid2}" id="muayeneturuid2">

            <h:outputText value="#{user.muayeneturuid2}" style="width:5%" />
            <p:watermark for="@(.muayeneturu)" value="#{msg['treatmentType']}" />

        </p:column>
        <p:column sortBy="#{user.tarih}" styleClass="tarih"
            filterMatchMode="contains" filterBy="#{user.tarih}" id="tarih">

            <h:outputText value="#{user.tarih}" style="width:5%">
                <f:convertDateTime type="both" pattern="dd/MM/yyyy - HH:mm" />
            </h:outputText>
            <p:watermark for="@(.tarih)" value="#{msg['treatmentDate']}" />

        </p:column>
        <p:column sortBy="#{user.islemiyapan}" styleClass="islemiyapan"
            filterMatchMode="contains" filterBy="#{user.islemiyapan}"
            id="userid2">

            <h:outputText value="#{user.islemiyapan}" style="width:5%" />
            <p:watermark for="@(.islemiyapan)" value="#{msg['treatmentDoctor']}" />

        </p:column>
        <p:column id="tanivarmi">

            <h:outputText style="width:5%" value="#{user.taniVarmi2}" />

        </p:column>
        <f:facet name="footer">
            <p:commandButton id="modalDialogButton2" style="min-width:8%"
                rendered="#{KisiInfoProcess.kisiSelected}"
                value="#{msg['newTreatment']}"
                action="#{KisiInfoProcess.resetMuayene}" update=":form:basic2"
                oncomplete="PF('dlg3').show()" />
        </f:facet>
    </p:dataTable>
</ui:composition>
coderxyz24
  • 11
  • 2
  • 11

2 Answers2

1
<p:panelGrid cellpadding="0" styleClass="results" id="someID">

And then when you do some action to change your dataTable's, set Update="someID" to refresh both pages. SomeID is your full id "someNameContainer:someID"

If you have one action to update both tables don't forget tu put process="idfirstTatbe idSecondTable" to process them both before update.

Dijana Cukic
  • 196
  • 1
  • 9
  • I tried this but unluckily nothing happened can It be a bug in jsf or is it about jsf version ? – coderxyz24 Jun 26 '15 at 09:08
  • Where is your form, is resultpanel() your panelGrid that has bot pages included? Is is it surrounded by form or do both pages have their own form? Do you use prependId=false on your form's? Are you sure your real id's of component are users and users2. Can you verified that with developer tools or firebug? – Dijana Cukic Jun 26 '15 at 09:15
  • resultpanel is panelgrid id, users and users2 are the id of datatables in included xhtml files, with or without h:form prependId=false only users2 is updated – coderxyz24 Jun 26 '15 at 09:49
  • You didn't say about multiple forms? Do you have them, no ID on them? Send code of your pages, i could only guess that you you have multiple forms and not submitting one of them or you get an error in processing user page. Are datatable's only elements in pages? – Dijana Cukic Jun 26 '15 at 10:33
  • I edited my question by adding two included xhtml files – coderxyz24 Jun 26 '15 at 10:50
  • 1
    You can't have two forms with same id, you can't have prependId=false and then address elements with form:itemID. Surround your whole panelgrid(resultpanel) with one (without id and prependID) and delete forms from individual pages. delete html tag in included pages and put ui:composition like this – Dijana Cukic Jun 26 '15 at 11:10
  • update=":form:users2" in first page change to update whole panelGrid – Dijana Cukic Jun 26 '15 at 11:20
  • As I said before there is something wrong with with datatable with id of users, the other datatable with id users2 has no problem when I click to commandbutton it is updated – coderxyz24 Jun 26 '15 at 11:22
  • @DijanaCukic: if you use `prependId="false"` in your form, you still have to add the form id in the ajax update/render attributes, See http://stackoverflow.com/questions/7415230/jsf-namingcontainer-and-uiform-with-prependid. Unfortunate, but true. Better to never use prependId="false" again... – Kukeltje Jun 26 '15 at 11:24
  • 1
    @coderxyz24 yes because you are updating user2 so user2 is ok, however you are not updating user so user don't get updated. (at)Kukeltje if you will see the code he is using updates with form:id "update=":form:panel2, :form:protocolNo" – Dijana Cukic Jun 26 '15 at 11:31
  • when I debug my code datatable is empty and when I use refresh button of my web browser then user datatable becomes empty – coderxyz24 Jun 26 '15 at 11:44
  • @dijanaCukic: yes I know OP is doing it right, I was referring to you post of 40 minutes ago. Interpreted your comment as that OP is using prependId and update in a wrong way – Kukeltje Jun 26 '15 at 11:53
  • I'm getting "The class does not have property 'onRowSelect'" after I deleted html tags – coderxyz24 Jun 26 '15 at 12:04
  • And second table also change on commandButton if you want to update both tables on click if you wat to chat about it go to http://collabedit.com/574uw – Dijana Cukic Jun 26 '15 at 12:39
0

I solved my own problem, I removed

RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.execute("PF('userTable').clearFilters()");

now I have another problem I have to clear filter of datatable

@DijanaCukic Thanks Dijana for spending your time to solve my problem

coderxyz24
  • 11
  • 2
  • 11
  • The best way to give thanks is by "**Checkmarking**" a users answer as the "Selected" answer, and/or **UpVoting** their answers and comments. Remember, you can Upvote all answers and comments that you find helpful. It's like free money, you can spend endlessly on upvotes. Upvotes motivate users to contribute their knowledge, and helps future users quickly find information useful for solving *their* problems. Thanks. – SherylHohman Mar 15 '19 at 04:49