- 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

@@ -1098,7 +1098,8 @@ public class BrowseBean implements IContextListener
// clear the UI state in preparation for finishing the next action
if (invalidate == true)
{
invalidateComponents();
// use the context service to notify all registered beans
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
}
}

View File

@@ -36,6 +36,7 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.GUID;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIListItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -192,7 +193,7 @@ public class NewTopicWizard extends NewSpaceWizard
// set the mimetype and encoding
writer.setMimetype(Repository.getMimeTypeForFileName(context, fileName));
writer.setEncoding("UTF-8");
writer.putContent(this.message);
writer.putContent(Utils.replaceLineBreaks(this.message));
}
}
}

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
*