Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

jsf - Primefaces DataGrid - CommandLink is not working

i have an issue with nested UI components which is probably a known bug in PrimeFaces and Mojara. However I have no idea how can i solve it.

We have a image gallery with uploader and I want to be able to delete images from the datagrid, so

XHTML:

<h:form enctype="multipart/form-data">

            <p:fileUpload fileUploadListener="#{pictureManagementBean.handleFileUpload}"  
                    mode="advanced"  
                    update="gallery messages"  
                    auto="true"                    
                    allowTypes="/(.|/)(gif|jpe?g|png)$/"
                    />  

            <p:growl id="messages" showDetail="true"/>  

            <p:dataGrid var="item" value="#{pictureManagementBean.pictures}" id="gallery">  
                <p:panel header="#{item.pictureName}" style="text-align:center">  
                    <h:panelGrid columns="1" style="width:100%">  

                        <p:graphicImage value="#{item.thumbnailDir}" />                             
                        <h:outputText value="#{item.createdate.toString()}" />                           
                        <p:commandLink value="Delete" 
                                       action="#{pictureManagementBean.removePicture(item.idpicture)}" ajax="false"/>

                    </h:panelGrid>  
                </p:panel>  
            </p:dataGrid>  

        </h:form>  

Basically what is not working at the momment - at all - is the commandLink Delete in the DataGrid. The rest is fine.

Is there any walkaround to this? I've tried: columns, ajax, no ajax... nothing works. All i can do is get the button outside the DataGrid. But that's not really what I want.

Any help apprecieated.

[small thing: surprisingly I have used commandLink in DataTable and Columns with no problem! ]

Primefaces 3.4RC1 from maven. (didnt work on 3.3.1 either)

ok so I've found one thing: inside <p:dataGrid> if I use anything BUT p:columns its not working. But then the view is terrible... should I just use CSS to fix it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@Maple_shaft you are so right!

correct code:

<p:dataGrid var="item" value="#{pictureManagementBean.pictures}" id="gallery">  
                <p:column>
                    <p:panel header="#{item.pictureName}" style="text-align:center"> 
                    <h:panelGrid columns="1" style="width:100%"> 

                        <p:graphicImage value="#{item.thumbnailDir}" />                             
                        <h:outputText value="#{item.createdate.toString()}" />                           
                        <p:commandLink value="Delete" 
                                       action="#{pictureManagementBean.removePicture(item.idpicture)}" ajax="false"/>

                    </h:panelGrid>
                    </p:panel>
                </p:column>
            </p:dataGrid>  

So just simple column element. I've just places it wrong before. Thanks so much.

Of course backing bean is @ViewScoped!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...