Comments (7)
Hi
I see different solution for this.
One ist mapping the DispatcherServlet to the root context '/'. The
demohttps://github.com/ralscha/extdirectspring-demoapplication is
using this approach.
Here the mapping in web.xml
Another solution is loading the model javascripts from a script tag. Below
the ext.js script tag you include the script tags for the models. This
will bypass
the dynamic loading of Ext Loader and is maybe not what you want.
Last solution is creating a simple servlet that calls the ModelGenerator.
This does not work right now because the ModelGenerator has a dependency on
Spring and the RouterController class. The app will fail to start because
of the missing context and RouterController. I guess something like this is
happening in your case. I can change that for the next 1.2.3 release so the
ModelGenerator should work independently in a simple servlet.
@WebServlet(urlPatterns = "/app/model/MODEL_NAME.js")
public class Svg2PngServlet extends HttpServlet {
@OverRide
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
ModelGenerator.writeModel(request, response, User.class,
OutputFormat.EXTJS4);
}
}
Ralph
On Mon, Nov 5, 2012 at 11:53 AM, NeverwinterMoon
[email protected]:
I have a problem getting ModelController working while using Ext Loader.
I have configured a servlet with /controller/* url pattern and it works
nicely with ExtDirectSpring.Then I decided to try out ModelController and ran into a problem. Ext
Loader is trying to access /app/model/MODEL_NAME.js and I have the same
path mapped with @RequestMapping on the corresponding method. Seeing as my
servlet is filtering only /controller/*, the working path would be
/controller/app/model/MODEL_NAME.js which Ext Loader doesn't know about.I tried creating another servlet and filtered url the following way:
"/app/model/*" and then changed @RequestMapping to just "MODEL_NAME.js".
Everything seems to be in the right places but app just doesn't start up
anymore.I don't have vast expertise of Spring, so I might be confusing something.
Any help would be appreciated.Loving your project so far.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/46.
from extdirectspring.
What if I use separate root application context and servlet context. Don't all servlet context beans have access to root application context beans? So, for instance, I can create servlet context for just ModelController and it will have access to RouterController which was exposed in root application context?
from extdirectspring.
I forgot about that. You are right this should work.
On Mon, Nov 5, 2012 at 2:11 PM, NeverwinterMoon [email protected]:
What if I use separate root application context and servlet context. Don't
all servlet context beans have access to root application context beans?
So, for instance, I can create servlet context for just ModelController and
it will have access to RouterController which was exposed in root
application context?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-10069822.
from extdirectspring.
OK, I played around and finally got to a more or less suitable solution. I ended up with two different servlets for ExtDirectSpring stuff and ModelController. Those servlets have url filters "/controller/" and "/app/model/", but they both use the same context file. Something like this:
<context:component-scan base-package="ch.ralscha.extdirectspring.controller" >
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
<bean class="com.tallink.agreements.web.util.ModelController" />
<mvc:annotation-driven />
Everything else is in the root application context file.
As for ModelController class, I just put the name of the model in the @RequestParam annotation, like so:
@RequestMapping("MODEL_NAME.js")
The downside is now there are two ways to access the ModelController: "/controller/MODEL_NAME.js" and "/app/model/MODEL_NAME.js". Not that big of a deal, I think.
But yeah, decoupling ModelController from RouterController so it would be possible to have a separate servlet is a very nice idea. I'm definitely for it.
Thanks for all the help.
from extdirectspring.
You could try and move the context:component-scan and
mvc:annotation-driven into the root application context. Then create
another xml with only in it.
The web.xml looks something like this. The /controller/.. context is empty
and the /app/.. context points to the xml with the ModelController in it.
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
1
On Mon, Nov 5, 2012 at 2:46 PM, NeverwinterMoon [email protected]:
OK, I played around and finally got to a more or less suitable solution. I
ended up with two different servlets for ExtDirectSpring stuff and
ModelController. Those servlets have url filters "/controller/" and
"/app/model/", but they both use the same context file. Something like
this:<context:component-scan base-package="ch.ralscha.extdirectspring.controller" >
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
/context:component-scan<mvc:annotation-driven />
As for ModelController class, I just put the name of the model in the
@RequestParam annotation, like so:@RequestMapping("MODEL_NAME.js")
The downside is now there are two ways to access the ModelController:
"/controller/MODEL_NAME.js" and "/app/model/MODEL_NAME.js". Not that big of
a deal, I think.But yeah, decoupling ModelController from RouterController so it would be
possible to have a separate servlet is a very nice idea. I'm definitely for
it.Thanks for all the help.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-10070830.
from extdirectspring.
This is near perfection (I'm saying "near" only because there is still an urge to keep any controller beans definitions out of root context).
Got everything nicely working that way. Thank you so much for all the help and for the wonderful tool that is ExtDirectSpring!
from extdirectspring.
I removed the "RouterController"-dependency in ModelGenerator. Now you can use it like this:
@WebServlet(urlPatterns = "/app/model/Song.js")
public class SongModelServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
ModelGenerator.writeModel(request, response, Song.class, OutputFormat.EXTJS4);
}
}
You can test this with the latest 1.2.3-SNAPSHOT
from extdirectspring.
Related Issues (20)
- Move getComparison() method to the base Filter class
- Support null values in BooleanFilter
- Struggling to work out what dependencies extdirectspring has HOT 2
- AuthenticationPrincipal moves into another package with Spring Security 4
- Inecting CDI Beans HOT 4
- Changing Jackson object mapper naming strategy impacts API json HOT 2
- Store filter syntax HOT 8
- @ExtDirectMethod(value = STORE_READ, jsonView=) is ignored HOT 4
- Default value for Ext Direct Remoting API variable name changes in Ext JS 6.0.1
- Static methods for ExtDirectStoreResult, ExtDirectFormLoadResult, ExtDirectFormPostResult, ExtDirectRawJsonStoreResult HOT 2
- Model Generator APT source? HOT 1
- Problem with grid grouping HOT 2
- org.springframework.web.bind.annotation.RequestParam.name HOT 1
- Test fail HOT 4
- Model CURD method metadata support HOT 2
- It's really nice to have methods as ExtDirectFormPostResult.create HOT 1
- Need to have special customization for variable "requestUrlString" in ApiController.buildAndCacheApiString
- Spring 5? HOT 2
- Router accepts text/plain requests which makes it CSRF vulnerable HOT 6
- Dependency org.springframework:spring-web, leading to CVE problem HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extdirectspring.