Reputation: 1541
I'm working in a jsp. bean.getConfigurationActionButtonBar()
returns a list of button objects. WebUtils.getActionButtonBar(List buttonList)
takes that list and returns generated html. Very simple.
Now, for some reason this doesn't work:
<td colspan="2">
${WebUtils.getActionButtonBar(bean.getConfigurationActionButtonBar())}
</td>
The button list is set. Something's wrong with the call to static WebUtils.getActionButtonBar
. That call is simply never made. Any idea?
Upvotes: 0
Views: 3202
Reputation: 1108802
You need to declare it as an EL function and register it in a separate taglib.
First create a /WEB-INF/functions.tld
file:
<?xml version="1.0" encoding="UTF-8" ?>
<taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<display-name>Custom Functions</display-name>
<tlib-version>1.0</tlib-version>
<uri>http://example.com/util</uri>
<function>
<name>getActionButtonBar</name>
<function-class>com.example.WebUtils</function-class>
<function-signature>java.lang.String getActionButtonBar(java.util.List)</function-signature>
</function>
</taglib>
Then you can use it as follows:
<%@taglib uri="http://example.com/util" prefix="util" %>
...
${util:getActionButtonBar(bean.getConfigurationActionButtonBar())}
However, you're going completely the wrong path as to achieving the concrete functional requirement. HTML should be generated by JSP files, not by raw Java code. Use a JSP include file or tag file instead.
Upvotes: 3