Opened 12 years ago

Closed 11 years ago

#5323 closed defect (invalid)

xhrPost 1.0 doesn't work but .9 does

Reported by: guest Owned by: James Burke
Priority: high Milestone:
Component: IO Version: 1.0
Keywords: xhr, .9, 1.0 Cc:
Blocked By: Blocking:

Description

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 thisdjConfig?=="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

fyi- This may have something to do with the form attribute... if i take that out and add "content" like content : "what i am posting" instead of form: "what i am posting" it works for a second, but then the page reloads (not sure y).

Change History (3)

comment:1 Changed 12 years ago by Adam Peller

Component: CoreIO
Owner: changed from anonymous to James Burke

comment:2 Changed 12 years ago by James Burke

I do not have websphere or a portlet environment, so I cannot test this code. Also, for future reference, please attach test files via the Attach File button, so that the source is maintained correctly.

So the problem seems to be the dojo.xhrPost call to the RestyDataLoad? server endpoint? If so, I would use Firebug to put a breakpoint in the load callback function and step through that code to see if an error is thrown in there. If there is an error in there, then the error path will be followed.

comment:3 Changed 11 years ago by James Burke

Resolution: invalid
Status: newclosed

Closing this out since there is no new information. Feel free to reopen with more info.

Note: See TracTickets for help on using tickets.