View Full Version : SpringSecurity Failed. Return False to JS

16 Oct 2012, 9:38 AM
I am using Spring security. I have a ext-js method which calls Java method.

Js method

testMethod: function(idpass, cb, scope){
this.onAjaxResponse = Ext.bind(this.onAjaxResponse, scope || window, [cb, scope], true);
url : 'remote/employee/testMethod/'+idpass,
success: this.onAjaxResponse,
failure: this.onAjaxResponse

The above method is called from a DetailPanel when a button is pressed.

submitClicked: function(dat){
app.employeeService.testMethod('name:bill', this.onSubmitClicked, this);

onSubmitClicked: function(data){
this.updateMessage('Action Successful');

Java File.

@RequestMapping(value = "/testMethod/{name}", method = {RequestMethod.POST,RequestMethod.GET })
public String testMethod(@PathVariable("name") String name, HttpSession session, ModelMap model){
//some logic..
return returnJson(model, response);

Now the Java Method is not executed for USER role.
How can I capture this and display an Alert to user that Access is Denied for the current user ?

22 Oct 2012, 8:58 AM
What is onAjaxResponse doing? Are you passing the callback to onSubmitClicked or wherever you want to handle the failure?

If you are getting a failure in Java you can change the http status code to some fail code like 500 or something and that will trigger the failure callback

22 Oct 2012, 10:22 AM
I figured it out, such an easy way, I got it done myself.
Anyhow Thanks for your time.

this.onAjaxResponse. I wrote an alert in this method. Access Denied.
Thats cool.

Thank you.