Primefaces DataGrid-CommandLink无法正常工作 [英] Primefaces DataGrid - CommandLink is not working

查看:54
本文介绍了Primefaces DataGrid-CommandLink无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的嵌套UI组件存在问题,这可能是PrimeFaces和Mojara中的已知错误.但是我不知道该怎么解决.

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>  

基本上,根本不起作用的是DataGrid中的commandLink Delete.其余的都很好.

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

对此有任何解决方法吗?我试过了:列,ajax,没有ajax ...什么都行不通.我所能做的就是获取DataGrid外部的按钮.但这不是我真正想要的.

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.

任何帮助.

[小事情:令人惊讶的是,我毫无疑问地在DataTable和Columns中使用了CommandLink! ]

maven的Primefaces 3.4RC1. (也可以在3.3.1上完成)

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

好的,所以我发现了一件事: <p:dataGrid>内,如果我使用任何东西,但p:则表示其不起作用. 但是,然后视图就很糟糕了……我应该只使用CSS来修复它吗?

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?

推荐答案

@Maple_shaft你太对了!

@Maple_shaft you are so right!

正确的代码:

<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.

当然支持bean是@ViewScoped!

Of course backing bean is @ViewScoped!

这篇关于Primefaces DataGrid-CommandLink无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