Search code examples
jspliferayscriptlet

JSP: Problems Interpreting a Variable


This is my first post and I'm having problems with a servlet to interpret a variable I created to sequentially name two TAGs on a page running with Liferay.

Apparently the JSP interprets correctly for some TAGs and some does not. This is strange to me.

The following is an example of the code:

  • I created the "sequencia" variable to create an order
<div id="buttons<%=sequencia%>">
   <aui:a href="javascript:printdiv('content<%=sequencia%>');" cssClass="bt_esquerda<%=sequencia%>">Imprimir<%=sequencia%></aui:a>
  • The result that returns in the code is this
<div id="buttons1">
   <a href="javascript:printdiv(&#039;content&lt;%=sequencia%&gt;&#039;);"

class="bt_esquerda<%=sequencia%>">Imprimir1

Does anyone have any idea WHY it can not resolve within the single and double quotation marks of the <a> tag, but can <div>?

Even if you do not know, do you have any alternative ideas?

Thank you.


Solution

  • The reason of issue is aui:a represents custom aui anchor tag; which has its implementation whereas div is generic html tag.

    You may use any of below alternative <aui:a href="javascript:;" onClick='<%="javascript:printdiv(\'content+<%=sequencia%>+\');" cssClass="bt_esquerda<%=sequencia%>">Imprimir<%=sequencia%></aui:a>

    <aui:a href='<%="javascript:printdiv(\'content+<%=sequencia%>+\');" cssClass="bt_esquerda<%=sequencia%>">Imprimir<%=sequencia%></aui:a>