1

I have a list (p:dataTable) of elements. If I select an element, a detail of it is shown on a p:dialog. The detail presents another list, of another kind of elements. If I select an element from that list, another p:dialog opens with its details.

Now, I can edit those details and update the entry, but the update parameter is not working. The list is not re-rendered. I have to close the dialog and open it again.

I also have to use a weird onkeyup to update EVERY textarea with the class newEventCommentClass. Otherwise #{event.comment} gets filled with an empty string instead of the p:inputTextarea value.

I've tried all kinds of combinations:

  • update="@all" closes all dialogs.
  • Combinations such as update="@form", update="@form:issueEvents" update="@this :issueDetail", update="@this @(.issueEventsClass)" and update="@this :issueEvents" do nothing.

When I open the inner dialog directly instead of from another dialog I don't have any problems to re-render the list using the update=":elementId" method.

How can I make it work too when the detail dialog opens from the parent detail dialog of another list?

This is the "outer" dialog code I am using:

<p:dialog 
    closeOnEscape="true"  
    widgetVar="commissionDetail" 
    id="commissionDetail" 
    modal="true" 
    width="60%"
>   
    <ui:include src="/views/widgets/commission_detail_edit.xhtml" />
</p:dialog>

And this the "inner" dialog code (note I have to use appendTo="@(body)", otherwise it opens inside the modal lock set by the parent dialog):

<p:dialog 
        closeOnEscape="true" 
        widgetVar="issueDetail" 
        id="issueDetail" 
        modal="true" 
        appendTo="@(body)" 
>   
        <p:ajax event="close" update=":manageCommissionSession:commissionSessionIssues" />
        <ui:include src="/views/widgets/issue_detail_edit.xhtml" />
</p:dialog>

This is the "outer" dialog content, commission_detail_edit.xhtml:

<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
>
    <h:form id="manageCommissionSession" prependId="false">
            <p:dataTable 
                id="commissionSessionIssues"
                value="#{myCommissionsController.selectedCommissionSession.issues}"
                var="tissue" 
                selection="#{issue}"
                selectionMode="single" 
                rowKey="#{tissue.idIssue}"
            >
                <p:ajax event="rowSelect" listener="#{myIssuesController.onSelectOneRow}" update=":issueDetail" oncomplete="PF('issueDetail').show();"/>
                <p:column headerText="#{i18n['issue.title']}">
                    <h:outputText value="#{tissue.title}" />
                </p:column>
                <p:column headerText="#{i18n['issue.description']}">
                    <h:outputText value="#{tissue.description}" />
                </p:column>
            </p:dataTable>
    </h:form>
    <p:dialog 
        // ... (the dialog code shown above)
    </p:dialog>
</ui:composition>

This is the "inner" dialog content, issue_detail_edit.xhtml:

<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"
>
    <h:form id="manageIssue" styleClass="manageIssueClass" prependId="false">
        <p:commandButton 
            id="saveNewEventButton" 
            value="#{i18n.saveEvent}" 
            action="#{newIssueController.addIssueEvent}" 
            process="@this @(.newEventCommentClass)" 
            update="@this @(.issueEventsClass)"
        />
        <br />
        <p:inputTextarea 
            id="newEventComment" 
            styleClass="newEventCommentClass" 
            value="#{event.comment}" 
            onkeyup="$('.newEventCommentClass').val($(this).val())"
        />
        <p:dataTable 
            id="issueEvents"
            styleClass="issueEventsClass"
            value="#{myIssuesController.selectedIssue.events}"
            var="tevent"
        >
            <p:column headerText="#{i18n['date']}">
                <h:outputText value="#{tevent.eventDate}" />
            </p:column>
            <p:column headerText="#{i18n['comment']}">
                <h:outputText value="#{tevent.comment}" />
            </p:column>
        </p:dataTable>
    </h:form>
</ui:composition>
NotGaeL
  • 8,344
  • 5
  • 40
  • 70
  • Version info? And please try to make an [mcve] – Kukeltje Oct 28 '15 at 13:20
  • 3
    Remove `prependId="false"` and retry. That's a bad thing from JSF 1.2 which may break ajax things in JSF 2.0. – BalusC Oct 28 '15 at 13:26
  • It worked! Once again, you saved my day @BalusC. Thank you so much! – NotGaeL Oct 28 '15 at 13:33
  • It worked for the update parameter, but I still have the problem with the id. I have to use the onkeyup trick on the `p:inputTextarea`, otherwise all I get is an empty string on `#{event.comment}`. It works fine if I don't nest dialogs. Any idea what may be causing this? – NotGaeL Oct 28 '15 at 15:12
  • Boil down to a MCVE and ask a new question. – BalusC Oct 28 '15 at 19:56
  • I have created a MCVE and asked a new question here: http://stackoverflow.com/questions/33401724/pinputtextarea-backing-bean-associated-value-not-being-populated-on-primefaces – NotGaeL Oct 28 '15 at 21:17

0 Answers0