View Full Version : Redirection for Login Page

9 May 2012, 10:45 PM
Hello folks

I have developed an extjs email application and added a spring security module to it for authentication.
Now everything works fine i.e User logs in->performs operation->logs out.
But after log out I have redirected the user back to the login page using.

<security:logout logout-success-url="/login.jsp"/>

in my spring security.xml file.
The redirect works but,if I try to log in again I get an error in firebug

Ext.util.JSON is undefined


obj = Ext.util.JSON.decode(action.response.responseText);

under the Response tab in firebug

{ success: false, errors: { reason: 'Login failed. Try again.' }}
I have this in my login.js

formBind: true,
// Function that fires when user clicks the button

Ext.Msg.alert('Status', 'Login Successful!', function(btn, text){
if (btn == 'ok'){
window.location = 'index.action';


failure:function(form, action){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);

Ext.Msg.alert('Login Failed!', obj.errors.reason);
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText);


Please correct me where is the mistake.


11 May 2012, 4:35 AM
Maybe ext lib not loaded? Look in firebug js tab.

11 May 2012, 4:46 AM
If I remember correctly, I think a Form Panel already decodes the response for you as JSON, so you can go directly after action.errors.reason without having to decode.

If you want to see exactly what's in the action object, you can run it through my favorite debugging function, to dump all of its attributes/values:

dumpObject: function(obj) {
console.log('===== >>> START Object enumeration =============================');
for (props in obj) {
console.log('property: ' + props);
console.log('value: ' + obj[props] );
console.log('===== <<< END Object enumeration ===============================');


You can also run it against specific child properties of the action object:


11 May 2012, 4:56 AM
My previous post wrong, here error:

obj = Ext.util.JSON.decode(action.response.responseText); // Ext.util dont have JSON class
// use
obj = Ext.JSON.decode(action.response.responseText);


11 May 2012, 5:23 AM
@redraid No there is no such fle missing.I did not find it even when i searched the framework folder.What is th exact file name?can you please tell.
Will try your solution and debug to fix it.

@friend:Good to see you after long time.
I will try it and let you know.

Thanks to both. :)

11 May 2012, 6:04 AM
@sachintaware: Congrats on the making the leap to Spring Framework/MVC/Security. It looks like you're making good progress!

As for JSON encoding/decoding, there are two wrapped convenience methods for doing this:

Ext.decode() (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext-method-decode) and Ext.encode() (http://docs.sencha.com/ext-js/4-1/#%21/api/Ext-method-encode).

13 May 2012, 11:43 PM
@friend: Yes,made some progress,but was not possible without some great support by the forum members like you,otherwise I would have given up long back.

But I get stuck more often then not.
I am trying to debug this thread issue and I have another one posted earlier and not resolved yet.

@friend @redraid here it is.I get this in Mozilla but not in Chrome(not tested on other browsers though).
Here is the thread: http://www.sencha.com/forum/showthread.php?192022-Mail-function-using-springmvc-and-extjs

Please go through and post your comments/views.I have to make it live ASAP.

Thanks for your continues support.