Skip to content

Commit

Permalink
Spring MVC model not forwarded #378
Browse files Browse the repository at this point in the history
  • Loading branch information
blasetti committed Sep 28, 2024
1 parent bdd2fcc commit a3f5816
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public JteAutoConfiguration(JteProperties jteProperties) {
@Bean
@ConditionalOnMissingBean(JteViewResolver.class)
public JteViewResolver jteViewResolver(TemplateEngine templateEngine) {
return new JteViewResolver(templateEngine, jteProperties.getTemplateSuffix());
return new JteViewResolver(templateEngine, jteProperties);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class JteProperties {
private Boolean usePrecompiledTemplates = false;
private String templateLocation = "src/main/jte";
private String templateSuffix = ".jte";
private boolean exposeRequestAttributes = false;

public String getTemplateSuffix() {
return templateSuffix;
Expand All @@ -31,4 +32,12 @@ public Boolean usePreCompiledTemplates() {
public void setUsePrecompiledTemplates(Boolean usePrecompiledTemplates) {
this.usePrecompiledTemplates = usePrecompiledTemplates;
}

public boolean isExposeRequestAttributes() {
return exposeRequestAttributes;
}

public void setExposeRequestAttributes(boolean exposeRequestAttributes) {
this.exposeRequestAttributes = exposeRequestAttributes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ public class JteViewResolver extends AbstractTemplateViewResolver {

private final TemplateEngine templateEngine;

public JteViewResolver(TemplateEngine templateEngine, final String templateSuffix) {
public JteViewResolver(TemplateEngine templateEngine, JteProperties jteProperties) {
this.templateEngine = templateEngine;
this.setSuffix(templateSuffix);
this.setSuffix(jteProperties.getTemplateSuffix());
this.setViewClass(JteView.class);
this.setContentType(MediaType.TEXT_HTML_VALUE);
this.setOrder(Ordered.HIGHEST_PRECEDENCE);
this.setExposeRequestAttributes(jteProperties.isExposeRequestAttributes());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ public JteAutoConfiguration(JteProperties jteProperties) {
@Bean
@ConditionalOnMissingBean(JteViewResolver.class)
public JteViewResolver jteViewResolver(TemplateEngine templateEngine) {

return new JteViewResolver(templateEngine, jteProperties.getTemplateSuffix());
return new JteViewResolver(templateEngine, jteProperties);
}


@Bean
@ConditionalOnMissingBean(TemplateEngine.class)
public TemplateEngine jteTemplateEngine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class JteProperties {
private boolean developmentMode = false;
private String templateLocation = "src/main/jte";
private String templateSuffix = ".jte";
private boolean exposeRequestAttributes = false;

public String getTemplateSuffix() {
return templateSuffix;
Expand Down Expand Up @@ -40,4 +41,21 @@ public boolean isDevelopmentMode() {
public void setDevelopmentMode(boolean developmentMode) {
this.developmentMode = developmentMode;
}

public boolean isUsePrecompiledTemplates() {
return usePrecompiledTemplates;
}

public void setUsePrecompiledTemplates(boolean usePrecompiledTemplates) {
this.usePrecompiledTemplates = usePrecompiledTemplates;
}

public boolean isExposeRequestAttributes() {
return exposeRequestAttributes;
}

public void setExposeRequestAttributes(boolean exposeRequestAttributes) {
this.exposeRequestAttributes = exposeRequestAttributes;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ public class JteViewResolver extends AbstractTemplateViewResolver {

private final TemplateEngine templateEngine;

public JteViewResolver(TemplateEngine templateEngine, final String templateSuffix) {
public JteViewResolver(TemplateEngine templateEngine, JteProperties jteProperties) {
this.templateEngine = templateEngine;
this.setSuffix(templateSuffix);
this.setSuffix(jteProperties.getTemplateSuffix());
this.setViewClass(JteView.class);
this.setContentType(MediaType.TEXT_HTML_VALUE);
this.setOrder(Ordered.HIGHEST_PRECEDENCE);
this.setExposeRequestAttributes(jteProperties.isExposeRequestAttributes());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
"type": "java.lang.String",
"description": "You can configure the file suffix of jte templates the compiler resolves",
"sourceType": "gg.jte.springframework.boot.autoconfigure.JteProperties"
},
{
"name": "gg.jte.exposeRequestAttributes",
"type": "java.lang.Boolean",
"description": "Set whether all request attributes should be added to the model prior to merging with the template",
"sourceType": "gg.jte.springframework.boot.autoconfigure.JteProperties"
}
],
"hints": []
Expand Down

0 comments on commit a3f5816

Please sign in to comment.