Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring MVC model not forwarded #378 #383

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.expose-request-attributes",
"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
Loading