Open Play Project in Activator

Posted on Saturday, August 24, 2013


I have recently tried Activator, a Web App from Typsafe that can create Web Apps in its interface.   I wanted to see how you can open a  Play Project created with the play command line tool and open it and run it in Activator.

This article assumes you already have Activator installed and the Play command line tool installed.

If not you can refer to these two articles.






Create a project with the command line tool


Choose a good spot to put a Play Program, in my case I chose a play folder on my Desktop.   From the command line change your directory to the directory you intend to place your Web App.

Run the following command



> play new HelloWorld





Click enter then when presented with the option of scala or java use scala by entering 1

This creates a HelloWorld folder in the current directory.


Start Activator


Or from the DOS command line run the following from the Activator directory


> activator ui








A web browser should open with the activator Web App at http://localhost:8888/home




Click on the "Find Existing" button


In my case the HelloWorld Web App is located at C:\Users\patman\Desktop\play\HelloWorld
To open that do the following.



Scroll down a little and double click on C:\Users\patman\Desktop

 


Double Click on C:\Users\patman\Desktop\play






Click on C:\Users\patman\Desktop\play\HelloWorld, which selects it.




You can see that C:\Users\patman\Desktop\play\HelloWorld is selected.  Now click on "Open this Project"

 



It is opening the Web App and compiling it.





Success, looks like it opened the Web App just fine.




Click "Run the app"

 


The Web App compiles and runs.



 



The Web App is running, but it seems I am missing the css styling as seen in this image.






It should look like this.





What is the problem?


I spent some time trying to figure out why I was not getting the css loaded here is what I discovered…
It is loading the main.css file just fine.  The one located at public/stylesheets/main.css

However it is empty.

It turns out the css being used by this "Hello World" application is coming from a Play module.  I am still learning Play so take what I say about this with a grain of salt.


According to this post this module adds routes to your routes file so that /@documention leads to documentation files.


To test this out I quickly made another HelloWorld Web App and ran it from the Play command line tool.   Here are the command line commands I ran  To run this Web App on Port 900.


> play new HelloWorld2
> play -Dhttp.port=900 ~run


After it is up and running if you try to open

You will see the CSS you expect




If you try to open the same file, but from the Web App running in Activator (port 9000) http://127.0.0.1:9000/@documentation/resources/style/main.css

You will see this



Resource not found.


Conclusions

At this point I do not see a way to fix the documentation Module issue, I need to learn more about Activator.  But also its not really a problem for your Web App.  Activator will correctly read your css file in your public/stylesheets folder, So go ahead and use it if you want to.


References
[1]  Typesafe Activator
       Visited 8/2013
[2]  Scala Play HelloWorld
       Visited 8/2013
[3]  Play Modules
       Visited 8/2013



No comments:

Post a Comment