[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory ...
Christian Bauer
christian at hibernate.org
Fri Aug 31 09:38:13 EDT 2007
User: cbauer
Date: 07/08/31 09:38:13
Modified: examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory
BlogDirectory.java BlogDirectoryPreferences.java
Added: examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory
BlogArchivePreferences.java
BlogRecentEntriesPreferences.java
Log:
More preferences for blogs
Revision Changes Path
1.16 +17 -6 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogDirectory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BlogDirectory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogDirectory.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- BlogDirectory.java 29 Aug 2007 00:29:23 -0000 1.15
+++ BlogDirectory.java 31 Aug 2007 13:38:13 -0000 1.16
@@ -7,6 +7,7 @@
package org.jboss.seam.wiki.plugin.blogdirectory;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.Component;
import org.jboss.seam.annotations.*;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.web.RequestParameter;
@@ -41,10 +42,10 @@
@RequestParameter
Boolean allEntries;
+ private Integer page = 0;
private Integer year;
private Integer month;
private Integer day;
- private Integer page = 0;
@RequestParameter
public void setPage(Integer page) {
@@ -64,6 +65,7 @@
public void setDay(Integer day) {
this.day = day;
}
+
private long numOfBlogEntries;
private long totalNumOfBlogEntries;
private List<BlogEntry> blogEntries;
@@ -72,16 +74,23 @@
@DataModel
private Map<Date, List<BlogEntry>> recentBlogEntries;
- @In("#{blogDirectoryPreferences.properties['pageSize']}")
private long pageSize;
- @In("#{blogDirectoryPreferences.properties['recentHeadlines']}")
private long recentBlogEntriesCount;
@Create
public void initialize() {
+ initializePreferences();
refreshBlogEntries();
}
+ // Lazier than @In, would be too many injections because of c:forEach iteration on blog entry list
+ private void initializePreferences() {
+ pageSize =
+ ((BlogDirectoryPreferences) Component.getInstance("blogDirectoryPreferences")).getPageSize();
+ recentBlogEntriesCount =
+ ((BlogRecentEntriesPreferences)Component.getInstance("blogRecentEntriesPreferences")).getRecentHeadlines();
+ }
+
private void queryNumOfBlogEntries() {
numOfBlogEntries = blogDAO.countBlogEntries(currentDirectory, currentDocument, year, month, day);
}
@@ -107,8 +116,9 @@
}
@Factory(value = "recentBlogEntries")
- @Observer("PreferenceComponent.refresh.blogDirectoryPreferences")
+ @Observer("PreferenceComponent.refresh.blogRecentEntriesPreferences")
public void queryRecentBlogEntries() {
+ initializePreferences();
List<BlogEntry> recentBlogEntriesNonAggregated =
blogDAO.findBlogEntriesWithCommentCount(
currentDirectory,
@@ -145,6 +155,7 @@
@Observer("PreferenceComponent.refresh.blogDirectoryPreferences")
public void refreshBlogEntries() {
+ initializePreferences();
blogEntries = new ArrayList<BlogEntry>();
queryNumOfBlogEntries();
if (numOfBlogEntries != 0){
1.5 +3 -5 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogDirectoryPreferences.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BlogDirectoryPreferences.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogDirectoryPreferences.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- BlogDirectoryPreferences.java 12 Jun 2007 12:30:03 -0000 1.4
+++ BlogDirectoryPreferences.java 31 Aug 2007 13:38:13 -0000 1.5
@@ -28,9 +28,7 @@
@NotNull
private Long pageSize;
- @Preference(description = "02. Number of recent entries in headline list", visibility = PreferenceVisibility.INSTANCE)
- @Range(min = 1l, max = 100l)
- @NotNull
- private Long recentHeadlines;
-
+ public Long getPageSize() {
+ return pageSize;
+ }
}
1.1 date: 2007/08/31 13:38:13; author: cbauer; state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogArchivePreferences.java
Index: BlogArchivePreferences.java
===================================================================
package org.jboss.seam.wiki.plugin.blogdirectory;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.ScopeType;
import org.jboss.seam.wiki.preferences.Preference;
import org.jboss.seam.wiki.preferences.PreferenceVisibility;
import org.jboss.seam.wiki.preferences.PreferenceSupport;
import org.hibernate.validator.Range;
import org.hibernate.validator.NotNull;
import java.io.Serializable;
@Name("blogArchivePreferences")
@Scope(ScopeType.CONVERSATION)
@Preference(description = "Plugin: Blog Archive", visibility = PreferenceVisibility.INSTANCE)
public class BlogArchivePreferences extends PreferenceSupport implements Serializable {
public String getCurrentUserVariable() { return "currentUser"; }
public String getCurrentInstanceVariable() { return "currentDocument"; }
@Observer("PreferenceEditor.refresh.blogArchivePreferences")
public void refreshProperties() { super.refreshProperties(); }
@Preference(description = "01. Show 'Subscribe' icon", visibility = PreferenceVisibility.INSTANCE)
private Boolean showSubscribeIcon;
public Boolean getShowSubscribeIcon() {
return showSubscribeIcon;
}
}
1.1 date: 2007/08/31 13:38:13; author: cbauer; state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogRecentEntriesPreferences.java
Index: BlogRecentEntriesPreferences.java
===================================================================
package org.jboss.seam.wiki.plugin.blogdirectory;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.ScopeType;
import org.jboss.seam.wiki.preferences.Preference;
import org.jboss.seam.wiki.preferences.PreferenceVisibility;
import org.jboss.seam.wiki.preferences.PreferenceSupport;
import org.hibernate.validator.Range;
import org.hibernate.validator.NotNull;
import java.io.Serializable;
@Name("blogRecentEntriesPreferences")
@Scope(ScopeType.CONVERSATION)
@Preference(description = "Plugin: Blog Recent Entries", visibility = PreferenceVisibility.INSTANCE)
public class BlogRecentEntriesPreferences extends PreferenceSupport implements Serializable {
public String getCurrentUserVariable() { return "currentUser"; }
public String getCurrentInstanceVariable() { return "currentDocument"; }
@Observer("PreferenceEditor.refresh.blogRecentEntriesPreferences")
public void refreshProperties() { super.refreshProperties(); }
@Preference(description = "01. Number of items in list", visibility = PreferenceVisibility.INSTANCE)
@Range(min = 1l, max = 100l)
@NotNull
private Long recentHeadlines;
@Preference(description = "02. Truncate item text after characters", visibility = PreferenceVisibility.INSTANCE)
@Range(min = 10l, max = 1000l)
@NotNull
private Long truncateItemText;
@Preference(description = "03. Show 'Subscribe' icon", visibility = PreferenceVisibility.INSTANCE)
private Boolean showSubscribeIcon;
public Long getRecentHeadlines() {
return recentHeadlines;
}
public Long getTruncateItemText() {
return truncateItemText;
}
public Boolean getShowSubscribeIcon() {
return showSubscribeIcon;
}
}
More information about the jboss-cvs-commits
mailing list