JSF2 + Primefaces 3.2 ajax更新

时间:2021-07-28 20:02:55

I'm having difficult to update this both h:form and p:panelGrid, so can u help me? I've tried @form too, and nothing happens. The expected behavior only happens if I press F5.

我很难更新h:form和p:panelGrid,你能帮我吗?我也尝试过@form,但什么也没发生。只有当我按F5时,才会出现预期的行为。

xhtml:

xhtml:

<h:form id="slct_img_form">
<p:panel header="Nova categoria">
    <div style="margin: 2% 0 1.7% 0;">
        <p><b>2.º Passo:</b> Selecione uma imagem para representar a categoria.</p></pre>
    </div>
    <p>debugging selected: #{catalogCategoryController.picasaPhoto.title}</p>
    <p:dataGrid id="imgs_to_slct" var="img" value="#{siteImgsPicasaController.picasaPhotos}"  
                columns="3" rows="6" paginator="true"
                emptyMessage="Nenhuma imagem at&eacute; o momento!"
                paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                rowsPerPageTemplate="6,9,12">


        <p:column>

            <p:panel header="#{img.title}" style="text-align:center; width: 300px;">
                <table border="0" style="margin: 0 auto;">
                    <tr>&nbsp;</tr>
                    <tr>
                        <td colspan="3">
                            <p:lightBox group="false" transition="false">
                                <h:outputLink value="#{img.sourceUrl}" title="#{img.title}">
                                    <h:graphicImage value="#{img.thumbnailUrl}" />
                                </h:outputLink>
                            </p:lightBox> 
                        </td>
                    </tr>                                                            
                    <tr>
                        <td colspan="3">&nbsp;</td>
                    </tr>
                    <tr>
                        <td><b>Dimens&otilde;es:</b> #{img.width} x #{img.height} pixels</td>
                    </tr>
                    <tr>
                        <td>

                            <p:commandButton title="Selecionar" value="Selecionar"
                                             rendered="#{img.sourceUrl ne catalogCategoryController.picasaPhoto.sourceUrl}" 
                                             update=":slct_img_form:imgs_to_slct">


                                <f:setPropertyActionListener value="#{img}" 
                                                             target="#{catalogCategoryController.picasaPhoto}" />
                            </p:commandButton>
                                <p:commandButton title="Selecionar" value="Selecionar" icon="ui-icon-check"
                                                 rendered="#{img.sourceUrl eq catalogCategoryController.picasaPhoto.sourceUrl}"
                                                 disabled="true" />
                        </td>
                    </tr>
                    <tr>&nbsp;</tr>
                </table>
            </p:panel>

    </p:column>

</p:dataGrid>
    <div style="font-weight: bold; margin: 2% 0 1% 0;">
    <p:commandButton value="Voltar" icon="ui-icon-arrow-1-w"
                     ajax="false" type="submit"
                     action="new">

    </p:commandButton>
    <p:commandButton value="Gravar" icon="ui-icon-disk"
                     ajax="false" type="submit"
                     action="#{catalogCategoryController.add}">

    </p:commandButton>
    </div>
</p:panel>
</h:form>

...

ManagedBean:

ManagedBean:

@Named
@SessionScoped
public class CatalogCategoryController implements Serializable{

...

private PicasaPhoto picasaPhoto;
public PicasaPhoto getPicasaPhoto() {
    return picasaPhoto;
}
public void setPicasaPhoto(PicasaPhoto picasaPhoto) {
    this.picasaPhoto = picasaPhoto;
    this.selectedImage = new Media(picasaPhoto, currentAccount);
}

....
} 

Thanks,

谢谢,

1 个解决方案

#1


3  

Add prependId="false" to form properties, then primefaces won't add form ID before other components ids, otherwise you have to specify "full" path to component (if it is not in the particular form). Then try it with update="@form" or update=":imgs_to_slct"

将prependId="false"添加到表单属性,那么在其他组件ID之前,primefaces将不会添加表单ID,否则必须指定到组件的“完整”路径(如果不是特定的表单)。然后尝试使用update="@form"或update=":imgs_to_slct"

#1


3  

Add prependId="false" to form properties, then primefaces won't add form ID before other components ids, otherwise you have to specify "full" path to component (if it is not in the particular form). Then try it with update="@form" or update=":imgs_to_slct"

将prependId="false"添加到表单属性,那么在其他组件ID之前,primefaces将不会添加表单ID,否则必须指定到组件的“完整”路径(如果不是特定的表单)。然后尝试使用update="@form"或update=":imgs_to_slct"