Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. 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).
  2. Tags resolves its models.
    1. 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.
    2. The <slice:lookup> tag uses Guice Injector to create requested model and map it from current Resource.
  3. Tag exposes resolved model (Java object) to the calling script, either Sightly or JSP.
  4. Script uses the model to render its view.

...

Sightly side by side

...

with JSP

Code Block
languagexml
titleSightly
linenumberstrue
<div data-sly-use.model="com.example.components.text.TextModel">
 <p>${model.text}<p>
</div>
Code Block
languagexml
titleSliceJSP
linenumberstrue
<slice:lookup var="model" type="<%=com.example.components.text.TextModel.class%>" />
<p>${model.text}</p>

...