my dog learned polymorphism*
The moose likes JSF and the fly likes Action method not getting called inside the dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Action method not getting called inside the dataTable" Watch "Action method not getting called inside the dataTable" New topic

Action method not getting called inside the dataTable

Amit Nair

Joined: May 23, 2006
Posts: 16
Hi Friends

I am having trouble in calling the action method from command link inside datatable.

The code of the DataTable is

<h:dataTable id="siteDetailTable1" value="#{siteRequirementBean.detailHeadQuarterList}" var="details" cellpadding="1" cellspacing="1" width="100%">
<h:panelGrid columns="1" width="100%" columnClasses="none,tableRowOdd" rowClasses="tableRowEven,tableRowOdd">
<hutputText value="Name: " />
<hutputText value="#{}" style="width: 55%" />
<hutputText value="Location: " />
<hutputText value="#{details.location}" style="width: 55%" />
<hutputText value="Description: " />
<hutputText value="#{details.description}" style="width: 55%" />
<h:commandLink action="#{requirementDisplay.viewDetailedRequirement}">
<hutputText value="VDR" />

The managed beans siteRequirementBean & requirementDisplay both are in request scope.

The datatable has two columns. In the first column there 3 labels which displays some information. In the second column there is a command link. This command link is binded with an action method of managed bean. The page gets displayed with all the components including the commandlink , but on clicking the command link the action method is not getting called. The page gets refreshed & comes back again.

Infact I tried putting in arbitrary string in the action method�s name attribute of command link. There was no error & the page came back again on clicking the link.
If the same command link is kept outside data table then the action method gets called.

Command Button also shows the same behavior as command link.

Please give your valuable inputs�..

Thanks in Advance
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
change your managed bean scope from "request" to "session"

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Amit Nair

Joined: May 23, 2006
Posts: 16
Thanks a lot Richard for your reply !!!

I changed the scope of bean from request to session. Now the action method is getting called. But I found that both the beans(siteRequirementBean &
requirementDisplay) needs to be in session scope. But the command link is only calling the action method of requirementDisplay bean. So when only
requirementDisplay is kept in session scope, action method is not getting called. Also my whole application is built on the top of logic that the bean would be in request scope. So changing the scope of bean from request to session would be night mare & real problem. So can you please tell me is there any other way out of it� Also one of my page is having the data table with the bean in request scope & it's calling the action method without any problem. But I am unable to figure out as what is getting wrong here....

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
How are you populating the datatable values? The values become garbaged after one request.

This might help:

[ December 01, 2006: Message edited by: Bauke Scholtz ]
I agree. Here's the link:
subject: Action method not getting called inside the dataTable
Similar Threads
datatable commandlink action method called for each row
Unable to call Action Methof
h:commandLink will not work inside a h:dataTable
Problem with building columns dynamically using dataTable tag
Problem in using rich:tree in IE6.0