[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util ...
Christian Bauer
christian at hibernate.org
Mon Apr 2 14:25:07 EDT 2007
User: cbauer
Date: 07/04/02 14:25:07
Modified: examples/wiki/src/main/org/jboss/seam/wiki/util
WikiUtil.java
Log:
Totally overengineered but definitely cool system/user/instance wiki preferences architecture
Revision Changes Path
1.2 +8 -7 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WikiUtil.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/util/WikiUtil.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- WikiUtil.java 22 Mar 2007 12:16:08 -0000 1.1
+++ WikiUtil.java 2 Apr 2007 18:25:07 -0000 1.2
@@ -2,6 +2,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.wiki.core.model.*;
+import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
import org.jboss.seam.Component;
import javax.faces.component.UIData;
@@ -71,8 +72,8 @@
// Rendering made easy
public static String renderURL(Node node) {
if (isFile(node)) return renderFileLink((File)node);
- GlobalPreferences globalPrefs = (GlobalPreferences) Component.getInstance("globalPrefs");
- if (globalPrefs.getDefaultURLRendering().equals(GlobalPreferences.URLRendering.PERMLINK)) {
+ WikiPreferences wikiPrefs = (WikiPreferences) Component.getInstance("wikiPreferences");
+ if (wikiPrefs.isRenderPermlinks()) {
return renderPermLink(node);
} else {
return renderWikiLink(node);
@@ -81,9 +82,9 @@
public static String renderPermLink(Node node) {
if (isFile(node)) return renderFileLink((File)node);
- GlobalPreferences globalPrefs = (GlobalPreferences) Component.getInstance("globalPrefs");
+ WikiPreferences wikiPrefs = (WikiPreferences) Component.getInstance("wikiPreferences");
String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
- return contextPath + "/" + node.getId() + globalPrefs.getPermlinkSuffix();
+ return contextPath + "/" + node.getId() + wikiPrefs.getPermlinkSuffix();
}
public static String renderWikiLink(Node node) {
@@ -95,7 +96,7 @@
private static String renderFileLink(File file) {
String contextPath = FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
- return contextPath + "/files/download?fileId=" + file.getId();
+ return contextPath + "/files/download.seam?fileId=" + file.getId();
}
public static String renderHomeURL(User user) {
@@ -111,7 +112,7 @@
/**
* Need to bind UI components to non-conversational backing beans.
* That this is even needed makes no sense. Why can't I call the UI components
- * in the EL directly? Don't try components['id'], it won't work.
+ * in the EL directly? Don't try #{components['id']}, it won't work.
*/
private UIData datatable;
public UIData getDatatable() { return datatable; }
@@ -122,6 +123,6 @@
* with arguments, in a value binding? Java needs properties badly.
*/
public static int sizeOf(Collection col) {
- return col.size();
+ return col == null ? 0 : col.size();
}
}
More information about the jboss-cvs-commits
mailing list