Login Register

xhrPost 1.0 doesn't work but .9 does

I am using websphere (application server 6)/ rad (7.0) ibm environment to develop portlets

I am trying to receive a string with an xhrPost. The string is a 2d array (and after i get this working i will want to send it to my grid code).... but that's after i get this working (hopefully you can help)

This exact code IS WORKING with .9 BUT NOT with 1.0

and it's extremely simple code.... (please let me know if it's working in your environment)

here's my post (i'll give you the full jsp below):

dojo.xhrPost( {
url: '<%=renderResponse.encodeURL(renderRequest.getContextPath() + "/RestyDataLoad")%>',
handleAs: 'text',
timeout: 10000,

load: function(response,ioArgs)
{
var mainForm = dojo.byId('mainTbl');
mainForm.innerHTML = response;
dojo.parser.parse(mainForm);
dijit.byId('noEmplIDDialog').hide();
return response;
},
error: function(response, ioArgs)
{
alert('HTTP Status Code in callRestyDataLoad: ' + ioArgs.xhr.status);
},
form: 'noEmplID'
});

Here's the Servlet side:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String html="[[ \"7\", \"10\", \"A01034\", \"Queued\", \"728\"],[ \"2\", \"taco\", \"A01034\", \"Queued\", \"729\"]]";
System.out.println("html:" + html);
response.setContentType("text/html");
response.setHeader("Cache-Control", "no-cache");
response.getWriter().write(html);
}

TO TEST THIS YOU HAVE TO PRESS THE CLICK HERE AND THEN ENTER THE NUMBER WHERE IT SAYS "FOR TESTING PURPOSES" THIS WILL CALL THE FUNCTION WITH THE POST IN IT.

FULL JSP

<%@page session="false" contentType="text/html"
pageEncoding="ISO-8859-1"
import="java.util.*,javax.portlet.*"%>
<%@taglib uri="http://java.sun.com/portlet" prefix="portlet"%>

<%
com.foo.AdminPortletSessionBean sessionBean = (com.foo.AdminPortletSessionBean) renderRequest
.getPortletSession()
.getAttribute(
com.foo.AdminPortlet.SESSION_BEAN);

String emplID = (String) renderRequest
.getPortletSession()
.getAttribute(
com.foo.AdminPortlet.EMPLID);

%>

<head>

<link rel="stylesheet"
        href="<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/_fooAdmin/jsp/html/style/pkiStyle.css") %>"
        type="text/css">
<link rel="stylesheet"
        href="
<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/_fooAdmin/jsp/html/dojo/dojo/resources/dojo.css") %>
"
        type="text/css">
<link rel="stylesheet"
        href="<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/_fooAdmin/jsp/html/dojo/dijit/themes/tundra/tundra.css") %>"
        type="text/css">

<script type="text/javascript"
        src="
<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/_fooAdmin/jsp/html/dojo/dojo/dojo.js") %>
"
        djConfig="parseOnLoad: true"></script>
<script type="text/javascript">
            dojo.require("dijit.layout.ContentPane");
            dojo.require("dijit.form.Button");
            dojo.require("dijit.TitlePane");
            dojo.require("dijit.form.TextBox");
            dojo.require("dijit.Dialog");
                dojo.require("dojo.parser");
                dojo.require("dijit.ProgressBar");                  
                
             
     </script>

