Problems with ui: repeat and ajax update

2

Good evening.

I have some problems with using ui:repeat and the ajax update of primefaces.

MyintentionistolistthecriteriafromtheDecisionProcessidtowhichtheyarelinkedsothattheusercanselect,foreachoneofthem,ifitisanumericvalue(Booleancheckbox)anddependingontheselectionofthecheck,renderifitisaspinnerorimpactvalue(selectOneMenu).

Theproblemsare:

1°)Youarenotlistingthingswithui:repeat.Ihavedebuggedandfoundthatthevaluesinthelistarebeingfilled.

2)Idonotknowwhy,buteverytimeIchangetheDecisionProcess,itclosesthedialog(maybebecauseIupdatedeveryform?)

3°)WhydidtheselectOneMenuspacecomelikethis?Shouldnotitbeallwhiteuntiltheclickicontoopenthelist?

View

<p:panelGridstyle="width: 100%;">
                    <p:row> 
                        <p:column><h:outputLabel for="pdMenu" value="Processo de Decisão: " class="componentePF label" /></p:column>
                        <p:column>
                            <p:selectOneMenu id="pdMenu" converter="generic" value="#{topsisBean.pd}" style="width:100% !important;" 
                                class="componentePF text" required="true" requiredMessage="É necessário escolher um processo de decisão">
                                <f:selectItem itemLabel="Escolha um Processo" noSelectionOption="true" />
                                <f:selectItems value="#{topsisBean.pds}" var="pd" itemLabel="#{pd.nomePD}"  
                                    itemValue="#{pd}" converter="generic" />
                                <p:ajax listener="#{topsisBean.mudouPD}" update=":form" />
                            </p:selectOneMenu>
                        </p:column>
                    </p:row>

                    <p:row> 
                        <p:column><h:outputLabel for="projetoMenu" value="Projeto: " class="componentePF label" onclick="#{topsisBean.getProjetosPD()}"/></p:column>
                        <p:column>
                            <p:selectOneMenu id="projetoMenu" converter="generic" value="#{topsisBean.avaliaProjeto.projeto}" 
                                class="componentePF text" required="true" requiredMessage="É necessário escolher um projeto">
                                <f:selectItem itemLabel="Escolha um Projeto" itemDisabled="true" noSelectionOption="true" />
                                <f:selectItems value="#{topsisBean.projetosPD}" var="p" itemLabel="#{p.nomeProjeto}" itemValue="#{p}" converter="generic" />
                            </p:selectOneMenu>
                        </p:column>
                    </p:row>
                </p:panelGrid>

                <p:panelGrid style="width: 100%;" id="avaliaProjetoGrid" rendered="#{topsisBean.pd != null}">
                    <p:row>
                        <p:column><h:outputText value="Critério" class="componentePF label"/></p:column>
                        <p:column><h:outputText value="Valor Numérico" class="componentePF label"/></p:column>                          
                        <p:column><h:outputText value="Valor ou Impacto" class="componentePF label"/></p:column>
                    </p:row>

                    <ui:repeat var="a" value="#{topsisBean.avaliaProjetosPD}">
                        <p:row>
                            <p:column><h:outputText value="#{a.criterio.nomeCriterio}" class="componentePF label"/></p:column>

                            <p:column>
                                <p:selectBooleanCheckbox label="Sim" widgetVar="flag">
                                    <p:ajax update="valor escalaMenu"/>
                                </p:selectBooleanCheckbox>
                            </p:column>

                            <p:column>
                                <p:selectOneMenu id="escalaMenu" converter="generic" value="#{a.escala}" rendered="#{!flag}"
                                    class="componentePF text" required="true" requiredMessage="É necessário escolher uma escala">
                                    <f:selectItem itemLabel="Escolha um Impacto de Escala" itemDisabled="true" noSelectionOption="true" />
                                    <f:selectItems value="#{topsisBean.escalas}" var="e" itemLabel="#{e.impactoEscala}" itemValue="#{e}" converter="generic" />
                                </p:selectOneMenu>

                                <p:spinner id="valor" value="#{a.valor}" class="componentePF text" rendered="#{flag}"/>
                            </p:column>
                        </p:row>
                    </ui:repeat>
                </p:panelGrid>
        </p:dialog>

Bean methods used

public void mudouPD() {
    projetosPD = projetoDAO.listar(pd);
    setaAvaliaProjetosPD();
}

public void setaAvaliaProjetosPD() {
    criterios = criterioDAO.listar(pd);
    avaliaProjetosPD = new ArrayList<>();
    AvaliaProjeto a;

    for(Criterio c : criterios) {
        a = new AvaliaProjeto();
        a.setCriterio(c);

        avaliaProjetosPD.add(a);
    }
}

If you need the pojo, let me know that I'm editing with them.

    
asked by anonymous 11.06.2015 / 13:11

1 answer

1

I solved the problem by replacing the second panelGrid with a common html table.

    
14.06.2015 / 19:12