1
votes

i wish to display 2 different datatables in each tab of the tabview of primefaces 3.2. there datatables will fetch data based on the 'type' variable set in the onChange event. but my problem is that the onChange event does not fire at all. pls check my tabview code to check why this is happening:

<h:form id="frm">
        <p:tabView activeIndex="#{equityBean.activeIndex}">
            <p:ajax event="tabChange" listener="#{equityBean.onChange}" update=":frm"/>
            <p:tab title="NSE" binding="#{equityBean.tbn}">


                <p:dataTable binding="#{equityBean.dt}" value="#{equityBean.scripList}" var="scrip">
                    <f:facet name="header">
                Scrip Symbol
            </f:facet>
                <h:outputText value="#{scrip.scripSymbol}"/>
                <f:facet name="header">
                Company Name
            </f:facet>
                <h:outputText value="#{scrip.companyName}"/>
                <f:facet name="header">
                Volume
            </f:facet>
                <h:outputText value="#{scrip.totalTradedVolume}"/>
                </p:dataTable>
            </p:tab>
            <p:tab title="BSE" binding="#{equityBean.tb}">

            </p:tab>
        </p:tabView>
    </h:form>

bean:

public void onChange(TabChangeEvent event) {
type=event.getTab().getTitle();
}

edited: bean code to get datatable value:

public List<MasterScrip> getScripList() {
    scripList=new ArrayList<MasterScrip> ();
 scripList=getScripByVolumeType(type);
    return scripList;
}
private java.util.List<service.MasterScrip> getScripByVolumeType(java.lang.String type) {
    service.StatelessWebService port = service.getStatelessWebServicePort();
    return port.getScripByVolumeType(type);
}

edited : jpa query

public Collection<MasterScrip> getScripByVolumeType(String type)

{ Collection sm=null;

     sm=em.createQuery("select m from MasterScrip m where m.type = :type order by m.totalTradedVolume").setParameter("type", type).setMaxResults(2).getResultList(); // retuens no records
       return sm;
   }

records are returned but not displayed..

why does this happen? where am i wrong?

1

1 Answers

2
votes

Your mistake is here.

listener="#{equityBean.onChange(event)}"

The event object does not exist in EL scope. Remove the argument. You don't need to specify it at all. JSF will supply the necessary action listener argument itself.

listener="#{equityBean.onChange}"

The same is true for all other listener and actionListener attributes. Only in action attribute of UICommand components you can specify custom arguments (which should be passed with real values, not with some random and non-existent variable name).