[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/docPager ...
Christian Bauer
christian at hibernate.org
Tue Jan 1 08:00:33 EST 2008
User: cbauer
Date: 08/01/01 08:00:33
Added: examples/wiki/src/main/org/jboss/seam/wiki/plugin/docPager
DocPagerPreferencesSupport.java DocPager.java
DocPagerPreferences.java
Log:
JBSEAM-1863 - Pager plugin for previous/next document, also on forum header
Revision Changes Path
1.1 date: 2008/01/01 13:00:33; author: cbauer; state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/docPager/DocPagerPreferencesSupport.java
Index: DocPagerPreferencesSupport.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.seam.wiki.plugin.docPager;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.wiki.preferences.metamodel.PreferenceEntity;
import org.jboss.seam.wiki.preferences.metamodel.PreferencesSupport;
import java.util.HashSet;
import java.util.Set;
/**
* @author Christian Bauer
*/
@Name("docPagerPreferencesSupport")
public class DocPagerPreferencesSupport extends PreferencesSupport {
public Set<PreferenceEntity> getPreferenceEntities() {
return new HashSet<PreferenceEntity>() {{
add( createPreferenceEntity(DocPagerPreferences.class) );
}};
}
}
1.1 date: 2008/01/01 13:00:33; author: cbauer; state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/docPager/DocPager.java
Index: DocPager.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.seam.wiki.plugin.docPager;
import org.jboss.seam.annotations.*;
import org.jboss.seam.ScopeType;
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
import org.jboss.seam.wiki.core.model.WikiDocument;
import java.io.Serializable;
/**
* @author Christian Bauer
*/
@Name("docPager")
@Scope(ScopeType.PAGE)
public class DocPager implements Serializable {
@In
WikiNodeDAO wikiNodeDAO;
@In
WikiDocument currentDocument;
@In("#{preferences.get('DocPager', currentMacro)}")
DocPagerPreferences prefs;
private WikiDocument previous;
private WikiDocument next;
public WikiDocument getPrevious() {
return previous;
}
public WikiDocument getNext() {
return next;
}
@Create
@Observer(value = "Macro.render.docPager", create = false)
public void loadSibling() {
// By default, previous/next documents are searched by creation date
String byProperty = "createdOn";
if (prefs.getByProperty() != null) {
byProperty = prefs.getByProperty();
}
previous = wikiNodeDAO.findSiblingWikiDocumentInDirectory(currentDocument, byProperty, true);
next = wikiNodeDAO.findSiblingWikiDocumentInDirectory(currentDocument, byProperty, false);
if (previous == next) {
// Can't decide if it's previous or next because the checked property has the same value for both
previous = null;
next = null;
}
}
}
1.1 date: 2008/01/01 13:00:33; author: cbauer; state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/docPager/DocPagerPreferences.java
Index: DocPagerPreferences.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.seam.wiki.plugin.docPager;
import org.jboss.seam.wiki.preferences.PreferenceVisibility;
import org.jboss.seam.wiki.preferences.annotations.PreferenceProperty;
import org.jboss.seam.wiki.preferences.annotations.Preferences;
import org.hibernate.validator.Length;
import java.io.Serializable;
/**
* @author Christian Bauer
*/
@Preferences(name = "DocPager", description = "#{messages['docPager.preferences.Name']}")
public class DocPagerPreferences implements Serializable {
@PreferenceProperty(
description = "#{messages['docPager.preferences.ByProperty']}",
visibility = {PreferenceVisibility.INSTANCE},
editorIncludeName = "AdaptiveTextInput"
)
@Length(min = 0, max = 255)
private String byProperty;
public String getByProperty() {
return byProperty;
}
}
More information about the jboss-cvs-commits
mailing list