The ModelTool exposes a model definition to the view.
TODO
- fetching: #set($book = $bookstore.fetch(1))
- properties and joins: $book.publisher.address.zip
- loops: #foreach($author.books) ...
- attributes: $book.most_recent_edition.year
Fix libraries versions (TODO add link towards dependencies).
- Models need to be in the application scope.
- Use the
com.republicate.tools.model.velosurf.VelosurfTool
class for the model. - Add
credentials = "
...path to credentials.xml..."
to the<tool>
tag.
Using the com.republicate.tools.model.velosurf.VelosurfTool
instead of the regular com.republicate.tools.model.ModelTool
provides the following backward compatibility helpers:
- Support of model
obfuscate()
anddeobfuscate()
methods - Support of
<database>
instead of<model>
and of the deprecated tags<entity>
and<attribute>
, along with some deprecated attributes (caching
,read-only
,obfuscate
andlocalize
for entities,caching
replaced bycached
for attributes) - Support for rowset
getRows()
,getScalars()
,getSet()
,getMap()
andgetInstanceMap()
- Instance generic getter also returns attributes (also mimic Velosurf behavior: search for attributes when inner values are present but null) - new behavior is to only return colmns
- Remove the
<credentials>
tag or the<xi:include>
of the credentials, if any. - Replace
<model>
's attributeread-only="true|false"
bywrite="none|java|vtl"
. - Remove
<model>
's attributesloglevel
andseed
, if any. - Other deprecated elements will appear as deprecation warnings in the log, but will be taken into account.
- Obfuscated columns are to be configured in
modality.properties
, see below.
Update uberspectors:
runtime.introspector.uberspect = com.republicate.modality.tools.model.ModelUberspector,org.apache.velocity.util.introspection.UberspectImpl,org.apache.velocity.tools.view.WebappUberspector
- Replace all references to velosurf.util.Logger, if any, with slf4j loggers.
- Servlets or filters needing access to the model can inherit from
com.republicate.modality.webapp.ModalityFilter
orcom.republicate.modality.webapp.ModalityServlet
, and callgetModel()
. - In Java code, the generic getter of instances now only concern columns. You'll call
evaluate()
to get a scalar,retrieve()
to get a row,query()
to get a rowset andperform()
to perform an action. The same methods can be called on the model for root attributes. - Entities have
fetch()
,getCount()
anditerate()
methods. - Use the above methods instead of
getWithParams()
.
You'll potentially need a new /WEB-INF/modality.properties
.
-
For obfuscated columns, set:
model.filters.read.*.foo_id = obfuscate model.filters.write.*.foo_id = deobfuscate_strings
This will obfuscate all foo_id columns.
-
You can still call an attribute as if it were a method, as before. Paramaters can now also be specified in their natural order instead of inside a map.
-
Don't set parameter values in the model itself, like in
#set($db.param = ...)
. You'll getjava.sql.SQLFeatureNotSupportedException: ModelTool is read-only
messages in the log. -
The
.order
and.refine
features have been dropped. -
The
Instance.setColumnValues()
method has been dropped. -
Since Velocity Engine 2.2 (unreleased at the time of writing), you can locate log messages in templates. For instance when using the webapp-slf4j-logger:
<context-param> <param-name>webapp-slf4j-logger.format</param-name> <param-value>%logger [%level] [%ip] %message @%file:%line:%column</param-value> </context-param>
Set Velocity to strict mode to be sure your templates are ok.