CommandLink in DataTable
I'm using asession-scoped bean to generate datatable, but still commandLink does not work.
<h:form>
<h:dataTable value="#{ComponentBean.components}" var="item"
styleClass="List" headerClass="ListHeader" footerClass="ListFooter"
rowClasses="EvenRow,OddRow" rendered="#{ComponentBean.found}">
<h:column>
<f:facet name="header">
<h:outputText value="#{msg.No}" />
</f:facet>
<h:outputText value="#{item.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<h:commandLink value="#{msg.Select}" action="#{ComponentBean.reserve}">
<f:param name="selectedId" value="#{item.id}" />
</h:commandLink>
</h:column>
</h:dataTable>
</h:form>
ComponentBean.components is not null. (session-scope)
When I click commandLink neigherComponentBean.getComponents() norComponentBean.reserve() are called, instead I'm redirected to main page.
Any help will be greatly appreciated.
Thanks.
# 3
hi,
it seems to me,
you are getting validation error(s)...
your action handler method is not firing because your full phase chain is not completed...
i recommend you try the FacesTrace component that shows all your phases, states, values, errors etc...
you can reach it from here:
http://facestrace.sourceforge.net/
regards...
xaxia at 2007-7-8 21:55:26 >

# 5
Remove the f:param (this causes this all not working, because it is not iterated correctly as you should expect) and add componentbinding to the h:dataTable. In the action method you can retrieve the id (or just the object) by
Long id = ((Component) htmlDataTable.getRowData()).getId();
Check http://balusc.xs4all.nl/srv/dev-jep-dat.html how to use datatables.
Edit
Another thing, you can replacerendered="#{ComponentBean.found}"
byrendered="#{!empty ComponentBean.components}"
In the link I gave you above, you also can download an EAR. This EAR contains a CRUD example. This will give you much more insights how it should work ;)
Message was edited by:
BalusC
# 6
Thanks for the reply..
I know commandLink problems in request-scoped beans, but I'm using session-scoped bean..
I have similar pages works well with session-scoped beans, but only this one causes problem. I'm trying to code in the same way through project, this is why I dont want to use databale binding...
# 9
BalusC,
I'have tried to remove f:param, but still ComponentBean.reserve is not invoked.
as I said before, that is not usual commandLink problem, because I'm redirected directly to context-root (http://localhost/app/) instead of page refresh.
edit:
SOLVED:
OMG!! I forgot to end a <h:form> tag before dataTable!!
I understand that when I look commandLink's id..
thanks everyone who replied.
Message was edited by:
GBerberoglu