Versions Compared

Key

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

...

Thanks to this you can make your code even cleaner. Check the following code snippets and see how Reportit has been simplified by use of the new feature.

Code Block
languagejava
linenumberstrue
// Now - with @Follow annotation
@SliceResource
public class ReportComponent  {
    @Follow
	@JcrProperty(value = "reportPath") 
	private ReportModel report; // this will build ReportModel based on resource path
                                // kept in reportPath property of current resource
	
	public String getReportValue() {
        return report.getValue();
    }
}
// Before
@SliceResource
public class ReportComponent implements InitializableModel {   
    @JcrProperty 
    private String reportPath;
    
    private ReportModel report;
    
    private ModelProvider modelProvider;
    
    @Inject
    public ReportComponent(ModelProvider modelProvider) {
        this.modelProvider = modelProvider
    }
    
    @Override
    public void afterCreated() {
        report = modelProvider.get(ReportModel.class, reportPath);
    }
    
    public String getReportValue() {
        return report.getValue();
    }
}

...