Hi,
As per my observation on AEM 6.3, when we drag and drop our components, the sling model associated with component instantiates immediately.
my Sling Model is like this :- @Model(adaptables = SlingHttpServletRequest.class) with injectors like below
@Inject @Via("resource")
@Optional
private String message;
Is this observation is correct ? if yes, is there any way to stop this instantiation and just show the placeholder and upon authoring in dialog, create the instance of the model ?
Thanks in advance.
Solved! Go to Solution.
Views
Replies
Total Likes
AFAIK, it's the correct observation.
You would probably have to add check in your @PostConstruct method Apache Sling :: Sling Models or HTL (formerly known as Sightly)
Views
Replies
Total Likes
AFAIK, it's the correct observation.
You would probably have to add check in your @PostConstruct method Apache Sling :: Sling Models or HTL (formerly known as Sightly)
Views
Replies
Total Likes
hi,
@PostConstruct will be called after all injections , while i want to stop instantiation of sling model during drag and drop.
Views
Replies
Total Likes
I don't think so you can do it.
Best case, you can try to add a check on the sightly element where you add this class.
Thanks
Views
Replies
Total Likes
If you wrap your data-sly-use inside a data-sly-test that evaluates to false it will not be evaluated.
for example, let's say you have a simple text component with one simple authored property "simpleText"
You want to NOT instantiate the model if "simpleText" is NOT authored
you can do the following
```
<!-- NOTE the use of data-sly-test on the same element as the data-sly-use -->
<sly data-sly-test="${properties.simpleText}" data-sly-use.TextModel="package.path.to.model.Text"/>
<div>
<h1>placeholder</h1>
<h1>text is: ${properties.simpleText}</h1>
</div>
```
The model will only instanciate if simpleText is authored and will not otherwise.
you can always make a simple component and test.
Views
Replies
Total Likes