2

I will try to explain myself:

I'm working on a JSF project using java, JSF 2.0 and RichFaces 4.2.1.

When I access my jsf it just loads a search filter and a commandLink. The commandLink will launch a method in my backingBean to load data that it will be displayed in a dataTable.

<h:commandLink id="btnRecords">
    <f:ajax render="myCompAjax" event="click" listener="#{myBean.loadRecords}" />
    <h:graphicImage value="img/ico_new.gif" alt="#{bundle['button.search']}" />
</h:commandLink>

The datatable is not visible at first, but once you click on the commandLink a flag in the backingBean will change and the table displays with data I just loaded.

<a4j:outputPanel ajaxRendered="true" id="myCompAjax">
    <h:dataTable id="recordsTable" value="#{myBean.records}"                   
     var="item" rendered="#{myBean.flagShowTable}">
        <h:column headerClass="thPijama" >
            <f:facet name="header">
                <table><tr class="thPijama"><td></td></tr></table>
            </f:facet>
            <h:commandLink action="#{myBean.goNextPage}">
                <h:outputText value="Go Next Page" />
                <h:inputHidden value="#{item}" />   
            </h:commandLink>                                                     
        </h:column>                   
    </h:dataTable>
</a4j:outputPanel>

Problem is the commandLink action inside of the dataTable isn't working at all. I just want to navigate to another jsf. In fact, what it does is hiding the dataTable and leaving the filter unchanged. The action method remains unreachable.

Of course, it works if I set the same commandLink outside the dataTable.

I cannot use Session Scope Beans because the people I work for don't approve it.

Can anyone help me?

Thanks for the hint.

user1806077
  • 21
  • 1
  • 2
  • Could you post more of the markup here? Where is the `` to process this page? Do you have nested forms? – kolossus Nov 07 '12 at 18:01
  • @kolossus: the statement near the end of the question *"Of course, it works if I set the same commandLink outside the dataTable."* is enough hint that there's a form and that it's not nested. – BalusC Nov 07 '12 at 19:03

1 Answers1

3

I cannot use Session Scope Beans because the people I work for don't approve it.

Are you implying that placing the bean in the session scope instead of the request scope actually solved the problem? If so, then just put the bean in the view scope.

@ManagedBean
@ViewScoped
public class MyBean implements Serializable {
    // ...
}

This way the bean will live as long as you're interacting with the same view by ajax requests. The bean is not been shared in other browser tabs/windows in the same session (which is among the architects indeed the major reason to forbid its use in case of simple views).

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Hi BalusC, thanks for the quick reply. Setting MyBean into Serializable and ViewScoped turns into a java.io.NotSerializableException when I access the jsf. – user1806077 Nov 08 '12 at 08:51
  • If helps, I'm deploying in a Jetty Server and MyBean contains one ObjectVO which implements Serializable, two List and a FacadeInterface. – user1806077 Nov 08 '12 at 08:59