Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update primefaces dialog on show

I'm trying to update a primefaces dialog every time it pops up. The dialog is triggered by a calendar field changing and the actual call is made from the bean. When I call it the first time, the datas are fine but, if I close it and open it again, it'll still show the old datas. It kinda makes sense: it's rendered just once and then it's shown and hidden and never actually updated.

I was thinking about updating it before the dialog.show() in the bean, but I don't know how to do that. Any idea?

<p:dialog
        site        ="sectionDlg"
        widgetVar   ="Dlg"
        minWidth    ="430"
        modal       ="true"
        closable    ="true"
        resizable   ="false"
        dynamic     ="true"
        width="450" height="300"
>


<h:form id="Form">
    <br/>
    <p:panelGrid id ="dates" styleClass="cmt-no-grid-100perc" columns="4">
    <calendar        attribName ="offerStartDateDlg"
                                value       ="#{bean.startDate}"
                                writable    ="#{false}"/>                           

    <calendar        attribName="offerEndDateDlg"
                                value="#{bean.endDate}"
                                writable="#{false}"/>
    </p:panelGrid>
    <div align="center">
        <p:commandButton
            onclick ="PF('whichSectionDlg').hide()"
            >
        </p:commandButton>
        <p:commandButton
            onclick ="PF('whichSectionDlg').hide()">
        </p:commandButton>
    </div>
</h:form>

This could make things easier

like image 675
pedro Avatar asked Mar 08 '23 21:03

pedro


1 Answers

Ok so, I managed to figure it out.

I solved it by updating it from the bean, right before the call

public void show_dlg_method(){
    RequestContext.getCurrentInstance().update("Dlg");
    RequestContext.getCurrentInstance().execute("PF('Dlg').show()");
}

with "Dlg" being the widgetVar attribute value.

like image 135
pedro Avatar answered Mar 19 '23 22:03

pedro