Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
mam2009
Posts: 10
Registered: ‎10-20-2009
My Device: Not Specified
Accepted Solution

Urgent Help Please! Ajax Does Not Work in BB8900

Hi everybody,

in a big trouble.. I have developed a very simple web application using Java, Spring, and AJAX. Page to login, on success, a form appears where the user has to fill and save thereafter.

 

In the form a number of select lists (drop-down combobox) are to be used. Some of them are disabled for the first time, by some actions (example filling a text field or selecting another list), the lists are to be enabled and filled using AJAX from a servlet.

 

This works with PC, with iPhone, with HTC (IE, Firefox, Opera...). But in BB9000 Emulator and in a BB8900 device I face the following problems (despite of that I enabled JavaScript):

1) text fields are disabled-enabled correctly, but drop-down lists are not disabled.

2) AJAX does not work, e.g., select a city does not trigger AJAX to bring the streets of that city.

3) DOM does not work .. e.g. pressing a button, no new <tr> <td> ... elements are added to the a table in the form.

 

Please help since my deadline is coming and I am in short of time!

 

Regards,

Please use plain text.
Developer
jwargo
Posts: 395
Registered: ‎12-18-2008
My Device: BlackBerry Torch 9800
My Carrier: AT&T

Re: Urgent Help Please! Ajax Does Not Work in BB8900

JavaScript is turned off by default in the browser - have you checked to see if it's enabled?

Please use plain text.
New Developer
mam2009
Posts: 10
Registered: ‎10-20-2009
My Device: Not Specified

Re: Urgent Help Please! Ajax Does Not Work in BB8900

thank you for the reply...

I have already enabled it in Browser options

regarding the request to the servlet, it works, I have debugged it. The database connection is built and the query returns correct answer.

I still fight with the problem of getting the data back to the client. Maybe, the onreadystate does not work. The problem maybe a Javascript support leak. As I told you:

<input id="myText" value="" type="text" disabled/>

this works fine. But this does not work, the list is enabled ??

 

<select id="" disabled>
 <option></option>
</select>

Please point me to any place that discuss these issues.

Regards!

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Urgent Help Please! Ajax Does Not Work in BB8900

Can you post your javascript that is not working so that we can take a look at it??

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
New Developer
mam2009
Posts: 10
Registered: ‎10-20-2009
My Device: Not Specified

Re: Urgent Help Please! Ajax Does Not Work in BB8900

Thanks for your replies. The following is my code.

 

loadlists.js:

var xmlhttp;

function initAjax() {
    try {
        if( window.XMLHttpRequest ) {
            xmlhttp = new XMLHttpRequest();
        } else if( window.ActiveXObject ) {
            xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
        }
    } catch( e ) {
        alert( "Error: " + e );
    }
    
}

function refreshStrList(cityId) {
    initAjax();
    if (xmlhttp==null) {
        alert ("Your browser does not support Ajax!");
        return;
    } else if(cityId == "") {
        var strList = document.getElementById("strlist");
        strList.length = 1;
        return;
    }
    var url = ".../streets.jsp?cityId=" + cityId;
    xmlhttp.onreadystatechange = cityStateChanged;
    xmlhttp.open("GET", url, true);
    xmlhttp.send(null);
}

function cityStateChanged() {
    var strList = document.getElementById("strlist");
    strList.length = 1;
    var no = new Option();
    
    if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") {
        strLis.disabled = false; 
        var showdata = xmlhttp.responseText;
        var strar = showdata.split("_$_");
        // loop for filling the street list
    }

}

 The JSP form:

<!-- .... -->
<form:form method="post" commandName="ereignis" name="myFrom">
 <table border="0" id="mainTable">
  <tbody id="mainTableBody">
   <tr>
    <td>City</td>
    <td>
     <form:select path="cityId" id="citylist" onchange="refreshStrList(this.value)">
       <form:option value=""/>
       <form:options items="${cities}" itemValue="id" itemLabel="name"/>
     </form:select>
    </td>
   </tr>
   <tr>
    <td>Street</td>
    <td>
     <form:select path="streetId" id="strlist" disabled="true"> <!-- the list is always enabled even before changing the citylist value-->       <form:option value="">---</form:option>
     </form:select>
    </td>
   </tr>
  </tbody>
 </table>
</form:form>

Problems:

1- while <form:input ... disabled="true"/> works fine, the above red code for disableing the combobox does not work, the lists are always enabled.

2- Ajax calls the servlet and the data is correctly loaded and I see that in the logger. But the data is not copied to the strList.

 

Thanks again for your time.

 

Please use plain text.
New Developer
mam2009
Posts: 10
Registered: ‎10-20-2009
My Device: Not Specified

Re: Urgent Help Please! Ajax Does Not Work in BB8900

Hi again,

I have changed the javascript code for filling the lists from

 

for(var i = 0; i < n; i++) {
  strlist[i] = new Option(.., ..);
}

 

 

to:

for(var i = 0; i < n; i++) {
  strlist.options[strlist.options.length] = new Option(.., ..);
}

 

 

And then in BB Simulator 9000, the list was filled out, but the mobile set BB 8900 still not working, the strlist is always empty.

The other problems still present in the simulator as well as the mobile set. E.g. list disable is not working, and DOM code for adding <tr> and <td> for the table do not work.

 

Thanks for any help

Please use plain text.
New Developer
mam2009
Posts: 10
Registered: ‎10-20-2009
My Device: Not Specified

Re: Urgent Help Please! Ajax Does Not Work in BB8900

Hi,

strangely, I could make it "more-or-less" work in the simulator as well as the BB 8900 device. The worked version uses:

strlist.options[strlist.options.length] = new Option("Text 1", "Value 1");

 ??? I had to disable the javascript first, clear the cache, close the browser, open it again, enable the javascript and run the web application again. Since there was no Javascript Error when filling out the lists, DOM works fine.

 

I could not make drop-down lists "disabled", nevertheless, the list object has the property "disabled" set to true as the debugger showed? Somehow, I can live with that for a while :-)

 

Thanks for all..

Please use plain text.