Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action method not getting called inside the dataTable

 
Amit Nair
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:column>
<h:panelGrid columns="1" width="100%" columnClasses="none,tableRowOdd" rowClasses="tableRowEven,tableRowOdd">
<h:panelGroup>
<hutputText value="Name: " />
<hutputText value="#{details.name}" style="width: 55%" />
</h:panelGroup>
<h:panelGroup>
<hutputText value="Location: " />
<hutputText value="#{details.location}" style="width: 55%" />
</h:panelGroup>
<h:panelGroup>
<hutputText value="Description: " />
<hutputText value="#{details.description}" style="width: 55%" />
</h:panelGroup>
</h:panelGrid>
</h:column>
<h:column>
<h:commandLink action="#{requirementDisplay.viewDetailedRequirement}">
<hutputText value="VDR" />
</h:commandLink>
</h:column>
</h:dataTable>

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
Amit
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
change your managed bean scope from "request" to "session"
 
Amit Nair
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....

Thanks
Amit
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic