[gee-svn] SF.net SVN: gabel: [113] trunk/gee/war/WEB-INF/classes
Status: Alpha
Brought to you by:
alllee
|
From: <al...@us...> - 2006-02-26 22:23:38
|
Revision: 113 Author: alllee Date: 2006-02-26 14:23:29 -0800 (Sun, 26 Feb 2006) ViewCVS: http://svn.sourceforge.net/gabel/?rev=113&view=rev Log Message: ----------- folding PrepareConsentForm action into StartExperiment to reduce code duplication. Modifying xwork.xml action mappings accordingly to go to specific methods within startExperiment. Modified Paths: -------------- trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java trunk/gee/war/WEB-INF/classes/xwork.xml Removed Paths: ------------- trunk/gee/src/java/edu/indiana/psych/gee/action/PrepareConsentForm.java Deleted: trunk/gee/src/java/edu/indiana/psych/gee/action/PrepareConsentForm.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/PrepareConsentForm.java 2006-02-26 22:02:44 UTC (rev 112) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/PrepareConsentForm.java 2006-02-26 22:23:29 UTC (rev 113) @@ -1,95 +0,0 @@ -package edu.indiana.psych.gee.action; - -import edu.indiana.psych.gee.ConsentForm; -import edu.indiana.psych.gee.Experiment; - -/** - * $Id$ - * - * @author <a href='al...@cs...'>Allen Lee</a> - * @version $Revision$ - */ - -@SuppressWarnings("serial") -public class PrepareConsentForm extends GeeAction { - - private String experimentName; - - private ConsentForm consentForm; - - private String message; - - public String execute() { - Experiment experiment = getExperimentService().find(experimentName); - if (experiment == Experiment.NULL) { - // FIXME: this String does not belong here at all, should be - // presentation-layer. Could provide a list and link of possible - // spelling corrections even? - message = String.format("There doesn't appear to be an experiment named '%s'.", experimentName); - return ERROR; - } - consentForm = experiment.getConsentForm(); - return SUCCESS; - } - - public void setExperimentName(String experimentName) { - this.experimentName = experimentName; - } - - public String getExperimentName() { - return experimentName; - } - - public String getMessage() { - return message; - } - - public ConsentForm getConsentForm() { - return consentForm; - } - -} -/* - * $Log$ - * Revision 1.4 2006/02/23 21:12:32 alllee - * extracting WebWork/xwork dependency to GeeAction base class. Currently supplies a logger and an ExperimentService (set by Spring) to subclasses. - * - * Revision 1.3 2006/02/02 23:17:25 alllee - * finally got validation working. here's the steps I had to take beyond dumping - * a FooAction-validation.xml in the appropriate path: - * 1. configure xwork.xml's start action to handle input results - this gets - * invoked when validation fails. Because we keep passing around the - * experiment name and other state across multiple pages, the result type - * should be "chain". The location of the result should be the name of - * another action. - * 2. the error message gets automagically inserted by webwork, nice! - * 3. added .errorMessage css to automagically colorize errors on a field. - * - * Revision 1.2 2006/01/17 08:34:54 alllee - * adding more presentation layer functionality, dynamic consent form is all set, - * but still need to hook in validation for the name. - * - * Revision 1.1 2006/01/17 02:51:40 alllee - * adding Action to load the consent form for the given experiment. - * - * Revision 1.4 2006/01/14 00:36:00 alllee - * adding a brief client message if StartExperiments fails. That class is not an - * optimal place to store those kind of messages, forces recompilation in order - * to change the message. Lift to a configuration later, there should be a - * webwork way to store messages. - * - * Revision 1.3 2006/01/13 09:30:54 alllee - * almost have experiments running - the StartExperiment action has all the - * information it needs and can start the experiment, but the startExperiment - * page is failing because forager-client.jar isn't there. Next step - make - * forager-client.jar there. - * - * Revision 1.2 2006/01/13 07:40:12 alllee - * starting to display experiment metadata through the page. still need to fill - * in the link to actually start and begin participating in an experiment. - * - * Revision 1.1 2005/12/21 21:47:27 alllee - * adding ant task to build web components and stubbed out XWork actions. - * - */ - Modified: trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java =================================================================== --- trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-02-26 22:02:44 UTC (rev 112) +++ trunk/gee/src/java/edu/indiana/psych/gee/action/StartExperiment.java 2006-02-26 22:23:29 UTC (rev 113) @@ -20,17 +20,15 @@ private ConsentForm consentForm; private String message; - public String execute() { - Experiment experiment = getExperiment(); - if (experiment == Experiment.NULL) { - // FIXME: this String does not belong here at all, should be - // presentation-layer. Could provide a list and link of possible - // spelling corrections even? - message = String.format("There doesn't appear to be an experiment named '%s'.", experimentName); - return ERROR; - } + public String prepare() { + consentForm = getExperiment().getConsentForm(); + return SUCCESS; + } + + public String start() { // FIXME: start up on a new port if it's already running? - experiment.start(); + prepare(); + getExperiment().start(); return SUCCESS; } @@ -43,9 +41,6 @@ } public ConsentForm getConsentForm() { - if (consentForm == null) { - consentForm = getExperiment().getConsentForm(); - } return consentForm; } Modified: trunk/gee/war/WEB-INF/classes/xwork.xml =================================================================== --- trunk/gee/war/WEB-INF/classes/xwork.xml 2006-02-26 22:02:44 UTC (rev 112) +++ trunk/gee/war/WEB-INF/classes/xwork.xml 2006-02-26 22:23:29 UTC (rev 113) @@ -1,65 +1,72 @@ -<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.1.dtd"> +<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" + "http://www.opensymphony.com/xwork/xwork-1.1.dtd"> <xwork> - <include file="webwork-default.xml"/> - - <!-- - <include file="config-browser.xml"/> - - <include file="xwork-continuations.xml"/> - - <include file="xwork-tags.xml"/> - - <include file="xwork-validation.xml" /> - - <include file="xwork-actionchaining.xml" /> - - <include file="xwork-ajax.xml" /> - --> - - <package name="default" extends="webwork-default"> - <default-interceptor-ref name="defaultStack"/> - <!-- the start page lists all available experiments --> - <action name="index" class="edu.indiana.psych.gee.action.ListExperiments"> - <result>index.jsp</result> - </action> - <action name="start" class="edu.indiana.psych.gee.action.StartExperiment"> - <result name="success">startExperiment.jsp</result> - <result name="error">error.jsp</result> - <result name="input">getConsent.jsp</result> - </action> - <action name="consent" class="edu.indiana.psych.gee.action.PrepareConsentForm"> - <result name="success">getConsent.jsp</result> - <result name="input">getConsent.jsp</result> - <result name="error">error.jsp</result> - </action> - <action name='contact'> - <result>contact.jsp</result> - </action> - </package> - <package name="admin" extends="default" namespace="/admin"> - <action name="index" class="edu.indiana.psych.gee.action.AdminAction" method="authenticate"> - <result name="success" type="freemarker">listExperiments.jsp</result> - <result name="error">error.jsp</result> - </action> - <action name="configure" class="edu.indiana.psych.gee.action.AdminAction" method="configure"> - <result name="error" type="chain">configure</result> - <result name="success">configureExperiment.jsp</result> - </action> - <action name="list" class="edu.indiana.psych.gee.action.AdminAction" method="listExperiments"> - <result name="success" type="freemarker">listExperiments.jsp</result> - <result name="error">error.jsp</result> - </action> - <action name="create" class="edu.indiana.psych.gee.action.AdminAction" method="createExperiment"> - <result type="redirect">listExperiments.jsp</result> - <result name="input">createExperiment.jsp</result> - </action> - <action name="start" class="edu.indiana.psych.gee.action.AdminAction" method="start"> - <result type="freemarker">listExperiments.jsp</result> - </action> - <action name="stop" class="edu.indiana.psych.gee.action.AdminAction" method="stop"> - <result type="freemarker">listExperiments.jsp</result> - </action> - </package> - -</xwork> + <include file="webwork-default.xml"/> + + <!-- + <include file="config-browser.xml"/> + + <include file="xwork-continuations.xml"/> + + <include file="xwork-tags.xml"/> + + <include file="xwork-validation.xml" /> + + <include file="xwork-actionchaining.xml" /> + + <include file="xwork-ajax.xml" /> + --> + + <package name="default" extends="webwork-default"> + <default-interceptor-ref name="defaultStack"/> + <!-- the start page lists all available experiments --> + <action name="index" class="edu.indiana.psych.gee.action.ListExperiments"> + <result>index.jsp</result> + </action> + <action name="start" class="edu.indiana.psych.gee.action.StartExperiment" method="start"> + <result name="success">startExperiment.jsp</result> + <result name="error">error.jsp</result> + <result name="input">getConsent.jsp</result> + </action> + <action name="consent" class="edu.indiana.psych.gee.action.StartExperiment" method="prepare"> + <result name="success">getConsent.jsp</result> + <result name="input">getConsent.jsp</result> + <result name="error">error.jsp</result> + </action> + <action name='contact'> + <result>contact.jsp</result> + </action> + </package> + <package name="admin" extends="default" namespace="/admin"> + <action name="index" class="edu.indiana.psych.gee.action.AdminAction" + method="authenticate"> + <result name="success" type="freemarker">listExperiments.jsp</result> + <result name="error">error.jsp</result> + </action> + <action name="configure" class="edu.indiana.psych.gee.action.AdminAction" + method="configure"> + <result name="error" type="chain">configure</result> + <result name="success">configureExperiment.jsp</result> + </action> + <action name="list" class="edu.indiana.psych.gee.action.AdminAction" + method="listExperiments"> + <result name="success" type="freemarker">listExperiments.jsp</result> + <result name="error">error.jsp</result> + </action> + <action name="create" class="edu.indiana.psych.gee.action.AdminAction" + method="createExperiment"> + <result type="redirect">listExperiments.jsp</result> + <result name="input">createExperiment.jsp</result> + </action> + <action name="start" class="edu.indiana.psych.gee.action.AdminAction" + method="start"> + <result type="freemarker">listExperiments.jsp</result> + </action> + <action name="stop" class="edu.indiana.psych.gee.action.AdminAction" + method="stop"> + <result type="freemarker">listExperiments.jsp</result> + </action> + </package> + +</xwork> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |