tags:

views:

328

answers:

2

hi All,

When using h:commandlink(or commandbutton) inside a rich:dataTable, the action specified is never invoked, neither is the corresponding managed bean instantiated(whether it is at request or session scope)... instead, the same request is performed.. (page reloads).. have seen what appeared to be similar issue on forums, but is not actually the problem i am having.. the h:commandlink /button work ok outside of the rich:datatable..

Does anyone have any advice?

here is a code snippet:

    <h:commandLink id="commLink" actionListener="#{hBean.test}" action="#{hBean.viewTranslation}">
        <h:outputText value="#{trans.translationName}"/>   
    </h:commandLink>
</rich:column>
+1  A: 

The bean is apparently request scoped and the datamodel is not been loaded during bean's construction (at least, during apply request values phase of the subsequent request). You need to preserve the same datamodel for the subsequent request, else JSF cannot locate the row item associated with the clicked link. The most straightforward way is to load the datamodel in the bean's constructor or @PostConstruct method.

A quick fix/test is to put bean in session scope. The datamodel will then be saved in the session scope and be available in the subsequent request. But this has more impact on user experience (e.g. unexpected results when having the same page opened in different browser windows/tabs in the same session). If you're already on JSF 2.0 (which is likely not the case since you're using RichFaces), then the new view scope would have been the solution.

Related questions:

BalusC
A: 

thanks BalusC for replying. Actually things are not so simple in my case, because i am using spring in conjunction with JSF and my dataList is constructed in spring annotated controller so in order to make it known to the jsf backing bean i had to make bean known to both spring and jsf.. Your reply though helped me find a solution - not only i have to share my bean between spring and jsf, also needed to make spring controller of session scope.. not such a great solution perhaps, but works for now..
i have not used jsf prior to my latest project and have to say i am not happy with it requiring to adhere so closely to its architecture - makes it somewant difficult to merge spring and jsf