Gilberto Rodrigues
Gilberto Rodrigues

Reputation: 29

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:

<div id="buttons<%=sequencia%>">
   <aui:a href="javascript:printdiv('content<%=sequencia%>');" cssClass="bt_esquerda<%=sequencia%>">Imprimir<%=sequencia%></aui:a>
<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.

Upvotes: 2

Views: 108

Answers (2)

Gilberto Rodrigues
Gilberto Rodrigues

Reputation: 29

I resolved my problem creating a string before the TAG and using it instead that way.

String link = "javascript:printdiv(\'content" + sequencia + "\');";

<aui:a href="<%=link%>" ...

Thanks for your help, Pankajkumar.

Upvotes: 1

Pankaj Kathiriya
Pankaj Kathiriya

Reputation: 4210

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>

Upvotes: 1

Related Questions