<script type="text/javascript">
           
     
               
                function showEmployeeIdDialog()
                {
                        //dijit.byId('indeterminateBar1').domNode.style.display = "none";
           dijit.byId('noEmplIDDialog').show();
               
                }
               
                    function callRestyDataLoad()
                {       
                                        dijit.byId('indeterminateBar1').domNode.style.display = "block";        
                                 
                        dojo.xhrPost( {
                                url: '<%=renderResponse.encodeURL(renderRequest.getContextPath()  + "/RestyDataLoad")%>',
            handleAs: 'text',
            timeout: 10000,

            load: function(response,ioArgs)
          {
                            var mainForm = dojo.byId('mainTbl');
                            mainForm.innerHTML = response;
                            dojo.parser.parse(mainForm);
            dijit.byId('noEmplIDDialog').hide();     
            return response;
          },         
            error: function(response, ioArgs)
          {
            alert('HTTP Status Code in callRestyDataLoad: ' + ioArgs.xhr.status);
          },
              form: 'noEmplID'
          });
                }

               
                function hideCertReqStatusDialog(){
                        dijit.byId('certReqStatusDialog').hide();
                }
               
                dojo.addOnLoad(
                    function(){
                                if ("<%=emplID%>" != "<%=emplID%>") {
                                        dijit.byId('noEmplIDMsg').domNode.style.display = "none";
                                        dijit.byId('loadMsgPane').domNode.style.display = "block";
                                        dijit.byId("emplID").setValue("<%=emplID%>");
                                        callRestyData();
                                       
                                }
                                else {       
                                dijit.byId('loadMsgPane').domNode.style.display = "none";
                                dijit.byId('noEmplIDMsg').domNode.style.display = "block";
                                }
            });

 </script>
</head>

<body class=tundra>

</form>
</div>

<div dojoType="dijit.Dialog" id="noEmplIDDialog"
        title="Enter Employee ID"  style="font-size: 14px; width:320px">


<form id="noEmplID">
<table align="center">
        <tr>
                <td><label>Employee ID:</label></td>
                <td><input dojoType=dijit.form.TextBox size="9" maxlength="9"
                        type="text" id="emplID" name="emplID">
</td>
        </tr>
        <tr>

                        <td colspan="3" align="center">
                <button  dojoType=dijit.form.Button type="submit"
                        onclick="callRestyDataLoad()">
Submit</button>
                </td>
        </tr>

        <tr>
       
                <td  colspan="3" align="center">
                <div style="width:190px" id="indeterminateBar1" indeterminate="true" dojoType="dijit.ProgressBar"></div>
                </td>
        </tr>
</table>
</form>
</div>

<!-- Main table -->

<div id="mainTbl" align="center">

<div dojoType="dijit.layout.ContentPane" id="noEmplIDMsg" style="width:75%">
        <p style="font-size: 16px; color: red">An error has occurred while retrieving your Employee ID.
        <p style=:"font-size: 14px">You will need to contact the helpdesk to get this error fixed.<br> In the meantime, you can manually enter your Employee ID to continue using the application by clicking <a href="javascript:showEmployeeIdDialog()">here</a>.<br>For testing purposes, use 000108500 as the Employee ID.
</div>
<div dojoType="dijit.layout.ContentPane" id="loadMsgPane">
<p style="font-size: 16px">Loading Restaurants
<div style="width:200px" id="loadingBar" indeterminate="true" dojoType="dijit.ProgressBar"></div>
</div>
</div>
</body>

ANY SUGGESTIONS OF WHY IT won't work in 1.0 but will with .9 would b great... i have been using beyond compare file comparison software to compare the dojo.js.uncompressed.js files for both, but haven't seen anything in there that is much different. Is there another file i can look at? Basically, it's falling through to the error code instead of producing the array like it does in .9, but i need 1.0 to create the grid... i am wondering if i could take the grid stuff and put it in .9's dojox... but haven't tried that yet.... In firebug it usually lands on this error after the button is pressed:

dojo "console is not defined
toString()dojo.js (line 20)
[Break on this error] if(typeof dojo=="undefined"){(function(){if(typeof this["djConfig"]=="undefined"..."

or says that dojo/regexp.js is the last file hit

I looked at the regex js for both .9 and 1.0 and didn't see anything in there that would seem to be that much different from the original code... please look at these files to see if you find anything... or please let me know if there has been a change between the two versions for xhr post....

i also tried looking at the porting guide for .9 to 1.0 and didn't find anything about xhr.... thanks for all your help on this... this code is urgent...thanx again!!! :) -j

you should probably file this as a bug report

trac.dojotoolkit.org, user=guest, pw=guest

please include code as attachments

will do- thanks!!!

will do, thanks for taking a look... i needed the reality check... thanks again! -J

ticket #5323 is hard to read

it's best to attach code to trac using the attach file button. As you can see, it munges text in the description.

Also, the shorter the description and example, the better.