Author: mrdon Date: Tue Dec 6 18:51:31 2005 New Revision: 354676 URL: http://svn.apache.org/viewcvs?rev=354676&view=rev Log: Changed example to use Groovy, other minor fixes * Replaced BeanShell with Groovy in Mailreader example * Fixed notice to not include info on ANTLR * Fixed a few typos in user and source guide * Removed old sf download link * Adding mailing list links to pom * Removed jconverage links in pom * Added comments for dependencies
Added: struts/scripting/trunk/src/struts-example/WEB-INF/classes/ struts/scripting/trunk/src/struts-example/WEB-INF/classes/struts-scripting.properties struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditRegistration.gv struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditSubscription.gv struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Locale.gv struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logoff.gv struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logon.gv struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveRegistration.gv struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveSubscription.gv struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Welcome.gv Removed: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditRegistration.bsh struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditSubscription.bsh struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Locale.bsh struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logoff.bsh struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logon.bsh struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveRegistration.bsh struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveSubscription.bsh struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Welcome.bsh Modified: struts/scripting/trunk/NOTICE.txt struts/scripting/trunk/build.xml struts/scripting/trunk/project.xml struts/scripting/trunk/src/struts-example/WEB-INF/struts-config-registration.xml struts/scripting/trunk/src/struts-example/WEB-INF/struts-config.xml struts/scripting/trunk/xdocs/changes.xml struts/scripting/trunk/xdocs/index.xml struts/scripting/trunk/xdocs/navigation.xml struts/scripting/trunk/xdocs/source-guide.xml struts/scripting/trunk/xdocs/user-guide.xml Modified: struts/scripting/trunk/NOTICE.txt URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/NOTICE.txt?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/NOTICE.txt (original) +++ struts/scripting/trunk/NOTICE.txt Tue Dec 6 18:51:31 2005 @@ -1,7 +1,2 @@ This product includes software developed by The Apache Software Foundation (http://www.apache.org/). - -This product includes the ANTLR parsing library, -developed by JGuru.com (http://www.antlr.org and -http://www.jguru.com). - Modified: struts/scripting/trunk/build.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/build.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/build.xml (original) +++ struts/scripting/trunk/build.xml Tue Dec 6 18:51:31 2005 @@ -85,9 +85,9 @@ ignoreerrors="true" src="http://www.ibiblio.org/maven/bsf/jars/bsf-2.3.0.jar"/> - <get dest="${lib.core}/bsh-1.3.0.jar" usetimestamp="true" + <get dest="${lib.core}/groovy-all-1.0-jsr-04.jar" usetimestamp="true" ignoreerrors="true" - src="http://www.ibiblio.org/maven/bsh/jars/bsh-1.3.0.jar"/> + src="http://www.ibiblio.org/maven/groovy/jars/groovy-all-1.0-jsr-04.jar"/> <get dest="${lib.core}/jakarta-oro-2.0.7.jar" usetimestamp="true" ignoreerrors="true" Modified: struts/scripting/trunk/project.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/project.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/project.xml (original) +++ struts/scripting/trunk/project.xml Tue Dec 6 18:51:31 2005 @@ -50,7 +50,22 @@ <siteAddress>people.apache.org</siteAddress> <siteDirectory>/www/struts.apache.org/struts-scripting/</siteDirectory> - + + <mailingLists> + <mailingList> + <name>Struts User List</name> + <subscribe>[EMAIL PROTECTED]</subscribe> + <unsubscribe>[EMAIL PROTECTED]</unsubscribe> + <archive>http://mail-archives.apache.org/eyebrowse/SummarizeList?listId=42</archive> + </mailingList> + <mailingList> + <name>Struts Developer List</name> + <subscribe>[EMAIL PROTECTED]</subscribe> + <unsubscribe>[EMAIL PROTECTED]</unsubscribe> + <archive>http://mail-archives.apache.org/eyebrowse/SummarizeList?listId=41</archive> + </mailingList> + </mailingLists> + <url>http://struts.apache.org/struts-scripting</url> <repository> <connection>scm|svn|http|//svn.apache.org/repos/asf/struts/scripting/trunk</connection> @@ -77,6 +92,7 @@ <properties> <scope>provided</scope> </properties> + <comment>Required for build</comment> </dependency> <dependency> @@ -87,6 +103,7 @@ <properties> <war.bundle>true</war.bundle> </properties> + <comment>Required for Struts 1.2.8</comment> </dependency> <dependency> @@ -97,6 +114,7 @@ <properties> <war.bundle>true</war.bundle> </properties> + <comment>Required</comment> </dependency> <dependency> @@ -107,6 +125,7 @@ <properties> <war.bundle>true</war.bundle> </properties> + <comment>Required for Struts 1.2.8</comment> </dependency> <dependency> @@ -117,6 +136,7 @@ <properties> <war.bundle>true</war.bundle> </properties> + <comment>Required for Struts 1.2.8</comment> </dependency> <dependency> @@ -129,6 +149,7 @@ <cactus.bundle>true</cactus.bundle> </properties> <url>http://struts.apache.org/</url> + <comment>Required</comment> </dependency> <dependency> @@ -140,17 +161,19 @@ <cactus.bundle>true</cactus.bundle> </properties> <url>http://jakarta.apache.org/bsf/</url> + <comment>Required</comment> </dependency> <dependency> - <groupId>bsh</groupId> - <artifactId>bsh</artifactId> - <version>1.3.0</version> + <groupId>groovy</groupId> + <artifactId>groovy-all</artifactId> + <version>1.0-jsr-04</version> <properties> <war.bundle>true</war.bundle> <cactus.bundle>true</cactus.bundle> </properties> - <url>http://www.beanshell.org/</url> + <url>http://groovy.codehaus.org/</url> + <comment>Optional - Used by the Mailreader example</comment> </dependency> <!-- The following two dependencies are only used during the build process --> @@ -212,7 +235,7 @@ <report>maven-pmd-plugin</report> <report>maven-simian-plugin</report> <report>maven-tasklist-plugin</report> - <report>maven-jcoverage-plugin</report> + <!--<report>maven-jcoverage-plugin</report>--> <!--report>maven-findbugs-plugin</report--> </reports> Added: struts/scripting/trunk/src/struts-example/WEB-INF/classes/struts-scripting.properties URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/classes/struts-scripting.properties?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/classes/struts-scripting.properties (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/classes/struts-scripting.properties Tue Dec 6 18:51:31 2005 @@ -0,0 +1,2 @@ +struts-scripting.engine.groovy.class=org.codehaus.groovy.bsf.GroovyEngine +struts-scripting.engine.groovy.extensions=gv,groovy Added: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditRegistration.gv URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditRegistration.gv?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditRegistration.gv (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditRegistration.gv Tue Dec 6 18:51:31 2005 @@ -0,0 +1,63 @@ +import java.lang.reflect.InvocationTargetException; +import javax.servlet.ServletException; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.struts.webapp.example.*; + +act = request.getParameter("action"); +if (act == null) { + act = "Create"; + if (log.isDebugEnabled()) { + log.debug("EditRegistrationAction: Processing " + act + + " act"); + } +} + +user = null; +// Is there a currently logged on user? +if (!"Create".equals(act)) { + user = (User) session.getAttribute(Constants.USER_KEY); + if (user == null) { + if (log.isDebugEnabled()) { + log.debug(" User is not logged on in session " + + session.getId()); + } + struts.setForwardName("logon"); + return; + } +} + +form = struts.form; +if (user != null) { + if (log.isTraceEnabled()) { + log.trace(" Populating form from " + user); + } + try { + PropertyUtils.copyProperties((Object)form, user); + + form.action=act; + form.password=null; + form.password2=null; + } catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + if (t == null) + t = e; + log.error("RegistrationForm.populate", t); + throw new ServletException("RegistrationForm.populate", t); + } catch (Throwable t) { + log.error("RegistrationForm.populate", t); + throw new ServletException("RegistrationForm.populate", t); + } +} + +// Set a transactal control token to prevent double posting +if (log.isTraceEnabled()) { + log.trace(" Setting transactal control token"); +} +struts.action.saveToken(request); + +// Forward control to the edit user registration page +if (log.isTraceEnabled()) { + log.trace(" Forwarding to 'success' page"); +} + +struts.setForwardName("success"); Added: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditSubscription.gv URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditSubscription.gv?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditSubscription.gv (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/scripts/EditSubscription.gv Tue Dec 6 18:51:31 2005 @@ -0,0 +1,71 @@ + +import java.lang.reflect.InvocationTargetException; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.struts.webapp.example.*; +import javax.servlet.ServletException; + +act = request.getParameter("action"); +if (act == null) { + act = "Create"; +} + +host = request.getParameter("host"); +if (log.isDebugEnabled()) { + log.debug("EditSubscriptionAction: Processing " + act + + " action"); +} + +// Is there a currently logged on user? +user = (User) session.getAttribute(Constants.USER_KEY); +if (user == null) { + if (log.isTraceEnabled()) { + log.trace(" User is not logged on in session " + + session.getId()); + } + struts.setForwardName("logon"); + return; +} +// Identify the relevant subscription +subscription = + user.findSubscription(request.getParameter("host")); +if ((subscription == null) && !act.equals("Create")) { + if (log.isTraceEnabled()) { + log.trace(" No subscription for user " + + user.getUsername() + " and host " + host); + } + struts.setForwardName("failure"); + return; +} + +if (subscription != null) { + session.setAttribute(Constants.SUBSCRIPTION_KEY, subscription); +} + +form = struts.form; +form.setAction(act); +if (!act.equals("Create")) { + if (log.isTraceEnabled()) { + log.trace(" Populating form from " + subscription); + } + try { + PropertyUtils.copyProperties(form, subscription); + form.setAction(act); + } catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + if (t == null) + t = e; + log.error("SubscriptionForm.populate", t); + throw new ServletException("SubscriptionForm.populate", t); + } catch (Throwable t) { + log.error("SubscriptionForm.populate", t); + throw new ServletException("SubscriptionForm.populate", t); + } +} + +// Forward control to the edit subscription page +if (log.isTraceEnabled()) { + log.trace(" Forwarding to 'success' page"); +} + +struts.setForwardName("success"); + Added: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Locale.gv URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Locale.gv?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Locale.gv (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Locale.gv Tue Dec 6 18:51:31 2005 @@ -0,0 +1,31 @@ +import java.util.Locale; +import org.apache.struts.Globals; +import org.apache.struts.action.ActionForward; + +def isBlank(str) { + return ((str == null) || (str.trim().length()==0)); +} + +language = request.getParameter("language"); +country = request.getParameter("country"); + +locale = struts.action.getLocale(request); + +if ((!isBlank(language)) && (!isBlank(country))) { + locale = new Locale(language, country); +} +else if (!isBlank(language)) { + locale = new Locale(language, ""); +} + +session.setAttribute(Globals.LOCALE_KEY, locale); + +String target = request.getParameter("page"); +if (!isBlank(target)) { + struts.setForward(new ActionForward(target)); + return; +} + +target = request.getParameter("forward"); +if (isBlank(target)) target = defaultTarget; +struts.setForwardName(target); Added: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logoff.gv URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logoff.gv?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logoff.gv (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logoff.gv Tue Dec 6 18:51:31 2005 @@ -0,0 +1,23 @@ +import org.apache.struts.webapp.example.*; + +user = session.getAttribute(Constants.USER_KEY); + +// Process this user logoff +if (user != null) { + if (log.isDebugEnabled()) { + log.debug("LogoffAction: User '" + user.getUsername() + + "' logged off in session " + session.getId()); + } +} else { + if (log.isDebugEnabled()) { + log.debug("LogoffActon: User logged off in session " + + session.getId()); + } +} + +session.removeAttribute(Constants.SUBSCRIPTION_KEY); +session.removeAttribute(Constants.USER_KEY); +session.invalidate(); + +// Forward control to the specified success URI +struts.setForwardName("success"); Added: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logon.gv URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logon.gv?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logon.gv (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Logon.gv Tue Dec 6 18:51:31 2005 @@ -0,0 +1,66 @@ +import org.apache.struts.action.ActionError; +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.util.ModuleException; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.struts.webapp.example.*; + +form = struts.form; + +def getUser(database, username, password, errors) { + + user = null; + if (database == null){ + errors.add( + ActionMessages.GLOBAL_MESSAGE, + new ActionMessage("error.database.missing")); + } + else { + user = database.findUser(username); + if ((user != null) && !user.getPassword().equals(password)) { + user = null; + } + if (user == null) { + errors.add( + ActionMessages.GLOBAL_MESSAGE, + new ActionMessage("error.password.mismatch")); + } + } + return user; +} + +def saveUser(request, user) { + + session = request.getSession(); + session.setAttribute(Constants.USER_KEY, user); + if (log.isDebugEnabled()) { + log.debug( + "LogonAction: User '" + + user.getUsername() + + "' logged on in session " + + session.getId()); + } + +} + +// Local variables +errors = new ActionErrors(); +username = PropertyUtils.getSimpleProperty(form, "username"); +password = PropertyUtils.getSimpleProperty(form, "password"); +database = application.getAttribute(Constants.DATABASE_KEY); + +// Retrieve user +user = getUser(database,username,password,errors); + +// Save (or clear) user object +saveUser(request,user); + +// Report back any errors, and exit if any +if (!errors.isEmpty()) { + struts.action.saveErrors(request, errors); + struts.setForward(struts.mapping.getInputForward()); +} + +// Otherwise, return "success" +struts.setForwardName(Constants.SUCCESS); Added: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveRegistration.gv URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveRegistration.gv?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveRegistration.gv (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveRegistration.gv Tue Dec 6 18:51:31 2005 @@ -0,0 +1,134 @@ +import java.lang.reflect.InvocationTargetException; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.struts.action.*; +import org.apache.struts.webapp.example.*; +import javax.servlet.ServletException; + +form = struts.getForm(); +String act = form.getAction(); +if (act == null) { + act = "Create"; +} +database = application.getAttribute(Constants.DATABASE_KEY); +if (log.isDebugEnabled()) { + log.debug("SaveRegistrationAction: Processing " + act + + " act"); +} + +// Is there a currently logged on user (unless creating)? +user = session.getAttribute(Constants.USER_KEY); +if (!"Create".equals(act) && (user == null)) { + if (log.isTraceEnabled()) { + log.trace(" User is not logged on in session " + + session.getId()); + } + struts.setForwardName("logon"); + return; +} +// Was this transact cancelled? +if (struts.action.isCancelled(request)) { + if (log.isTraceEnabled()) { + log.trace(" Transact '" + act + + "' was cancelled"); + } + session.removeAttribute(Constants.SUBSCRIPTION_KEY); + struts.setForwardName("success"); + return; +} + +// Validate the transactal control token +errors = new ActionErrors(); +if (log.isTraceEnabled()) { + log.trace(" Checking transactal control token"); +} +if (!struts.action.isTokenValid(request)) { + errors.add(ActionErrors.GLOBAL_ERROR, + new ActionError("error.transact.token")); +} +struts.action.resetToken(request); + +// Validate the request parameters specified by the user +if (log.isTraceEnabled()) { + log.trace(" Performing extra validations"); +} +value = form.getUsername(); +if (("Create".equals(act)) && + (database.findUser(value) != null)) { + errors.add("username", + new ActionError("error.username.unique", + form.getUsername())); +} +if ("Create".equals(act)) { + value = form.password; + if ((value == null) || (value.length() <1)) { + errors.add("password", + new ActionError("error.password.required")); + } + value = form.password2; + if ((value == null) || (value.length() < 1)) { + errors.add("password2", + new ActionError("error.password2.required")); + } +} + +// Report any errors we have discovered back to the original form +if (!errors.isEmpty()) { + struts.action.saveErrors(request, errors); + struts.action.saveToken(request); + struts.setForward(struts.mapping.getInputForward()); + return; +} + +// Update the user's persistent profile information +try { + if ("Create".equals(act)) { + user = database.createUser(form.username); + } + oldPassword = user.password; + PropertyUtils.copyProperties(user, form); + if ((form.password == null) || + (form.password.length() < 1)) { + user.setPassword(oldPassword); + } +} catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + if (t == null) { + t = e; + } + log.error("Registration.populate", t); + throw new RuntimeException("Registration.populate", t); +} catch (Throwable t) { + log.error("Registration.populate", t); + throw new RuntimeException("Subscription.populate", t); +} + +try { + database.save(); +} catch (Exception e) { + log.error("Database save", e); +} + +// Log the user in if appropriate +if ("Create".equals(act)) { + session.setAttribute(Constants.USER_KEY, user); + if (log.isTraceEnabled()) { + log.trace(" User '" + user.getUsername() + + "' logged on in session " + session.getId()); + } +} + +// Remove the obsolete form bean +if (struts.mapping.getAttribute() != null) { + if ("request".equals(struts.mapping.scope)) + request.removeAttribute(struts.mapping.attribute); + else + session.removeAttribute(struts.mapping.attribute); +} + +// Forward control to the specified success URI +if (log.isTraceEnabled()) { + log.trace(" Forwarding to success page"); +} + +struts.setForwardName("success"); + Added: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveSubscription.gv URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveSubscription.gv?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveSubscription.gv (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/scripts/SaveSubscription.gv Tue Dec 6 18:51:31 2005 @@ -0,0 +1,119 @@ +import java.lang.reflect.InvocationTargetException; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.struts.webapp.example.*; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.ServletException; + +form = struts.form; + +act = form.getAction(); +if (act == null) { + act = "?"; +} + +if (log.isDebugEnabled()) { + log.debug("SaveSubscriptionAction: Processing " + act + + " act"); +} + + +// Is there a currently logged on user? +user = session.getAttribute(Constants.USER_KEY); + +if (user == null) { + if (log.isWarnEnabled()) { + log.warn(" User is not logged on in session " + + session.getId()); + } + struts.setForwardName("logon"); + return; +} + +if (struts.action.isCancelled(request)) { + if (log.isWarnEnabled()) { + log.warn(" Transact '" + act + + "' was cancelled"); + } + session.removeAttribute(Constants.SUBSCRIPTION_KEY); + struts.setForwardName("success"); + return; +} + + +// Is there a related Subscription object? +subscription = session.getAttribute(Constants.SUBSCRIPTION_KEY); +if ("Create".equals(act)) { + subscription = + user.createSubscription(request.getParameter("host")); +} +if (subscription == null) { + if (log.isWarnEnabled()) { + log.warn(" Missing subscription for user '" + + user.getUsername() + "'"); + } + log.warn("bad request sent"); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, + response.getMessage("error.noSubscription")); + +} + +// Was this transact a Delete? +if (act.equals("Delete")) { + if (log.isTraceEnabled()) { + log.trace(" Deleting mail server '" + + subscription.getHost() + "' for user '" + + user.getUsername() + "'"); + } + user.removeSubscription(subscription); + session.removeAttribute(Constants.SUBSCRIPTION_KEY); + try { + database = application.getAttribute(Constants.DATABASE_KEY); + database.save(); + } catch (Exception e) { + log.error("Database save", e); + } + struts.setForwardName("success"); + return; +} + +// All required validations were done by the form itself + +// Update the persistent subscription information +if (log.isTraceEnabled()) { + log.trace(" Populating database from form bean"); +} +try { + PropertyUtils.copyProperties(subscription, form); +} catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + if (t == null) + t = e; + log.error("Subscription.populate", t); + throw new ServletException("Subscription.populate", t); +} catch (Throwable t) { + log.error("Subscription.populate", t); + throw new ServletException("Subscription.populate", t); +} + +try { + database = application.getAttribute(Constants.DATABASE_KEY); + database.save(); +} catch (Exception e) { + log.error("Database save", e); +} + +// Remove the obsolete form bean and current subscription +if (struts.mapping.attribute != null) { + if ("request".equals(struts.mapping.scope)) + request.removeAttribute(struts.mapping.attribute); + else + session.removeAttribute(struts.mapping.attribute); +} +session.removeAttribute(Constants.SUBSCRIPTION_KEY); + +// Forward control to the specified success URI +if (log.isTraceEnabled()) { + log.trace(" Forwarding to success page"); +} + +struts.setForwardName("success"); Added: struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Welcome.gv URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Welcome.gv?rev=354676&view=auto ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Welcome.gv (added) +++ struts/scripting/trunk/src/struts-example/WEB-INF/scripts/Welcome.gv Tue Dec 6 18:51:31 2005 @@ -0,0 +1,27 @@ +import org.apache.struts.webapp.example.*; +import java.util.ArrayList; + +// Setup message array in case there are errors +messages = []; + +// Confirm message resources loaded +resources = struts.getMessages(); +if (resources==null) { + messages.add(Constants.ERROR_MESSAGES_NOT_LOADED); +} + +// Confirm database loaded +userDatabase = application.getAttribute(Constants.DATABASE_KEY); +if (userDatabase==null) { + messages.add(Constants.ERROR_DATABASE_NOT_LOADED); +} + +// If there were errors, forward to our failure page +if (messages.size()>0) { + request.setAttribute(Constants.ERROR_KEY,messages); + struts.setForwardName(Constants.FAILURE); + return; +} + +// Forward to our success page +struts.setForwardName(Constants.SUCCESS); Modified: struts/scripting/trunk/src/struts-example/WEB-INF/struts-config-registration.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/struts-config-registration.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/struts-config-registration.xml (original) +++ struts/scripting/trunk/src/struts-example/WEB-INF/struts-config-registration.xml Tue Dec 6 18:51:31 2005 @@ -52,7 +52,7 @@ <!-- Matches all edit actions (in this case, only user regstration) --> <action path="/Edit*" type="org.apache.struts.scripting.ScriptAction" - parameter="/WEB-INF/scripts/Edit{1}.bsh" + parameter="/WEB-INF/scripts/Edit{1}.gv" name="{1}Form" scope="request" validate="false"> @@ -62,7 +62,7 @@ <!-- Matches all save actions (in this case, only user registration) --> <action path="/Save*" type="org.apache.struts.scripting.ScriptAction" - parameter="/WEB-INF/scripts/Save{1}.bsh" + parameter="/WEB-INF/scripts/Save{1}.gv" name="{1}Form" scope="request" input="{1}"/> Modified: struts/scripting/trunk/src/struts-example/WEB-INF/struts-config.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/src/struts-example/WEB-INF/struts-config.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/src/struts-example/WEB-INF/struts-config.xml (original) +++ struts/scripting/trunk/src/struts-example/WEB-INF/struts-config.xml Tue Dec 6 18:51:31 2005 @@ -62,7 +62,7 @@ <!-- Display welcome page --> <action path="/Welcome" type="org.apache.struts.scripting.ScriptAction" - parameter="/WEB-INF/scripts/Welcome.bsh"> + parameter="/WEB-INF/scripts/Welcome.gv"> <forward name="failure" path="/Error.jsp" /> <forward name="success" path="/welcome.jsp" /> </action> @@ -71,7 +71,7 @@ <action path="/Locale" type="org.apache.struts.scripting.ScriptAction" - parameter="/WEB-INF/scripts/Locale.bsh?defaultTarget=welcome" /> + parameter="/WEB-INF/scripts/Locale.gv?defaultTarget=welcome" /> <!-- Display registration page --> <action path="/Registration" @@ -88,7 +88,7 @@ <!-- Process a user logon --> <action path="/SubmitLogon" type="org.apache.struts.scripting.ScriptAction" - parameter="/WEB-INF/scripts/Logon.bsh" + parameter="/WEB-INF/scripts/Logon.gv" name="LogonForm" scope="request" input="logon"> @@ -101,14 +101,14 @@ <!-- Process a user logoff --> <action path="/Logoff" type="org.apache.struts.scripting.ScriptAction" - parameter="/WEB-INF/scripts/Logoff.bsh"> + parameter="/WEB-INF/scripts/Logoff.gv"> <forward name="success" path="/Welcome.do"/> </action> <!-- Edit mail subscription --> <action path="/EditSubscription" type="org.apache.struts.scripting.ScriptAction" - parameter="/WEB-INF/scripts/EditSubscription.bsh" + parameter="/WEB-INF/scripts/EditSubscription.gv" name="SubscriptionForm" scope="request" validate="false"> @@ -119,7 +119,7 @@ <!-- Save mail subscription --> <action path="/SaveSubscription" type="org.apache.struts.scripting.ScriptAction" - parameter="/WEB-INF/scripts/SaveSubscription.bsh" + parameter="/WEB-INF/scripts/SaveSubscription.gv" name="SubscriptionForm" scope="request" input="subscription"> Modified: struts/scripting/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/xdocs/changes.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/xdocs/changes.xml (original) +++ struts/scripting/trunk/xdocs/changes.xml Tue Dec 6 18:51:31 2005 @@ -23,6 +23,12 @@ <body> + <release version="1.0.1" date="Unreleased"> + <action dev="mrdon" type="add"> + Changed Mailreader example to use Groovy instead of BeanShell due to possible licensing issues. + </action> + </release> + <release version="1.0.0" date="2005-12-04"> <action dev="mrdon" type="add"> Updated BeanShell to 2.0 Modified: struts/scripting/trunk/xdocs/index.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/xdocs/index.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/xdocs/index.xml (original) +++ struts/scripting/trunk/xdocs/index.xml Tue Dec 6 18:51:31 2005 @@ -26,9 +26,9 @@ <a name="overview"/> <p>This project allows Struts Actions to be written in the scripting language of one's choice rather than as Java classes. It uses the - <a href="http://jakarta.apache.org/bsf">Beans Scripting Framework</a> + <a href="http://jakarta.apache.org/bsf">Bean Scripting Framework</a> to allow scripts to be written in any language BSF supports like Perl, - Python, Ruby, JavaScript, BeanShell, and even VBScript. + Python, Ruby, JavaScript, Groovy, and even VBScript. </p> <p> Struts Scripting allows an application to be developed rapidly with @@ -38,7 +38,7 @@ may have a scripting background, to be more involved, leaving the Java developers to create the reusable services the Struts actions will interact with. Finally, when used with Java-like languages such as <a - href="http://www.beanshell.org">BeanShell</a>, applications can quickly be + href="http://groovy.codehaus.org">Groovy</a>, applications can quickly be stood up, then later the Struts action scripts can be migrated to Java for better performance. </p> @@ -46,7 +46,7 @@ <subsection name="Features"> <a name="features"/> <ul> - <li>Implement Actions with JavaScript, BeanShell, etc.</li> + <li>Implement Actions with JavaScript, Groovy, etc.</li> <li>Supports all BSF languages</li> <li>Scripts cached in memory on first use</li> <li>Ability to pass parameters to script through Struts config</li> @@ -62,7 +62,7 @@ <a href="apidocs/org/apache/struts/scripting/BSFManagerFilter.html">Filter</a> API's.</li> <li><a href="http://svn.apache.org/viewcvs.cgi/struts/scripting/trunk/src/struts-example/">Struts Mailreader</a> - A rewrite of the Struts 1.2.8 Mailreader example application using Struts Scripting - and <a href="http://www.beanshell.org">BeanShell</a></li> + and <a href="http://groovy.codehaus.org">Groovy</a></li> </ul> </subsection> </section> Modified: struts/scripting/trunk/xdocs/navigation.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/xdocs/navigation.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/xdocs/navigation.xml (original) +++ struts/scripting/trunk/xdocs/navigation.xml Tue Dec 6 18:51:31 2005 @@ -9,7 +9,6 @@ <item name="User Guide" href="user-guide.html"/> <item name="Source Guide" href="source-guide.html"/> <item name="Download" href="http://struts.apache.org/acquiring.html"/> - <item name="Download (old)" href="http://sourceforge.net/project/showfiles.php?group_id=49385&package_id=84734"/> </menu> <menu name="Quick Links"> Modified: struts/scripting/trunk/xdocs/source-guide.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/xdocs/source-guide.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/xdocs/source-guide.xml (original) +++ struts/scripting/trunk/xdocs/source-guide.xml Tue Dec 6 18:51:31 2005 @@ -30,7 +30,7 @@ Next, it gives help on how to build common artifacts. </p> <p>Again, since the heavy lifting is done by the - <a href="http://jakarta.apache.org/bsf">Beans Scripting Framework </a> + <a href="http://jakarta.apache.org/bsf">Bean Scripting Framework </a> and the scripting engines themselves, there isn't much code to this project itself. </p> <ul> @@ -46,7 +46,7 @@ <li><code>/src</code> - All source code can be found here</li> <li><code>/src/java</code> - The source code for the Struts Scripting framework itself</li> <li><code>/src/struts-example</code> - A modified version of the Struts 1.2.8 Mailreader example application. - This version replaces Java-coded Struts Actions with <a href="http://www.beanshell.org">Beanshell</a> scripts.</li> + This version replaces Java-coded Struts Actions with <a href="http://groovy.codehaus.org">Groovy</a> scripts.</li> </ul> <ul> <li><code>/xdocs</code> - The XML source code for all documentation, including this guide.</li> Modified: struts/scripting/trunk/xdocs/user-guide.xml URL: http://svn.apache.org/viewcvs/struts/scripting/trunk/xdocs/user-guide.xml?rev=354676&r1=354675&r2=354676&view=diff ============================================================================== --- struts/scripting/trunk/xdocs/user-guide.xml (original) +++ struts/scripting/trunk/xdocs/user-guide.xml Tue Dec 6 18:51:31 2005 @@ -26,7 +26,7 @@ <a name="overview"/> <p>The entire Struts Scripting project is only a few classes, since most of the heavy lifting is done by the - <a href="http://jakarta.apache.org/bsf">Beans Scripting Framework</a> + <a href="http://jakarta.apache.org/bsf">Bean Scripting Framework</a> and the scripting engines themselves. Therefore, there are only a few steps you'll need to take in order to sucessfully install and use Struts Scripting. </p> @@ -37,7 +37,7 @@ <subsection name="Installation"> <a name="installation"/> <p>After downloading the Struts Scripting distribution, copy the Struts - Scripting jar, <code>struts-scripting-1.0.jar</code>, to your application's + Scripting jar, <code>struts-scripting-1.0.0.jar</code>, to your application's libraries directory. When deployed, this directory will be <code>WEB-INF/lib</code>. </p> <p>Next, choose which scripting engine you want to use. BSF ships with knowledge about @@ -84,7 +84,7 @@ </table> <p>Once you have picked a language, you need to download its libraries and install it into your application, which usually means copying its jar files into the same location - you copied the Struts Scripting jar. If you are not sure, we recommend BeanShell + you copied the Struts Scripting jar. If you are not sure, we recommend Groovy which ships with Struts Scripting, as it features a very similar Java-like syntax. </p> <p><i>Optional</i>: If you don't see your desired language that claims to support BSF, @@ -128,7 +128,7 @@ <p>This ability to pass parameters can enable DispatchAction-type behavior where one script file can handle multiple action paths. If you are using Struts Action 1.3 or later, this feature isn't as useful since you can pass multiple values through ActionMapping using the - <code><set-property key="foo" value="bar"<</code> syntax. + <code><set-property key="foo" value="bar"></code> syntax. </p> <p> Before the script completes, the next ActionForward needs to be --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]