New line in string

0
Hi guys, I have a question about something that should be very simple, but i cannot figure it out. I've looked through all the questions about this and cannot find the answer. I've tried <br>, <br/>, \r\n, url decode. I've tried opening a quote on line 1 and closing it on line 2. I've tried adding new lines inside of the quote. I want to pass this string to a new object. So i tried all the above methods by creating a variable first and then passing that to the new object. Also i've tried passing it directly into the object. Could someone help me solve this :)  Thank you!
asked
5 answers
2

If you want to add a new line, you must do this between quotes. For example, if you have two Strings you wish to join, with each on a new line, then the following should work.

 

$String1 + '
' + $String 2

 

Notice that the start quote and end quote are on different lines.

 

I hope this helps.

answered
1

I managed to solve it for myself. Maybe this will help others too.

1. I used this formatting: ‘string 1’ + ‘<br /><br />’ + ‘string 2’. 
2. I changed the setting in the rich text editor for the enter action to break lines instead of paragraphs. 
3. It shows the break in the rich text field. 

answered
0

Hi Jitze,

 

I think this is what you’re looking for:

https://forum.mendix.com/link/questions/1749

answered
0

I'm trying to view this string in a rich text box.

answered
0

// This file was generated by Mendix Studio Pro.

//

// WARNING: Only the following code will be retained when actions are regenerated:

// - the import list

// - the code between BEGIN USER CODE and END USER CODE

// - the code between BEGIN EXTRA CODE and END EXTRA CODE

// Other code you write will be lost the next time you deploy the project.

// Special characters, e.g., é, ö, à, etc. are supported in comments.

 

package myfirstmodule.actions;

 

import com.mendix.systemwideinterfaces.core.IContext;

import com.mendix.webui.CustomJavaAction;

 

public class AppendStringsNewLine extends CustomJavaAction<java.lang.String>

{

private final java.lang.String constantString;

private final java.lang.String currentString;

private final java.lang.String resultString;

 

public AppendStringsNewLine(

IContext context,

java.lang.String _constantString,

java.lang.String _currentString,

java.lang.String _resultString

)

{

super(context);

this.constantString = _constantString;

this.currentString = _currentString;

this.resultString = _resultString;

}

 

@java.lang.Override

public java.lang.String executeAction() throws Exception

{

// BEGIN USER CODE

StringBuilder result = new StringBuilder(resultString);

if (result.length() == 0) {

result.append(constantString);

}

result.append("\n").append(currentString);

return result.toString();

// END USER CODE

}

 

/**

* Returns a string representation of this action

* @return a string representation of this action

*/

@java.lang.Override

public java.lang.String toString()

{

return "AppendStringsNewLine";

}

 

// BEGIN EXTRA CODE

// END EXTRA CODE

}

use this java action, for any use case

 

answered