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 ?
Hi:
h:commandButton is a SUBMIT button by default. To prevent it from automatically performing a form submission, you must set the type attribute to button:
<h:commandButton type="button" ...
Best,Jim