PDA

View Full Version : Need assistance on ScriptTagProxy



dlbjr
16 Sep 2009, 11:45 AM
I need to make a secure call to another server like so:
This is an intranet environment



var ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: ' https://link/Authenticate',
method: 'post',
params: { username: 'A129651', password: 'pwdwrd'}
}),
reader: new Ext.data.XmlReader(?????)
});


It returns XML like so:

When it passes:
<authenticate status="passed" />

When it fails:
<authenticate status="failed">Password is incorrect.</authenticate>

I need to know how to make this work and what the XMLReader definition needs to look like to read the status and message passed.

Any assistance would be highly appreciated.

Thank you,

Animal
16 Sep 2009, 11:51 AM
You can't.

As the docs say (the emphasis is in the original)



The content passed back from a server resource requested by a ScriptTagProxy must be executable JavaScript source code because it is used as the source inside a <script> tag.

dlbjr
16 Sep 2009, 11:54 AM
I assume a JSON string return will work? I tried to enforce a json return but this is old school AS400 dinasours I'm dealling with, and they are still tickled pink with XML.

Thanks Animal

Animal
16 Sep 2009, 11:57 AM
Again, as the docs say



In order for the browser to process the returned data, the server must wrap the data object with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy. Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy depending on whether the callback name was passed:


They then show you how this might be done in Java:



boolean scriptTag = false;
String cb = request.getParameter("callback");
if (cb != null) {
scriptTag = true;
response.setContentType("text/javascript");
} else {
response.setContentType("application/x-json");
}
Writer out = response.getWriter();
if (scriptTag) {
out.write(cb + "(");
}
out.print(dataBlock.toJsonString());
if (scriptTag) {
out.write(");");
}

dlbjr
16 Sep 2009, 12:02 PM
--

SreevaniN
23 Sep 2009, 9:45 AM
HI,

Please could you tell me the control flow from the store and the Java code.

How does the request get parsed?

I am still new and sorry for the naive query.

Thanks,
Sreevani

Animal
23 Sep 2009, 9:46 AM
The code example in the docs actually shows you the Java code to set up the response!!!!

Arindam Das
6 May 2010, 12:53 AM
Hi SreevaniN

Kindly see my response here (http://www.extjs.com/forum/showthread.php?89343-ScriptTagProxy-and-XML-Why-doesn-t-Extjs-provide-an-implementation&p=464924#post464924)