[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action ...
Christian Bauer
christian at hibernate.org
Thu Jan 17 11:56:05 EST 2008
User: cbauer
Date: 08/01/17 11:56:05
Modified: examples/wiki/src/main/org/jboss/seam/wiki/core/action
WikiRequestResolver.java
Log:
Fixes for faq browser
Revision Changes Path
1.7 +47 -0 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiRequestResolver.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WikiRequestResolver.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiRequestResolver.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- WikiRequestResolver.java 14 Jan 2008 05:10:46 -0000 1.6
+++ WikiRequestResolver.java 17 Jan 2008 16:56:05 -0000 1.7
@@ -8,7 +8,10 @@
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.web.Parameters;
+import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.annotations.*;
+import org.jboss.seam.annotations.web.RequestParameter;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
@@ -16,6 +19,7 @@
import org.jboss.seam.wiki.core.search.WikiSearch;
import javax.faces.application.FacesMessage;
+import java.util.Map;
/**
* Returns <tt>docDisplay</tt>, <tt>dirDisplay</tt>, or <tt>search</tt> for the resolved <tt>nodeId</tt>.
@@ -98,6 +102,9 @@
public String resolve() {
log.debug("resolving wiki request, node id: " + getNodeId() + " area name: " + getAreaName() + " node name: " + getNodeName());
+ // Push optional request parameters into contexts
+ resolveRequestParameters();
+
// Queue a message if requested (for message passing across session invalidations and conversations)
if (message != null) {
log.debug("wiki request contained message: " + message);
@@ -199,4 +206,44 @@
}
}
+ // These are pushed into the EVENT context, if present in the request (used by plugins etc.)
+ public static enum OptionalParameter {
+
+ category("requestedCategory", String.class),
+ year("requestedYear", Long.class),
+ month("requestedMonth", Long.class),
+ day("requestedDay", Long.class),
+ page("requestedPage", Long.class);
+
+ String variableName;
+ Class variableType;
+ public String getVariableName() {
+ return variableName;
+ }
+ public Class getVariableType() {
+ return variableType;
+ }
+ OptionalParameter(String variableName, Class variableType) {
+ this.variableName = variableName;
+ this.variableType = variableType;
+ }
+ }
+
+ private void resolveRequestParameters() {
+ log.debug("resolving (optional) request paramters");
+
+ OptionalParameter[] optionalParams = OptionalParameter.values();
+ for (OptionalParameter optionalParam : optionalParams) {
+ Object value =
+ Parameters.instance().convertMultiValueRequestParameter(
+ Parameters.instance().getRequestParameters(), optionalParam.name(), optionalParam.getVariableType()
+ );
+ if (value != null) {
+ log.debug("found request parameter '" + optionalParam.name() + "', setting '"
+ + optionalParam.getVariableName()+"' in EVENT context: " + value);
+ Contexts.getEventContext().set(optionalParam.variableName, value);
+ }
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list