mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
- Fixed couple of bugs in forums stuff
- Made delete pages consistent git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2025 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
package org.alfresco.web.ui.common;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -278,6 +280,43 @@ public final class Utils
|
||||
return out.append(str.substring(lastindex, str.length())).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces carriage returns and line breaks with the <br> tag.
|
||||
*
|
||||
* @param str The string to be parsed
|
||||
* @return The string with line breaks removed
|
||||
*/
|
||||
public static String replaceLineBreaks(String str)
|
||||
{
|
||||
String replaced = null;
|
||||
|
||||
if (str != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder parsedContent = new StringBuilder();
|
||||
BufferedReader reader = new BufferedReader(new StringReader(str));
|
||||
String line = reader.readLine();
|
||||
while (line != null)
|
||||
{
|
||||
parsedContent.append(line).append("<br/>");
|
||||
line = reader.readLine();
|
||||
}
|
||||
|
||||
replaced = parsedContent.toString();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
if (logger.isWarnEnabled())
|
||||
{
|
||||
logger.warn("Failed to replace line breaks in string: " + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return replaced;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to output an attribute to the output stream
|
||||
*
|
||||
|
Reference in New Issue
Block a user