Question

I would like to know how to format the scriplet code in a JSP file, here is my code:

<script type="text/javascript">
function modifyClick(index) {

var editModify = "<td>"+<%=Site.getFieldUIName(Site.field.site_name.name())%>+ "</td>";

after I format this file by type CTRL+SHIFT+F, the code will change to the following:

<script type="text/javascript">
function modifyClick(index) {

var editModify = "<td>"
    +
<%=Site.getFieldUIName(Site.field.site_name.name())%>
+ "</td>";

Where can I edit this format style for the <%, I don't want it always to create a line. I have try to find and test the formatter style in JavaScript/web html configuration, but nothing works.

Was it helpful?

Solution

You are treating the JSP code as if its a Javascript string variable. That's going to be a syntax error in your browser. You should just do:

var editModify = "<td><%=Site.getFieldUIName(Site.field.site_name.name())%></td>";

Or, if you want, wrap it in quotes to make it end up as a Javascript string literal:

var editModify = "<td>" + "<%=Site.getFieldUIName(Site.field.site_name.name())%>" + "</td>";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top