DynamicForm double request on fetching data

Hi,

I’ve got a DynamicForm bound on fetch operation to an URL used to retrieve form data.

autofetchdata is not set to true, I call explicitly fetchData() on my form but the URL is invoked twice instead of once.

Please find the corresponding code attached, the form is called “missionForm” and the datasource “missionsDS”

Here are the twor request as shown in developper console :

First one:

{
    actionURL:"http://localhost:8080/mss/isomorphic/HttpProxy", 
    showPrompt:false, 
    prompt:"Finding records that match your criteria...", 
    transport:"xmlHttpRequest", 
    useSimpleHttp:true, 
    promptStyle:"dialog", 
    params:{
        data:"<data xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\" xsi:type=\"xsd:Object\"><url>http://localhost:8887/createMission?templateMid=Template-2&description=s&alertTS=2009-02-17Z&alertMsg=Message%20sample%20updated&alertMmsi=1&alertStatus=Pending</url><httpMethod>GET</httpMethod><params xsi:type=\"xsd:Object\"></params><requestBody></requestBody></data>"
    }, 
    httpMethod:null, 
    contentType:null, 
    sendNoQueue:true, 
    isProxied:true, 
    callback:{
        target:null, 
        methodName:"$37c"
    }, 
    willHandleError:true, 
    serverOutputAsString:true, 
    clientContext:{
        requestIndex:1
    }, 
    data:null
}

Second one:

{
    actionURL:"http://localhost:8080/mss/isomorphic/HttpProxy", 
    showPrompt:true, 
    transport:"xmlHttpRequest", 
    useSimpleHttp:true, 
    promptStyle:"dialog", 
    params:{
        data:"<data xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\" xsi:type=\"xsd:Object\"><url>http://localhost:8887/createMission?templateMid=Template-2&description=s&alertTS=2009-02-17Z&alertMsg=Message%20sample%20updated&alertMmsi=1&alertStatus=Pending</url><httpMethod>GET</httpMethod><params></params><requestBody></requestBody></data>"
    }, 
    httpMethod:null, 
    contentType:null, 
    sendNoQueue:true, 
    isProxied:true, 
    callback:{
        target:null, 
        methodName:"$37c"
    }, 
    serverOutputAsString:true, 
    data:null
}

The only difference seems to be the prompt dialog for criteria matching and that’s maybe the origin of the problem.
I tried to set showPrompt to false on my datasource but there are still two requests instead of one.

I saw another similar (“Multiple post …”) but in my case I’ve got no filtering and no autofetchdata set to true so do you have any idea ?

Thank you in advance,
Sébastien

createMission.html (8.19 KB)

Subtle signs indicate the first request is coming from a grid. You don’t show one that would be issuing a request in your .html file, so it’s probably in your included file scripts/core.js.

By the way, autoFetchData is set on components, no on the DataSource.

No sorry here is core.js content :

// Deployment variables
var ipAddress = "XX.XX.XX.XX";

var alertMgtServiceURL = "http://" + ipAddress + ":8888/alertMgt";
var alertMgtServiceWSDL_URL = alertMgtServiceURL + "?wsdl";
var updateMissionURL = "http://localhost:8887/updateMission";
var deleteMissionURL = "http://localhost:8887/deleteMission";

function getUrlParam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return unescape(results[1]);
}

I agree for autoFetchData it’s a mistake from my code but I just wanted to notice that it was set to false on my components (default value according to SmartClient documentation).

Any other idea ?

Hmm, there’s got to be a grid somewhere. A DynamicForm with optionDataSource set or connected to a DataSource with foreignKey set will also potentially issue a fetch, but you don’t have those.

Try using the Watch tab of the Developer Console to ensure you don’t have code floating around that is somehow creating other components.

Watch tab revealed to me a component which is not drawn, it’s a pickListMenu which must be the one attached to the status combo box displayed into the form

I attached two screenshots :

  • not drawn is what I’m getting first
  • drawn is what I’m getting after forcing the component to be drawn from the developer console

When I remove the ‘select’ type for status field in form ‘missionForm’, the problem is fixed, but I cannot explain how this can generate two requests and I have to present this field as a select list anyway so this cannot be a workaround.

Is it a bug, any other rational explanation ?

PickListMenu is a class created by SelectItems and ComboBoxItems to show options. It’s normal that with a SelectItem, it would be present and undrawn and that it would cause a fetch, but only if you had a setting for either optionDataSource or foreignKey on either the SelectItem directly or on a DataSource.

The reason the SelectItem requests data at draw() is so that it can provide type-ahead if a user tabs into the SelectItem and starts typing (without opening the list of options).

A “carpet bombing” approach to eliminate this request would be to change the default for autoFetchData:

isc.SelectItem.addProperties({autoFetchData:false})

But again, you’ve got a mystery here because in the code you’ve shown, you don’t have any settings that would cause this fetch.

:slight_smile: yes it’s more than “carpet bombing” but thank for the hint until we found the exact origin.

Maybe an idea, in this form the only enabled field is the status one (SelectItem) so it could eventually triggers the same behavior that the one you described when the user tabs into and starts typing.

Don’t you think so ?

Tomorrow I will try to reproduce that “mystery/bug” in an isolated sample.

Aha, you’re right. “status” is a SelectItem with no valueMap in a databound form. Since you haven’t provided a valueMap it thinks you want it to show all distinct values of “status” that are available in any record in the DataSource. Add a valueMap to prevent this (even if it’s initially blank, like valueMap:{}).

That’s it, it works fine now, nice that we found the problem together, thank you for your help and hints !