Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
WebGrid data refresh problem
posted

Hi,

I am trying to refresh a dataGrid (<ig:gridView> tag) on change of  select box item. The problem is when I am trying to reload the data with fresh data, its not getting refreshed on the page (althought the data in the backing bean is refreshed). Can someone please highlight what should be the issue.

Note: If I am binding the grid with the "com.infragistics.faces.grid.component.GridView" then it gets refreshed. Is it necessary to bind the data with GridView?

I have attched below the snippet of the code:

Bean:
public class LimitModelBean {
private ArrayList<GridBean> limitDetails;
private ArrayList<SelectItem> limitModelIds;
private ArrayList<SelectItem> strategyIds;
private String selectedLimitModelId;
private String selectedStrategyId;
private List<MappedAction> mappedActList;
private SessionFacade sessionfacade;
private DataModel contextLimitModel;
private DataModel contextMappedActModel;

// method called to reload the data
public void limitModelIdChangeAction(ValueChangeEvent event) {

  FacesContext facesContext = FacesContext.getCurrentInstance();
  LimitModelBean limitModelBean = (LimitModelBean) facesContext.getExternalContext().getSessionMap().get("limitModelBean");
  
  ArrayList<SelectItem> strategyIds = new ArrayList<SelectItem>();
  ArrayList<GridBean> limitDetails = new ArrayList<GridBean>();
  ArrayList<MappedAction> mappesActions = new ArrayList<MappedAction>();
  contextLimitModel = new ListDataModel();
  contextMappedActModel = new ListDataModel();
  List<StrategyModelBO> strategies = sessionfacade
    .getStrategyModelForLimitModelAndCEID(16, Integer
      .parseInt((String) event.getNewValue()));
  Iterator<StrategyModelBO> itStrategy = strategies.iterator();
  while (itStrategy.hasNext()) {
   StrategyModelBO strategy = itStrategy.next();
   strategyIds.add(new SelectItem((new Integer(strategy
     .getDisplayStrategyID())).toString(), strategy
     .getDisplayStrategyID()
     + " - " + strategy.getStrategyName()));
  }
  List<OverallLimitDetailsBO> overallLimits = sessionfacade
    .getCFLimitsForLimitModelID(16, Integer.parseInt((String) event
      .getNewValue()));
  Iterator<OverallLimitDetailsBO> overIt = overallLimits.iterator();

  while (overIt.hasNext()) {
   OverallLimitDetailsBO overallLimitDetailsSDO = overIt.next();
   GridBean gridBean = LimitBeanHelper
     .convertOverallLimitSDoToGrid(overallLimitDetailsSDO);
   limitDetails.add(gridBean);
  }
  contextLimitModel.setWrappedData(limitDetails);
  List<MappedActionsBO> mappedActionsList = sessionfacade
    .getMappedActionsForLimitModelID(16, Integer
      .parseInt((String) event.getNewValue()));
  for (Iterator<MappedActionsBO> iterator = mappedActionsList.iterator(); iterator
    .hasNext();) {
   MappedActionsBO mappedActionsSDO = (MappedActionsBO) iterator
     .next();
   mappesActions.add(LimitBeanHelper
     .getMappedActionForMappedActionSDO(mappedActionsSDO));
  }
  
  contextMappedActModel.setWrappedData(mappesActions);
  
  limitModelBean.setContextLimitModel(contextLimitModel);
  limitModelBean.setContextMappedActModel(contextMappedActModel);
  limitModelBean.setMappedActList(mappesActions);
  limitModelBean.setStrategyIds(strategyIds);
  limitModelBean.setLimitDetails(limitDetails);
  limitDetailGrid.setDataSource(contextLimitModel);
  mappedActionGrid.setDataSource(contextMappedActModel);
  limitModelBean.setLimitDetailGrid(limitDetailGrid);
  limitModelBean.setMappedActionGrid(mappedActionGrid);
  FacesContext.getCurrentInstance().renderResponse();
  ArrayList<GridBean> a1 = (ArrayList)contextLimitModel.getWrappedData();
  for(int i=0; i<a1.size();i++){
   System.out.println("bbbbb   "+a1.get(i).getLimit());
 
  }
  Runtime.getRuntime().gc();

}


Facelet (xhtml):

 

<h:selectOneMenu id="menu1" styleClass="selectOneMenu"
 immediate="true" style="width:50" onchange="submit()"
 valueChangeListener="#{limitModelBean.limitModelIdChangeAction}">
 <f:selectItems value="#{limitModelBean.limitModelIds}" />
</h:selectOneMenu>


<h:outputText id="text2" styleClass="outputText" value="Strategy ID"
 style="width:50"></h:outputText>

<h:selectOneMenu id="menu2" styleClass="selectOneMenu"
 style="width:50">
 <f:selectItems value="#{limitModelBean.strategyIds}" />
</h:selectOneMenu>
</h:panelGrid>
<br />


<ig:tabView id="tabbedPanel1" styleClass="tabView">
<!-- Overall Limit Details are populated below -->
 <ig:tabItem value="Overall Limit Details" id="bfpanel1"
  selectedStyleClass="selectedStyle" styleClass="tabItem"
  hoverStyleClass="hoverStyle">

  <ig:gridView dataSource="#{limitModelBean.contextLimitModel}"
  id="tableEx1" styleClass="tabGrid" bottomPagerRendered="true"
  topPagerRendered="false" pageSize="5">

   <f:facet name="bottomPager">
    <ig:pager styleClass="pagerStyle"></ig:pager>
   </f:facet>
   <f:facet name="header">
    <h:outputText
    value="Limit Model Values and Reporting Ranges (R1 to R8)"
    id="text2" styleClass="outputText" />
   </f:facet>

   <ig:column>
    <f:facet name="header">
     <h:outputText value="Sequence" id="textSequence"
      styleClass="outputText" />
    </f:facet>
    <h:outputText id="textSequence1" value="#{DATA_ROW.sequence}"
     styleClass="outputText">
    </h:outputText>
   </ig:column>


 

Parents
  • 12025
    posted

    Hello,

    You will have to component bind the GridView call setDataSource to set the data source and call databind() for the grid to reflect the data change. Or, you can change the returned list itself that the grid uses in its datasource attribute. So, when the select box item change, you filter/update the list and then have the same list being returned form "getContextLimitModel", this way when the grid re-renders it will set the new list as its datasource.

    Hope this helps.

    Taz.

Reply Children
No Data