Skip to content

Commit 9ccfc1b

Browse files
author
noobandy
committed
Data Table Ajax Source
1 parent 4f9b6e0 commit 9ccfc1b

File tree

17 files changed

+697
-0
lines changed

17 files changed

+697
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package in.anandm.apps.template.application.controller;
2+
3+
import java.text.DateFormat;
4+
import java.util.Date;
5+
import java.util.Locale;
6+
7+
import javax.servlet.http.HttpServletRequest;
8+
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
11+
import org.springframework.stereotype.Controller;
12+
import org.springframework.ui.Model;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RequestMethod;
15+
import org.springframework.web.bind.annotation.RequestParam;
16+
17+
/**
18+
* Handles requests for the application home page.
19+
*/
20+
@Controller
21+
@RequestMapping(value="/ajax")
22+
public class AjaxController {
23+
24+
private static final Logger logger = LoggerFactory.getLogger(AjaxController.class);
25+
26+
/**
27+
* Simply selects the home view to render by returning its name.
28+
*/
29+
@RequestMapping(value = "/dashboard-boxrefresh-demo", method = RequestMethod.GET)
30+
public String refreshDashBoard(Locale locale, Model model) {
31+
logger.info("Welcome home! The client locale is {}.", locale);
32+
33+
Date date = new Date();
34+
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
35+
36+
String formattedDate = dateFormat.format(date);
37+
38+
model.addAttribute("serverTime", formattedDate );
39+
40+
return "dashboard-boxrefresh-demo";
41+
}
42+
43+
@RequestMapping(value = "/browserData", method = RequestMethod.GET)
44+
public String browserData(Locale locale, Model model,
45+
@RequestParam(value="iDisplayLength") Integer iDisplayLength,
46+
@RequestParam(value="iDisplayStart") Integer iDisplayStart,
47+
@RequestParam(value="sSearch") String sSearch,
48+
HttpServletRequest request
49+
) {
50+
/*Search search = new Search(User.class);
51+
search.addFilterILike("userName", sSearch);
52+
search.setFirstResult(iDisplayStart);
53+
search.setMaxResults(iDisplayLength);
54+
List<Sort> sorts = new ArrayList<Sort>();
55+
Sort.
56+
search.setSorts(sorts)*/
57+
logger.info("Welcome browser Data! The client locale is {}.", locale);
58+
logger.info("iDisplayLength {}.", iDisplayLength);
59+
logger.info("iDisplayStart {}.", iDisplayStart);
60+
logger.info("sSearch {}.", sSearch);
61+
62+
Date date = new Date();
63+
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
64+
65+
66+
67+
model.addAttribute("aaData", DataTableHelper.getRecords(iDisplayLength, iDisplayStart));
68+
69+
return "result";
70+
}
71+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
*
3+
*/
4+
package in.anandm.apps.template.application.controller;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @author anandm
10+
*
11+
*/
12+
public class Browser implements Serializable {
13+
14+
/**
15+
*
16+
*/
17+
private static final long serialVersionUID = 1L;
18+
private String renderingEngine;
19+
private String browser;
20+
private String plateform;
21+
private String engineVersion;
22+
private String cssGrade;
23+
/**
24+
*
25+
*/
26+
public Browser() {
27+
super();
28+
29+
}
30+
public String getRenderingEngine() {
31+
return renderingEngine;
32+
}
33+
public void setRenderingEngine(String renderingEngine) {
34+
this.renderingEngine = renderingEngine;
35+
}
36+
public String getBrowser() {
37+
return browser;
38+
}
39+
public void setBrowser(String browser) {
40+
this.browser = browser;
41+
}
42+
public String getPlateform() {
43+
return plateform;
44+
}
45+
public void setPlateform(String plateform) {
46+
this.plateform = plateform;
47+
}
48+
public String getEngineVersion() {
49+
return engineVersion;
50+
}
51+
public void setEngineVersion(String engineVersion) {
52+
this.engineVersion = engineVersion;
53+
}
54+
public String getCssGrade() {
55+
return cssGrade;
56+
}
57+
public void setCssGrade(String cssGrade) {
58+
this.cssGrade = cssGrade;
59+
}
60+
61+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
*
3+
*/
4+
package in.anandm.apps.template.application.controller;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
/**
10+
* @author anandm
11+
*
12+
*/
13+
public class DataTableHelper {
14+
15+
private static final List<Browser> browsers = new ArrayList<Browser>();
16+
static{
17+
for(int i = 0; i < 100; i++){
18+
Browser browser = new Browser();
19+
browser.setBrowser("browser_"+ i);
20+
browser.setCssGrade("cssGrade_"+i);
21+
browser.setEngineVersion("engineVersion_"+i);
22+
browser.setPlateform("plateform_"+i);
23+
browser.setRenderingEngine("renderingEngine_"+i);
24+
browsers.add(browser);
25+
}
26+
}
27+
28+
/**
29+
*
30+
*/
31+
public DataTableHelper() {
32+
super();
33+
34+
}
35+
36+
public static List<Browser> getRecords(Integer noOfRecords,Integer start){
37+
38+
return browsers.subList(start, start+noOfRecords);
39+
}
40+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package in.anandm.apps.template.application.controller;
2+
3+
import java.text.DateFormat;
4+
import java.util.Date;
5+
import java.util.Locale;
6+
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import org.springframework.stereotype.Controller;
10+
import org.springframework.ui.Model;
11+
import org.springframework.web.bind.annotation.PathVariable;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.RequestMethod;
14+
15+
/**
16+
* Handles requests for the application home page.
17+
*/
18+
@Controller
19+
public class DecoratorController {
20+
21+
private static final Logger logger = LoggerFactory.getLogger(DecoratorController.class);
22+
23+
24+
25+
@RequestMapping(value = "/decorators/{decorator}", method = RequestMethod.GET)
26+
public String pages(Locale locale, Model model,@PathVariable(value="decorator") String decorator) {
27+
logger.info("Welcome page! The client locale is {}.", locale);
28+
29+
Date date = new Date();
30+
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
31+
32+
String formattedDate = dateFormat.format(date);
33+
34+
model.addAttribute("serverTime", formattedDate );
35+
36+
return "decorators/"+decorator;
37+
}
38+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package in.anandm.apps.template.application.controller;
2+
3+
import java.text.DateFormat;
4+
import java.util.Date;
5+
import java.util.Locale;
6+
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import org.springframework.stereotype.Controller;
10+
import org.springframework.ui.Model;
11+
import org.springframework.web.bind.annotation.PathVariable;
12+
import org.springframework.web.bind.annotation.RequestMapping;
13+
import org.springframework.web.bind.annotation.RequestMethod;
14+
15+
/**
16+
* Handles requests for the application home page.
17+
*/
18+
@Controller
19+
public class HomeController {
20+
21+
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
22+
23+
/**
24+
* Simply selects the home view to render by returning its name.
25+
*/
26+
@RequestMapping(value = "/", method = RequestMethod.GET)
27+
public String home(Locale locale, Model model) {
28+
logger.info("Welcome home! The client locale is {}.", locale);
29+
30+
Date date = new Date();
31+
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
32+
33+
String formattedDate = dateFormat.format(date);
34+
35+
model.addAttribute("serverTime", formattedDate );
36+
return "index";
37+
}
38+
39+
//apps/pages/forms/general.html
40+
41+
42+
@RequestMapping(value = "/pages/{type}/{page}", method = RequestMethod.GET)
43+
public String pagesOfTypes(Locale locale, Model model,@PathVariable(value="type") String type,@PathVariable(value="page") String page) {
44+
logger.info("Welcome page! The client locale is {}.", locale);
45+
46+
Date date = new Date();
47+
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
48+
49+
String formattedDate = dateFormat.format(date);
50+
51+
model.addAttribute("serverTime", formattedDate );
52+
53+
return "pages/"+type+"/"+page;
54+
}
55+
56+
@RequestMapping(value = "/pages/{page}", method = RequestMethod.GET)
57+
public String pages(Locale locale, Model model,@PathVariable(value="page") String page) {
58+
logger.info("Welcome page! The client locale is {}.", locale);
59+
60+
Date date = new Date();
61+
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
62+
63+
String formattedDate = dateFormat.format(date);
64+
65+
model.addAttribute("serverTime", formattedDate );
66+
67+
return "pages/"+page;
68+
}
69+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
*
3+
*/
4+
package in.anandm.apps.template.application.impl;
5+
6+
import java.io.Serializable;
7+
8+
import javax.persistence.EntityManager;
9+
import javax.persistence.PersistenceContext;
10+
11+
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.springframework.stereotype.Repository;
13+
14+
import com.googlecode.genericdao.dao.jpa.GenericDAOImpl;
15+
import com.googlecode.genericdao.search.jpa.JPASearchProcessor;
16+
17+
/**
18+
* @author anandm
19+
*
20+
*/
21+
@Repository
22+
public class BaseRepository<T,ID extends Serializable> extends GenericDAOImpl<T, ID> {
23+
24+
25+
@Autowired
26+
@Override
27+
public void setSearchProcessor(JPASearchProcessor searchProcessor) {
28+
29+
super.setSearchProcessor(searchProcessor);
30+
}
31+
32+
@PersistenceContext
33+
@Override
34+
public void setEntityManager(EntityManager entityManager) {
35+
36+
super.setEntityManager(entityManager);
37+
}
38+
39+
40+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
*
3+
*/
4+
package in.anandm.apps.template.application.impl;
5+
6+
import in.anandm.apps.template.domain.model.user.User;
7+
8+
import org.springframework.stereotype.Repository;
9+
10+
/**
11+
* @author anandm
12+
*
13+
*/
14+
@Repository
15+
public class UserRepository extends BaseRepository<User, Long> {
16+
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
*
3+
*/
4+
package in.anandm.apps.template.domain.model.group;
5+
6+
/**
7+
* @author anandm
8+
*
9+
*/
10+
public class Group {
11+
12+
}

0 commit comments

Comments
 (0)