• Post Reply Bookmark Topic Watch Topic
  • New Topic

Escape Carriage Return

 
Maria Laxmi
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a tag file where in I am calling one Java function from the Java layer and it returns String. The function which is defined in the Java layer gets populated with the data from the data base. Now when the JavaScript displays the String and if it falls into multiple lines then I am getting the error "Unterminated String Constant". Is there any way I can take care of Carriage return in Java Function at the Java layer or when I call the function at presentation layer (means in tag file).


Thanks,
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the purpose of the CRs? Can they just be removed? Or perhaps replaced with \n?
 
Maria Laxmi
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well thats the question , How can I replace with \n when it is coming from the database?

Here is the example how it is used in the tag file.

<script type="text/javascript" LANGUAGE="JavaScript">
var some_text${someClass.id} = "${someClasee.function}";
</script>

Now the SomeClass.function returns long Strings which comes from the database. Only some of the strings falls into multiple lines, not all of them. And those who falls into multiple lines creates a problem. So, this is something dynamic and content related problem and I am not getting the point where and how should I put the \n?

I hope it makes sense.

Thanks for the quick reply !!! I really appreciate it.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
someClasee? Is that different from someClass?

In any case, the getter for the data can simply scrub it as necessary.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!