-
Notifications
You must be signed in to change notification settings - Fork 69
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
Can JTE have the directive function #420
Comments
Hi @leeaee, I'm not entirely sure what problem you want to solve. Can you maybe provide a bit more context, or some example jte+Java Code? |
Hi @casid, I encountered a situation while using JTE that I'm unsure how to handle. For example, I have customized a JTE select template as shown below: <select id="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select> Current ApproachBased on my understanding, the typical approach for using this template is as follows: Pass the select option values from Spring: model.addAttribute("options", optionList); Use the select template in the desired pages. ProblemThe issue arises when this select element is required on multiple pages. In this case, I would have to pass the select options through many Spring methods, wherever the select element is used. Desired SolutionWhat I would like to achieve is the ability to automatically retrieve the select options from a single source or a custom tag class whenever the select template is used in JTE. This would help simplify backend code management and avoid having to pass the options repeatedly. QuestionIs there a way to use JTE similarly to how Freemarker uses directives? If so, this would be a perfect solution. For reference: Freemarker Directives |
Hey @leeaee, with jte, there are two options to access data from a template, without the need to pass a parameter to it. Static method, that is called by the template. Static method, that is called by the template, with a thread local behind it (if you need that data on a request base, e.g. localized stuff etc.) |
I have a custom tag that corresponds to a Java class behind it, which can return custom data. Currently, the sidebar menu is returned by the server, and I hope to automatically retrieve values from a class to handle some common data.
The text was updated successfully, but these errors were encountered: