I want to use Smart Refresh on a WebGrid component by clicking a h:commandButton component, but I found that the whole page refreshes instead of just the grid data. My code is as follows:
JSP:
<h:form id="myTradingPlatform"> <h:panelGroup styleClass="section"> <ig:tabView id="myAcctInfoTab"> <ig:tabItem value="Order Book"> <ig:link id="refreshLink" actionListener="#{orderBook.onRefreshButtonClick}" smartRefreshIds="orderBookGridView" value="refresh" /> <h:commandButton value="Refresh" id="refreshButton" onclick="BLOCKED SCRIPTig.smartSubmit('myTradingPlatform:myAcctInfoTab:refreshLink', null, null, 'myTradingPlatform:myAcctInfoTab:orderBookGridView', null);" />
.....
(since the ig:smartSubmit needs to use NetAdvantage component in the first parameter, so i created a dummy refresh link as above for this purpose. Would you please also advise if there is another better approach?)
Backing Bean:
public void onRefreshButtonClick(ActionEvent e){ enquireOrderStatus(); } public OrderStatusBean getOrderStatus(){ if (orderStatus == null){ orderStatus = new OrderStatusBean(); orderStatus.enquireOrderStatus(); } return orderStatus; } public void enquireOrderStatus(){ getOrderStatus().enquireOrderStatus(); orderBookGridView.dataBind(); }
Have I made something wrong such that the smart refresh does not work ?
Cool. Thanks for participating in the forum. :)
It works fine now. Thanks you all.
Hi:
You should call dataBind after you've updated the server-side data source. The binding will ensure that the new data is sent to the browser for dispay. So it sounds like you do have it in the right place - is it working? :)
Best,Jim
Hi Jim,
I think I have put the dataBind() method in a wrong position. I now create a actionListener for the <ig:Link> component and call dataBind() method in that listener method. It can refresh the gird now. But Is it a proper way of doing so ? As I am not sure where should the dataBind() method be placed.
Kennanwu:
Make sure that you call the dataBind() method on your grid to refresh its data.