| 42 | | public TemplateRepresentation(Template template, MediaType mediaType) { |
|---|
| 43 | | super(mediaType); |
|---|
| 44 | | this.template = template; |
|---|
| 45 | | context = template.createContext(); |
|---|
| 46 | | // We always expire because the content is dynamic |
|---|
| 47 | | setModificationDate(new Date()); |
|---|
| 48 | | setExpirationDate(getModificationDate()); |
|---|
| 49 | | } |
|---|
| | 42 | public TemplateRepresentation(Template template, MediaType mediaType) { |
|---|
| | 43 | super(mediaType); |
|---|
| | 44 | this.template = template; |
|---|
| | 45 | context = template.createContext(); |
|---|
| | 46 | // We always expire because the content is dynamic |
|---|
| | 47 | setModificationDate(new Date()); |
|---|
| | 48 | setExpirationDate(getModificationDate()); |
|---|
| | 49 | } |
|---|
| 58 | | public void setVariable(String name, Object value) { |
|---|
| 59 | | ValueExpression tag = context.getExpressionFactory() |
|---|
| 60 | | .createValueExpression(value, value.getClass()); |
|---|
| 61 | | context.getVariableMapper().setVariable(name, tag); |
|---|
| 62 | | } |
|---|
| 63 | | |
|---|
| 64 | | public TemplateContext getContext() { |
|---|
| 65 | | return context; |
|---|
| 66 | | } |
|---|
| | 58 | public void setVariable(String name, Object value) { |
|---|
| | 59 | ValueExpression tag = null; |
|---|
| | 60 | if (value != null) { |
|---|
| | 61 | tag = context.getExpressionFactory().createValueExpression(value, |
|---|
| | 62 | value.getClass()); |
|---|
| | 63 | } |
|---|
| | 64 | context.getVariableMapper().setVariable(name, tag); |
|---|
| | 65 | } |
|---|
| | 66 | |
|---|
| | 67 | public TemplateContext getContext() { |
|---|
| | 68 | return context; |
|---|
| | 69 | } |
|---|