My dialog component on PrimeFaces can't render a list on first click

26 Views Asked by At

this is the dialog component that im using

<?xml version="1.0" encoding="UTF-8"?>
<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:composite="http://java.sun.com/jsf/composite"
    xmlns:p="http://primefaces.org/ui">

    <composite:interface>
        <composite:attribute name="headerDialog" />
        <composite:attribute name="widgetVar" />
        <composite:attribute name="renderTesto" type="boolean" default="false"/>
        <composite:attribute name="testo" />
        <composite:attribute name="renderHeaderTextArea" type="boolean" default="false"/>
        <composite:attribute name="headerTextArea" />
        <composite:attribute name="renderTextArea" type="boolean" default="false"/>
        <composite:attribute name="requiredTextArea"
            shortDescription="Booleano che mi indica se è richiesta la nota"
            type="boolean" />
        <composite:attribute name="textArea" />
        <composite:attribute name="actionlistener"
            method-signature="java.lang.String action()" />
        <composite:attribute name="modificalistener"
                    method-signature="java.lang.String action()" />
        <composite:attribute name="valueBtnLeft" />
        <composite:attribute name="renderedBtnLeft" default="true"/>
        <composite:attribute name="valueBtnRight" />
        <composite:attribute name="renderedBtnRight" default="true"/>
        <composite:attribute name="renderedBtnModifica" default="false"/>
        <composite:attribute name="escapeTestoCharacters" default="true"/>
        <composite:attribute name="renderList" type="boolean" default="false"/>
        <composite:attribute name="listaElementi" type="java.util.List"/>
    </composite:interface>
    
    <composite:implementation>
    
        <p:dialog id="dialogComponent" header="#{cc.attrs.headerDialog}"
            widgetVar="#{cc.attrs.widgetVar}" modal="true" resizable="false"
            width="400" appendTo="@(body)" closable="false" >
            <h:form id="formDialogComponent">
                <div class="cm-margin-10px">
                    <!-- Elenco puntato dinamico -->
                    <p:outputPanel id="divRenderedList" rendered="#{cc.attrs.renderList}">
                        <p:panelGrid columns="1" styleClass="ui-grid-col-12 cm-padding-10px">
                            <ul>
                                <ui:repeat value="#{cc.attrs.listaElementi}" var="elemento">
                                    <li>#{elemento}</li>
                                </ui:repeat>
                            </ul>
                        </p:panelGrid>
                    </p:outputPanel>

                    <!-- Testo con supporto al ritorno a capo -->
                    <p:outputPanel id="divRenderedTesto" rendered="#{cc.attrs.renderTesto}"
                        styleClass="ui-grid">
                        <p:outputPanel layout="block"
                            styleClass="ui-grid-row cm-margin-top-10px">
                            <p:outputPanel id="divTesto" layout="block"
                                styleClass="ui-grid-col-12 cm-padding-10px">
                                <p:outputLabel value="#{cc.attrs.testo}" styleClass="cm-font-bold cm-color-black" escape="false" />
                            </p:outputPanel>
                        </p:outputPanel>
                    </p:outputPanel>
                    
                    <!-- TextArea -->
                    <p:outputPanel id="divTextArea"
                        rendered="#{cc.attrs.renderTextArea}" styleClass="ui-grid"
                        style="max-height: 600px; overflow-y: auto;">
                        <p:outputPanel layout="block"
                            styleClass="ui-grid-row cm-margin-top-10px cm-background-color-light-grey">
                            <p:outputPanel layout="block"
                                rendered="#{cc.attrs.renderHeaderTextArea}"
                                styleClass="ui-grid-col-12 cm-padding-10px">
                                <h:outputText value="#{cc.attrs.headerTextArea}"
                                    styleClass="cm-font-bold" />
                            </p:outputPanel>
                        </p:outputPanel>
                        <p:outputPanel layout="block" styleClass="ui-grid-row">
                            <p:outputPanel id="panelNota"
                                styleClass="ui-grid-col-12">
                                <p:message id="notaTextAreaError" for="idNotaTextArea"
                                    display="text" escape="false" styleClass="cm-alert-text-area"/>
                                <p:inputTextarea id="idNotaTextArea"
                                    value="#{cc.attrs.textArea}" style="width:100%;"
                                    scrollHeight="100" maxlength="10000"
                                    counterTemplate="{0} caratteri rimanenti"
                                    counter="displayCaratteriRimanenti" required="true"
                                    requiredMessage="Inserire un valore &lt;script type='text/javascript'&gt;hide_ajax_status_modal_div('ajax_status_change_page');&lt;/script&gt;"
                                    validator="validator.isNotBlank"
                                    validatorMessage="Valore Errato &lt;script type='text/javascript'&gt;hide_ajax_status_modal_div('ajax_status_change_page');&lt;/script&gt;" />
                            </p:outputPanel>
                        </p:outputPanel>
                        <p:outputPanel styleClass="ui-grid-row cm-margin-top-5px">
                            <p:outputPanel styleClass="ui-grid-col-12">
                                <h:outputText id="displayCaratteriRimanenti" style="float:right;" />
                            </p:outputPanel>
                        </p:outputPanel>
                    </p:outputPanel>
                    
                    <!-- Pulsanti -->
                    <p:outputPanel layout="block" styleClass="ui-grid-row">
                        <p:outputPanel styleClass="ui-grid-row cm-margin-top-10px">
                            <p:outputPanel styleClass="ui-grid-col-12">
                                <p:commandButton value="#{cc.attrs.valueBtnRight}"
                                    update="formDialogComponent" action="#{cc.attrs.actionlistener}"
                                    rendered="#{cc.attrs.renderedBtnRight}"
                                    onclick="display_ajax_status_modal_div('ajax_status_change_page')"
                                    styleClass="btn-color-blu cm-margin-bottom-10px cm-float-right" />
                                <p:commandButton value="#{cc.attrs.valueBtnLeft}"
                                    update="formDialogComponent"
                                    rendered="#{cc.attrs.renderedBtnLeft}"
                                    onclick="PF('#{cc.attrs.widgetVar}').hide()"
                                    styleClass="btn-color-blu cm-margin-bottom-10px" />
                                <p:commandButton value="#{cc.attrs.valueBtnLeft}"
                                    update="formDialogComponent"
                                    rendered="#{cc.attrs.renderedBtnModifica}"
                                    action="#{cc.attrs.modificalistener}"
                                    styleClass="btn-color-blu cm-margin-bottom-10px" />
                            </p:outputPanel>
                        </p:outputPanel>
                    </p:outputPanel>
                </div>
            </h:form>
        </p:dialog>
    </composite:implementation>

</html>

When i click a button the application do some controls and populate a list of warnings in case of warning. It is a list of Strings. If this list is not empty i show it in the dialog like this (getListaWarning()):

<gft:dialog_component_elenco id="alertInoltroPraticaRD"
            widgetVar="alertInoltroPraticaRD"
            headerDialog="#{commonBundle.attenzione}"
            renderList="#{approvazioneCategoriaRDBean.isWarningValorizzato()}"
            listaElementi="#{approvazioneCategoriaRDBean.getListaWarning()}"
            renderTesto="true"
            testo="Alla conferma la pratica verrà inoltrata al Responsabile Rating Desk per verifica e approvazione. Si desidera proseguire?"
            valueBtnLeft="#{commonBundle.btn_indietro}"
            valueBtnRight="#{commonBundle.btn_prosegui}"
            actionlistener="#{approvazioneCategoriaRDBean.salvataggiCheckOk()}" />

My problem is that when i click for the first time on the button the list doesn't appear. I used some debug and it is correctly populated. If i click for the second time it works as it should

What can i do ? thank you

I tried to populate a list in the initialization and the problem is still there

0

There are 0 best solutions below