Primefaces DataGrid - CommandLink 不工作 [英] Primefaces DataGrid - CommandLink is not working
问题描述
我有嵌套 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:columns 它不起作用.但是视图很糟糕……我应该使用 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屋!