I am trying to build a web application where the user can select and define a web-page’s content through the use of some predefined UI components (without exposing any HTML to the users).
Since I’m new to Play framework, I need some good practices to store the (component-based) content of this web page “the Play way“. Basically I can think of two approaches:
- I can define a page-content definition model that will store the user’s creation; and then produce the live page by a smart template mechanism based on the info in this model.
- or, I can convert and store the page-content directly as a template (play template) on the filesytem. But then re-editing of a previously generated content will be difficult to handle I think.
- or, I can use both: the model for the editing and updating, the template to store and display.
Do you propose any one of them, or would another approach be more practical/right for a Play application?
Thank you very much 🙂
The Play! way would be to define all your entities as part of your model and store them in a database. This way you can make the best use of the integrated jpa features which come bundled with Play!.
You could define your html components as Models which are associated with a particular user/site and keep them updated on the db.
I suggest you go through the jpa section and the tutorial if you need a better idea of how Play! works.
Personally I would seldomely use the filesystem for anything else than properties and configuration.