When a SelectItem is configured to use a DataSource, it loads the data to display from the DataSource.
However, there are be cases when this data load is unsuccessful for the first time, but would succeed for a second time if it happened.
One of these cases is when the user fills in a form, which takes too long (coffee break) and its session timeouts, so when she clicks the SelectItem, the DataSource will receive a timeout-occured-error.
The user is kindly requested to log in again, and then being user friendly, she can continue her work from the very place, so she clicks the SelectItem again, which will show "No items to show" without retrying to load the data.
In my understanding, SelectItem is expected to retry to load the data on dropdown event until it succeeds (the same is true for latter on-demand data fetches if there are any).
SmartClient Version: v11.1p_2017-09-27/LGPL Development Only (built 2017-09-27)
Please see a code sample below.
Note: the DataSource JSP below returns an error for the first and then every second time.
However, there are be cases when this data load is unsuccessful for the first time, but would succeed for a second time if it happened.
One of these cases is when the user fills in a form, which takes too long (coffee break) and its session timeouts, so when she clicks the SelectItem, the DataSource will receive a timeout-occured-error.
The user is kindly requested to log in again, and then being user friendly, she can continue her work from the very place, so she clicks the SelectItem again, which will show "No items to show" without retrying to load the data.
In my understanding, SelectItem is expected to retry to load the data on dropdown event until it succeeds (the same is true for latter on-demand data fetches if there are any).
SmartClient Version: v11.1p_2017-09-27/LGPL Development Only (built 2017-09-27)
Please see a code sample below.
Code:
public void onModuleLoad() { Canvas canvas = new Canvas(); RestDataSource selectDS = new RestDataSource(); selectDS.setDataURL("http://127.0.0.1:8888/dummyLookupData.jsp"); DynamicForm form = new DynamicForm(); SelectItem item = new SelectItem(); item.setOptionDataSource(selectDS); item.setDisplayField("display"); item.setValueField("value"); form.setItems(item); item.setAutoFetchData(false); canvas.addChild(form); canvas.draw(); }
Code:
<% String requestedValue = request.getParameter("value"); if (requestedValue != null || "false".equals(session.getAttribute("last_succeed"))) { if (requestedValue == null) session.setAttribute("last_succeed", "true"); %> <response> <status>0</status> <startRow>0</startRow> <endRow>2</endRow> <totalRows>3</totalRows> <data> <% if (requestedValue == null || requestedValue.equals("1000") ) { %> <record><value>1000</value><display>1 thousand</display></record> <%} if (requestedValue == null || requestedValue.equals("2000") ) { %> <record><value>2000</value><display>2 thousand</display></record> <%} if (requestedValue == null || requestedValue.equals("3000") ) { %> <record><value>3000</value><display>3 thousand</display></record> <% } %> </data> </response> <% } else { session.setAttribute("last_succeed", "false"); %> <response> <status>-1</status> <data>Some error, which won't happen on next refresh.</data> </response> <% } %>
Comment