Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java web framework with RESTful JSON services, HTML5 & jQuery ajax

It is almost year 2013, HTML5 age. jQuery is the de-facto standard for web Javascript-ing.

This link was good for year 2010: https://stackoverflow.com/questions/3882082/rest-json-web-services-java-ee-framework

I am looking for Java web framework that will expose domain classes via RESTful JSON web services. Then will [hopefully] generate web forms for those domain classes. And uses jQuery ajax to communicate with server for sending/receiving JSON data and populate in HTML.

All web UI processing should be in client browser. Server should just transmit static HTML5 pages. No server-side processing like JSP.

UPDATE. I must clarify that my question point is not what framework to use for web-services creation. (There are a lot like Apache CXF, Spring MVC web services). It is not also about jQuery or not. But Java framework that will save time for boilerplate coding of client-server communication.

Groovy & Scala are great things, but they are not Java, but JVM languages. (Imagine telling your teammates "We should learn Java-like language with some differences to start using a new framework." )

Bottom line:

Java web framework + static HTML5 pages + JSON interaction

like image 655
Paul Verest Avatar asked Oct 05 '22 16:10

Paul Verest


2 Answers

Your right it is almost 2013 why not just expose your Rest Web Services with nodeJS!

If your adamant about Java then look at Spring MVC as an alternative to Jax-RS. With Spring (and Jackson for JSON marshall/unmarshall) you can do something like:

@Controller
@RequestMapping("/resource")
public class ResourceController
{
    @Autowired
    private ResourceService resourceService;

    @RequestMapping(value="/{id}", method=RequestMethod.GET)
    public @ResponseBody Resource getResource(@PathVariable Integer id)
    {
        return resourceService.lookup(id);
    }
    ...
}

public class Resource
{
    @JsonProperty("id")
    private int id;
    @JsonProperty("resourceName")
    private String name;
    ...
}

Hope that helps.

like image 196
ramsinb Avatar answered Oct 10 '22 04:10

ramsinb


Did you trying exploring Spring for domain-rest mapping and Grails's Scaffolding ? Try exploring these links to achieve your goal :

  1. Domain mapping to REST endpoint
  2. More on domain rest antipattern
  3. Generate whole application using domain model using scaffolding
like image 45
Saurabh Avatar answered Oct 10 '22 04:10

Saurabh