I have just started using the Java Play framework, and I have a few questions...
I've developed a web application, which was managed using Maven 3.0, hosted on Tomcat 7.0, and containing a whole bunch of JSP files.
Our team recently decided to run everything using the Play framework, and I'm just wonder if there is a fast way to import my original project into Play? also, how does play recognise JSP files? where to put them?
Thank you
Unfortunately, play framework view template uses groovy (1.x) or scala (2.x) to render the data. Therefore, there is no way to use or replace the old jsp files in your new system. You have to convert the old bulk jsp files into the new views
Related
Use Play Framework as a component got a server up, but configuring the file system paths for routes file, views, etc, give or take having to take care of a thread pool for the embedded play server is a different story. Basing on the aforementioned, I started a template for including play as a library, but it remains unclear how to wire the paths, hopefully in an IDE-import friendly way too, so that Play can be nicely used in an existing non-play project, as a library.
How do you configure the file system paths for the routes file and views?
What else should be handled for being as robust as running as the framework?
Anything special for bundling the project for deploy with Play now included?
Motivation: Adding Play to a project, in the current state of affairs, means wrapping the project definition and structure around Play, and losing full compilation in sbt (because only run completes the compilation when using the play sbt plugin). As future Spray support is vague and Akka http is beta-ish, using Play as a library seems to plug a hole.
Somehow this didn't pop up in google, until someone suggested the link on gitter: https://www.playframework.com/documentation/2.5.x/ScalaEmbeddingPlay
Note that an application.conf file containing the required crypto secret can simply sit under src/main/resources in this embedded mode (up until you want to override it for production as per the documentation about it). This is quite enough for a REST server.
However now back to the docs, in case you want more than REST:
This can be used in conjunction with the Twirl template compiler and Play routes compiler
So for Play view templates (which are twirl templates really), refer to the repo I mention in the question body, in which #JonasAnso kindly enabled exactly that.
I have common views that I want to share across multiple Play Framework 2.2.1 applications. I'm thinking packaging them up into a single library and publishing them to our Maven repo is the way to go, but something isn't working correctly during the compile phase.
My project has a single file My/Namespace/myView.scala.html. After compiling my package jar has a file named exactly as my view. My/Namespace/MyView.scala.html I was expecting to see some class files.
The play framework seems to do something very similar https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/views/helper/twitterBootstrap/twitterBootstrapFieldConstructor.scala.html and looking at their Maven package this seems to compile into a twitterBootstrapFieldConstructor class (along with all the meta classes scala generates):
I'm guessing i'm missing something in my SBT configuration that makes it compile scala.html files...but i'm just not seeing it.
Anyone have some insight into what i should be doing?
It appears the best option at this time is to make use of the Twirl library https://github.com/spray/twirl which is the template engine wrapped up into a similar but distinct API.
sbt .13 support is in a testing phase see https://github.com/spray/twirl/issues/15#issuecomment-32272389 as it appears there's going to be some reconciliation of this project & play's templating libraries (one using the other)
I am new to ExtJs.
When practicing in eclipse do we need to include the entire library(52 MB approx) in the appropriate location?
Is there any shorter version of this library?
Can I delete some files in the library which are not important?
What are the necessary .js files to be included for building a sample MVC pattern, CRUD operation support application in ExtJs 4.2?
For my setup, I include the /ext directory in my project, however I exclude it from the build path so that it doesn't slow Eclipse down. See Eclipse: Javascript validation disabled. but still generating errors?
Then, if you don't even want to see the directory in your workspace, you can create a working set.
I wouldn't recommend deleting/excluding ExtJS source files from your project, especially if you are using Sencha Cmd and/or using dynamic loading in your application.
If you really want to include the bare-minimum, you could get away with using ext-all.js, ext-all.css, and making sure you have all of the ExtJS image files.
I am coming from the Java EE world. New to scala and Play. Looking at some sample applications. I see scala code in html files. I am able to understand the framework but I could not get scala.html files. Do I need to learn scala to use Play framework. Any work around.
You can use Java version of Play! without any scala skills. If you don't want to use scala.html templates you can get some module providing Java templates for Play20. Modules list can be found here.
Some examples with samples:
Groovy Template Engine for Play Framework 2.0
A full feaured Java-based template engine for Play2
I have some projects:
WebShared (Java Library project)
WebExternal (GWT Web Application)
WebInternal (GWT Web Application)
I have UI Binder's which are shared between WebExternal and WebInternal, and I organize those under the "WebShared" project.
I am now adding i18n support, and I want to use UI Binder's <ui:msg> tags, and consolidate them using the GWT-P mergelocales.py script.
Mergelocales.py works by running against a GWT app that was GWT compiled using the -extra parameter. Since WebShared is not a GWT app, running the script against it produces no output. Additionally, running mergelocales.py against WebExternal or WebInternal does not produce a file that includes the messages from the WebShared project.
I believe it would work if I converted the WebShared project into a GWT project, but then I would still have two separate properties files to send to the translation service, and I don't want to deal with combining files or managing multiple files.
What is the best way to handle this scenario using the available tools, OR do I need to create my own script?
Thanks in advance for the help.
Solved.
This actually works by default. When the GWT Compiler runs, it generates .property files for the UI Binders that are localized, even if used from a dependent project, and the mergelocales.py script runs against those property files.