Reputation: 21
I'm getting an error while integrating spring and extjs. It's just simple code of a login page.
Error details are as follows
Failed to load resource: the server responded with a status of 500 (Internal Server Error) ext-all.js:21 Uncaught TypeError: Cannot read property 'isProvider' of undefined
with the warning
No mapping found for HTTP request with URI [/LoginExt_Spring_20-06/services/api.js] in DispatcherServlet with name 'services'
//This is my controller code
Ext.define('myapp.controller.LoginController',{
extend:'Ext.app.Controller',
stores:['LoginStore'],
Views:['LoginView','HomeView'],
refs:[
{ ref:'loginview'},
{ref:'homepage'}
],
init:function(){
this.control({
'loginview button[action=login]':{
click:'onLogin'
},
'loginview button[action=cancel]':{
click:'onCancel'
}
});
},
onLogin:function(button){
var loginForm=button.up('form[name=loginview]');
var loginValues=loginForm.getValues();
var login=loginForm.up('container[name=viewport]');
var home=login.down('grid[name=homepage]');
//console.log('loginValues are: '+loginValues.username);
formController.authenticate(loginValues);
//if(loginValues.username=='admin'&&loginValues.password=='password'){
Ext.Msg.alert('status','successfull login');
loginForm.setVisible(false);
home.setVisible(true);
//}else Ext.Msg.alert('status','Invalid credentials...');
},
onCancel:function(){
var loginForm=button.up('form[name=loginview]');
this.loginForm.getForm().reset();
}
});
//code in Store
Ext.define('myapp.store.LoginStore',{
extend:'Ext.data.Store',
model:'myapp.model.LoginModel',
autoLoad:true,
proxy:{
type:'direct',
directfn:formController.authenticate,
reader:{
type:'json'
}
}
});
// I included
Ext.require('Ext.direct.*', function() {
Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
});
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Jsp page</title>
<script type="text/javascript" src="resources/extjs/ext-all.js"></script>
<link rel="stylesheet" href="resources/css/ext-theme-neptune-all.css">
<script type="text/javascript" src="services/api.js"></script>
<script type="text/javascript" src="resources/script/app.js"></script>
<script type="text/javascript">Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);</script>
</head>
<body>
</body>
</html>
Application Initializer
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
public class AppInitializer implements WebApplicationInitializer{
@Override
public void onStartup(ServletContext container) throws ServletException {
AnnotationConfigWebApplicationContext context=new AnnotationConfigWebApplicationContext();
context.register(ApplicationConfig.class);
context.setServletContext(container);
ServletRegistration.Dynamic servlet=container.addServlet("Dispatcher", new DispatcherServlet(context));
servlet.setLoadOnStartup(1);
servlet.addMapping("/services/*");
}
}
Java Controller
@ExtDirectMethod
public String authenticate(@RequestParam Login cred){
loginDao.userCredentials(cred);
return "HomeView";
}
Upvotes: 2
Views: 215