null

Possible Dojo Ajax Autocompleter Issue

I have an autocompleter in my form and it works great except for when I type a word, that is in the list, out in its entirety then click onto another field without clicking on the word in the dropdown, hitting tab, or hitting enter. When this happens it submits the text successfully, as it is in the list (forceValidOption="true"), but the id it sets is null.

EX.
Java
    ...
    public void setMyTypeName( final String myTypeName )
    {
        System.out.println( "myTypeType : " + myTypeName );
        this.myTypeName = myTypeName;
    }
   
    public void setMyTypeId( final Integer myTypeId )
    {
        System.out.println( "myTypeId : " + myTypeId );
        this.myTypeId = myTypeId;
    }
    ...

JSP
    ...
    <!-- NOTE: myAction is defined in my applicationContext.xml -->
    <s:url id="getMyTypes" action="myAction" namespace="/mynamespace" method="loadMyTypes" />
    ...

    <s:form method="post" theme="xhtml" namespace="/" action="addRecipe" id="form">
        <sx:autocompleter href="%{getMyTypes}" dataFieldName="myTypes" forceValidOption="true" resultsLimit="-1" label="My Types" name="myTypeName" keyName="myTypeId" />

        <s:textarea label="Description" name="description" cols="80" rows="10" />

        <sx:submit validate="true" />
    </s:form>


The autocopleter field is set with a JSONed map; set up as such:
for( final MyType mt : myTypeList )
{
myTypesMap.put( mt.getName(), mt.getId().toString() );
}
So it has names and ids.

So if "Square" was a name in the drop down and I fully typed out "Square" then clicked on the description field, WITHOUT doing any of the following: clicking the item in the list, pressing tab, or pressing enter. Then click submit. I see the following:
myTypeId : null
myTypeName: Square

However, if do any of the following: clicking the item in the list, pressing tab, or pressing enter. I see:
myTypeId : 1
myTypeName: Square

If I type anything that is not in the list it is cleared as soon as I click on the description field due to the forceValidOption set to true;
Also, if I type just the first 2 letters, "Sq", then it autoCompletes, and if I click on the description field then without doing any of the aforementioned items; I see:
myTypeId : null
myTypeName: Sq
Which is not in my list but still got through.

Also, if I type something in that is not in the list then immediately hit submit I see:
myTypeId : null
myTypeName: ItemNotInList
Which shouldn't happen as I have forceValidOption set to true.

Let me know if I am doing anything wrong, or it is a known issue, or it is just this way.

BTW, I am using the struts 2.1.2 jar that is on the maven repo, and the struts2-dojo-plugin 2.1.2 that is also on the maven repo.

Thanks

-am

Null responseXML on xhrGet with handleAs xml

I am experiencing a similar problem what was posted here and am hoping I can pick up some guidance.

I am making an xhrGet http request to a service returning ATOM message XMLs of the type 'application/atom+xml'.

Currently I have a servlet running that serves to parse my URLs and return a well formed statically stored xml file containing an ATOM message. I am using FireFox 2 with Firebug as an aid on Windows XP.

When my file servlet running in my windows environment returns the ATOM xml the xhrGet call invokes my load function with the reponse data in well a well formed ATOM/XML format. This is good.

When my file servlet is running In an AIX/Unix environment, returning the same static xml files, the same bit of code returns with responseXML null but the responseText holds the response.

Firebug's console shows the well formed ATOM message was received and the xhr.responseText holds the string text. This leads me to believe that the reponse is received but just not handled as 'xml'.

It appears to me that in this case Dojo is failing to resolve and handle the response as XML. Below are my args.

var args = {
url: iUrl,
handleAs: 'xml',
load: readyHandlerMethod,
error: errorHandlerMethod,
timeout: 10000,
scDispHandler: displayHandlerMethod,
scDispHandlerArgs: displayHandlerArgs,
scXslPath: xslFile
};

Something to note, I have inserted some custom arguments so that the invoked load handlers can further invoke other functions and pass along context.

Syndicate content

Back to top