Here's the code:
My problem here is that I want to handle any error in the fetch on my own. For example if the reply came with the error code I want to clean up the SelectItem and make it disable.
here's example of the request this item sends:
{
dataSource:"dm_server",
operationType:"fetch",
showPrompt:true,
requestId:"dm_server$62746",
fallbackToEval:false,
bypassCache:true
}
and here's the reply
[
{
invalidateCache:false,
isDSResponse:true,
queueStatus:-1,
status:-606,
data:null
}
]
Unfortunately, the DataArrivedHandler never triggered for the error code, but works just fine for the non-error one. What can I do to handle the error on my own here ?
I know that in newer versions I can set callback to the dsRequestProperties ( dsRequestProperties .setCallback(new DSCallback() {...} ), but I use the old one: SmartClient Version: v9.0p_2014-04-23/PowerEdition Deployment (built 2014-04-23) (this is about support of the old clients).
Code:
public class SimpleDiscoveryDMSelectionLayout {
private final SelectItem dmServerItem =
new SelectItem("dm_server_id", "My Server");
public SimpleDiscoveryDMSelectionLayout() {
this.dmServerItem.setOptionDataSource( DSFactory.getDS( DSType.DM_SERVER ) );
this.dmServerItem.setValueField("dm_server_id");
this.dmServerItem.setDisplayField("dm_name");
this.dmServerItem.setAllowEmptyValue(false);
this.dmServerItem.setAlign( Alignment.LEFT );
this.dmServerItem.setDefaultToFirstOption( true );
DSRequest dsRequestProperties = new DSRequest();
dsRequestProperties.setWillHandleError(true);
this.dmServerItem.setOptionFilterContext(dsRequestProperties);
this.dmServerItem.addDataArrivedHandler(new com.smartgwt.client.widgets.form.fields.events.DataArrivedHandler(){
@Override
public void onDataArrived(DataArrivedEvent event) {
//this one never called for error
System.out.println("Arrived");
}
});
this.dmServerItem.setValueFormatter(new FormItemValueFormatter(){
@Override
public String formatValue(Object value, Record record,
DynamicForm form, FormItem item) {
String dispValue = SimpleDiscoveryDMSelectionLayout.this.dmServerItem.getDisplayValue(value.toString());
if (dispValue == null) {
return "";
}
return dispValue;
}
}
);
}
here's example of the request this item sends:
{
dataSource:"dm_server",
operationType:"fetch",
showPrompt:true,
requestId:"dm_server$62746",
fallbackToEval:false,
bypassCache:true
}
and here's the reply
[
{
invalidateCache:false,
isDSResponse:true,
queueStatus:-1,
status:-606,
data:null
}
]
Unfortunately, the DataArrivedHandler never triggered for the error code, but works just fine for the non-error one. What can I do to handle the error on my own here ?
I know that in newer versions I can set callback to the dsRequestProperties ( dsRequestProperties .setCallback(new DSCallback() {...} ), but I use the old one: SmartClient Version: v9.0p_2014-04-23/PowerEdition Deployment (built 2014-04-23) (this is about support of the old clients).
Comment