...
- Components written Sightly way or as JSP scripts are using respectively
data-sly-use.model
attribute or<slice:lookup>
tag to fetch a required model of data (Java object). - Tags resolves its models.
- The
data-sly-use.model
adapts a Resource to the model using Adapters Factory provided by Slice. You don't need to write your own adapters. Under the hood it uses the same mechanism as<slice:lookup>
tag. - The
<slice:lookup>
tag uses Guice Injector to create requested model and map it from current Resource.
- The
- Tag exposes resolved model (Java object) to the calling script, either Sightly or JSP.
- Script uses the model to render its view.
...
Sightly side by side
...
with JSP
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<div data-sly-use.model="com.example.components.text.TextModel"> <p>${model.text}<p> </div> |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<slice:lookup var="model" type="<%=com.example.components.text.TextModel.class%>" /> <p>${model.text}</p> |
...