Reputation: 288
I read BalusC's post (here) too but still unable to make an ajax call from a dataGrid. Is it that dataGrid doesn support ajax calls? Or i missed something?
Tried everything, the method gets hit when outside the dataGrid, so I assume something do to with dataGrid..? First my page was included into a template, I removed that, still no luck.
My jsf :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Order select</title>
</h:head>
<h:body>
<p:layout style="min-width:400px;min-height:400px;" id="layout">
<p:layoutUnit id="rightLayout" position="east" size="100" minSize="200" maxSize="200">
right
</p:layoutUnit>
<p:layoutUnit position="center" >
<h:form id="imgForm" style="text-align: center">
<p:dataGrid var="img"
value="#{orderBean.userMedia.mediaList}"
columns="4"
rows="16"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="9,12,15">
<p:panel>
<p:commandLink actionListener="#{orderBean.selectImage}" update="@form">
<p:graphicImage value="#{img.thumbNail.getString('url')}"/>
</p:commandLink>
</p:panel>
</p:dataGrid>
</h:form>
</p:layoutUnit>
</p:layout>
</h:body>
</html>
My managed bean(viewScoped) method:
public void selectImage()
{
String methodName = "selectImage()";
log.info("Entering :"+methodName);
}
I am using : primefaces : 3.3.1 (tomcat 7 + Java 1.6)
Upvotes: 1
Views: 718
Reputation: 4044
As stated in primefaces docs, you have to put everything inside p:datagrid
inside a p:column
<p:dataGrid var="img"
value="#{orderBean.userMedia.mediaList}"
columns="4"
rows="16"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="9,12,15">
<p:column>
<p:panel>
<p:commandLink actionListener="#{orderBean.selectImage}" update="@form">
<p:graphicImage value="#{img.thumbNail.getString('url')}"/>
</p:commandLink>
</p:panel>
</p:column>
</p:dataGrid>
Starting from primefaces version 3.4, this is not required, but you are using version 3.3.1
Upvotes: 1