- 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:
Gavin Cornwell
2005-12-12 15:55:55 +00:00
parent 8f6bcff2d6
commit 7b8394f1f8
8 changed files with 65 additions and 24 deletions

View File

@@ -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
*