@@ -0,0 +1,2493 @@
+package de.terrestris.shogun2.web;%0A%0Aimport java.io.IOException;%0Aimport java.util.ArrayList;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.beans.factory.annotation.Qualifier;%0Aimport org.springframework.stereotype.Controller;%0Aimport org.springframework.web.bind.annotation.PathVariable;%0Aimport org.springframework.web.bind.annotation.RequestMapping;%0A%0Aimport ch.rasc.extclassgenerator.IncludeValidation;%0Aimport ch.rasc.extclassgenerator.ModelGenerator;%0Aimport ch.rasc.extclassgenerator.OutputFormat;%0A%0A/**%0A * This controller provides EXT-Models based on the available Java-Models, that%0A * are contained in %7B@link #modelPackageCandidates%7D.%0A */%0A@Controller%0Apublic class ExtModelController %7B%0A%0A%09/**%0A%09 * Model package candidates%0A%09 */%0A%09@Autowired%0A%09@Qualifier(value = %22modelPackageCandidates%22)%0A%09private ArrayList%3CString%3E modelPackageCandidates;%0A%0A%09/**%0A%09 * Generates EXT Models based on the Java-models.%0A%09 * %0A%09 * To match project-specific paths to the expected Ext-model-path (of your%0A%09 * application), the servlet-mapping in web.xml has (eventually) to be%0A%09 * adapted.%0A%09 * %0A%09 * @param request%0A%09 * @param response%0A%09 * @param className%0A%09 * @throws IOException%0A%09 */%0A%09@RequestMapping(value = %22/%7BclassName%7D.js%22)%0A%09public void buildExtModel(HttpServletRequest request,%0A%09%09%09HttpServletResponse response, @PathVariable String className)%0A%09%09%09throws IOException %7B%0A%0A%09%09Class%3C?%3E clazz = null;%0A%0A%09%09// Try to find the corresponding java-class via a fully qualified class%0A%09%09// name (based on the modelPackageCandidates)%0A%09%09for (String modelPackage : modelPackageCandidates) %7B%0A%09%09%09try %7B%0A%09%09%09%09String fullyQualifiedClassName = modelPackage + %22.%22 + className;%0A%09%09%09%09clazz = Class.forName(fullyQualifiedClassName);%0A%09%09%09%7D catch (ClassNotFoundException e) %7B%0A%09%09%09%09// Oops. Try again with the next package%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09boolean success = false;%0A%09%09if (clazz != null) %7B%0A%09%09%09// try to generate the Ext model (by using the extclassgenerator%0A%09%09%09// framework)%0A%09%09%09try %7B%0A%09%09%09%09ModelGenerator.writeModel(request, response, clazz,%0A%09%09%09%09%09%09OutputFormat.EXTJS4, IncludeValidation.BUILTIN, true);%0A%09%09%09%09success = true;%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09// Return 404 with info otherwise%0A%09%09if (!success) %7B%0A%09%09%09response.setStatus(HttpServletResponse.SC_NOT_FOUND);%0A%09%09%09response.getWriter().write(%0A%09%09%09%09%09%22Could generate EXT class for %22 + className);%0A%09%09%09response.getWriter().flush();%0A%09%09%09response.getWriter().close();%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add a ExtModelController, that provides Ext models