You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2003/02/17 01:31:45 UTC
cvs commit: jakarta-struts/web/example subscription.jsp
craigmcc 2003/02/16 16:31:45
Modified: src/example/org/apache/struts/webapp/example/memory
MemoryDatabasePlugIn.java
web/example subscription.jsp
Log:
Eliminate the scriptlet used to set up the server types collection
(shoulda done this a *long* time ago).
Revision Changes Path
1.8 +32 -4 jakarta-struts/src/example/org/apache/struts/webapp/example/memory/MemoryDatabasePlugIn.java
Index: MemoryDatabasePlugIn.java
===================================================================
RCS file: /home/cvs/jakarta-struts/src/example/org/apache/struts/webapp/example/memory/MemoryDatabasePlugIn.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- MemoryDatabasePlugIn.java 11 Jan 2003 03:08:23 -0000 1.7
+++ MemoryDatabasePlugIn.java 17 Feb 2003 00:31:45 -0000 1.8
@@ -68,12 +68,14 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
+import java.util.ArrayList;
import javax.servlet.ServletException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
+import org.apache.struts.util.LabelValueBean;
import org.apache.struts.webapp.example.Constants;
/**
@@ -207,10 +209,36 @@
servlet.getServletContext().setAttribute(Constants.DATABASE_KEY,
database);
+ // Setup and cache other required data
+ setupCache(servlet, config);
+
}
// --------------------------------------------------------- Public Methods
+
+
+ // ------------------------------------------------------ Protected Methods
+
+
+ /**
+ * <p>Cache commonly required data as servlet context attributes.</p>
+ *
+ * @param servlet The <code>ActionServlet</code> instance running
+ * this webapp
+ * @param config The <code>ModuleConfig</code> for this application module
+ */
+ protected void setupCache(ActionServlet servlet, ModuleConfig config) {
+
+ // Set up list of server types under "serverTypes"
+ ArrayList serverTypes = new ArrayList();
+ serverTypes.add(new LabelValueBean("IMAP Protocol", "imap"));
+ serverTypes.add(new LabelValueBean("POP3 Protocol", "pop3"));
+ servlet.getServletContext().setAttribute("serverTypes", serverTypes);
+
+ }
+
+
// -------------------------------------------------------- Private Methods
1.30 +0 -8 jakarta-struts/web/example/subscription.jsp
Index: subscription.jsp
===================================================================
RCS file: /home/cvs/jakarta-struts/web/example/subscription.jsp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- subscription.jsp 14 Jul 2002 01:35:18 -0000 1.29
+++ subscription.jsp 17 Feb 2003 00:31:45 -0000 1.30
@@ -5,14 +5,6 @@
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<app:checkLogon/>
-<%-- In real life, these would be loaded from a database --%>
-<%
- java.util.ArrayList list = new java.util.ArrayList();
- list.add(new org.apache.struts.util.LabelValueBean("IMAP Protocol", "imap"));
- list.add(new org.apache.struts.util.LabelValueBean("POP3 Protocol", "pop3"));
- pageContext.setAttribute("serverTypes", list);
-%>
-
<html:html>
<head>
<logic:equal name="subscriptionForm" property="action"
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org