Reputation: 1138
Like the topic says; How do I include ordinary jsp code in tags? (In my case liferay tags, but it could as well be html-tags)
Example:
<liferay-ui:panel id="panel-c4" title="Service Bulletins" collapsible="true"
extended="<% if (noService==false) {
out.print("false");
}
%>">
Test panel
</liferay-ui:panel>
In the example i just want to insert "false" so the expression looks like the following:
<liferay-ui:panel id="panel-c4" title="Service Bulletins" collapsible="true"
extended="false">
Test panel
</liferay-ui:panel>
This gives me a jasperException.. I´m used to PHP where this kind of code-includes are daily meat.
Can someone please point me in the right direction?
Thanks in advance!
Upvotes: 1
Views: 959
Reputation: 11698
You can have (I'm using ELs, as they are much cleaner):
If variable noService is a boolean:
<c:set var="isExtended"><%=noService ? "true" : "false" %></c:set>;
<liferay-ui:panel id="panel-c4" title="Service Bulletins" collapsible="true"
extended="${isExtended}">
Test panel
</liferay-ui:panel>
If variable noService is a String:
<c:set var="isExtended"><%="false".equals(noService) ? "false" : "true" %></c:set>
<liferay-ui:panel id="panel-c4" title="Service Bulletins" collapsible="true"
extended="${isExtended}">
Test panel
</liferay-ui:panel>
Upvotes: 2
Reputation: 3660
You can also do this.
<liferay-ui:panel id="panel-c4" title="Service Bulletins" collapsible="true"
extended="<%=String.valueOf(noService)%>">
Upvotes: 1
Reputation:
<liferay-ui:panel id="panel-c4" title="Service Bulletins" collapsible="true"
extended="${noService}">
Test panel
</liferay-ui:panel>
noService
must be set in request e.g.:
java:
...
request.setAttribute("noService", false);
...
Upvotes: 3
Reputation: 921
You need to use a Bean
read this:
http://www.exampledepot.com/egs/javax.servlet.jsp/usebean.jsp.html
Upvotes: 0