You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/02/24 23:45:28 UTC
svn commit: r155272 - in lenya/trunk/src:
java/org/apache/lenya/cms/usecase/AbstractUsecase.java
java/org/apache/lenya/cms/usecase/Usecase.java
webapp/lenya/usecases/usecases.js
Author: andreas
Date: Thu Feb 24 14:45:27 2005
New Revision: 155272
URL: http://svn.apache.org/viewcvs?view=rev&rev=155272
Log:
allow non-interactive usecases
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java
lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java
lenya/trunk/src/webapp/lenya/usecases/usecases.js
Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java?view=diff&r1=155271&r2=155272
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java Thu Feb 24 14:45:27 2005
@@ -368,4 +368,11 @@
this.parameters.remove(name);
}
+ /**
+ * @see org.apache.lenya.cms.usecase.Usecase#isInteractive()
+ */
+ public boolean isInteractive() {
+ return true;
+ }
+
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java?view=diff&r1=155271&r2=155272
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/Usecase.java Thu Feb 24 14:45:27 2005
@@ -22,7 +22,7 @@
/**
* Usecase interface.
- *
+ *
* @version $Id$
*/
public interface Usecase {
@@ -31,69 +31,73 @@
* The <code>Usecase</code> role.
*/
String ROLE = Usecase.class.getName();
-
+
/**
* Sets a parameter from the form.
* @param name The parameter name.
* @param value The parameter value.
*/
void setParameter(String name, Object value);
-
+
/**
* Returns the current value of a parameter.
* @param name The parameter name.
* @return An object.
*/
Object getParameter(String name);
-
+
/**
* Returns the current value of a parameter as a string.
* @param name The parameter name.
* @return A string or <code>null</code> if the parameter was not set.
*/
String getParameterAsString(String name);
-
+
/**
- * Sets a parameter from the form. This method is called for parts in multipart requests.
+ * Sets a parameter from the form. This method is called for parts in
+ * multipart requests.
* @param name The parameter name.
* @param value The parameter value.
*/
void setPart(String name, Part value);
-
+
/**
* Advances the usecase to the next step. This method is called when all
* parameters are set.
*/
void advance();
-
+
/**
* Checks the conditions before a form is displayed.
- * @throws UsecaseException if an error occurs that causes an unstable system.
+ * @throws UsecaseException if an error occurs that causes an unstable
+ * system.
*/
void checkPreconditions() throws UsecaseException;
-
+
/**
* Checks the conditions after the usecase was executed.
- * @throws UsecaseException if an error occurs that causes an unstable system.
+ * @throws UsecaseException if an error occurs that causes an unstable
+ * system.
*/
void checkPostconditions() throws UsecaseException;
-
+
/**
* Checks the conditions right before the operation is executed.
- * @throws UsecaseException if an error occurs that causes an unstable system.
+ * @throws UsecaseException if an error occurs that causes an unstable
+ * system.
*/
void checkExecutionConditions() throws UsecaseException;
-
+
/**
* Returns the error messages from the previous operation. Error messages
* prevent the operation from being executed.
* @return A list of strings.
*/
List getErrorMessages();
-
+
/**
- * Returns the info messages from the previous operation. Info messages
- * do not prevent the operation from being executed.
+ * Returns the info messages from the previous operation. Info messages do
+ * not prevent the operation from being executed.
* @return A list of strings.
*/
List getInfoMessages();
@@ -102,15 +106,23 @@
* Executes the usecase. During this method error and info messages are
* filled in. If getErrorMessages() returns an empty array, the operation
* succeeded. Otherwise, the operation failed.
- * @throws UsecaseException if an error occured that causes an unstable system.
+ * @throws UsecaseException if an error occured that causes an unstable
+ * system.
*/
void execute() throws UsecaseException;
-
+
/**
- * Returns the webapp URL which should be redirected to after the usecase is completed.
+ * Returns the webapp URL which should be redirected to after the usecase is
+ * completed.
* @param success If the usecase was completed successfully.
* @return A web application URL.
*/
String getTargetURL(boolean success);
-
-}
+
+ /**
+ * @return If the usecase is interactive, i.e. a confirmation screen should
+ * be shown.
+ */
+ boolean isInteractive();
+
+}
\ No newline at end of file
Modified: lenya/trunk/src/webapp/lenya/usecases/usecases.js
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/usecases.js?view=diff&r1=155271&r2=155272
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/usecases.js (original)
+++ lenya/trunk/src/webapp/lenya/usecases/usecases.js Thu Feb 24 14:45:27 2005
@@ -60,42 +60,49 @@
var flowHelper = cocoon.getComponent("org.apache.lenya.cms.cocoon.flow.FlowHelper");
var envelope = flowHelper.getPageEnvelope(cocoon);
var document = envelope.getDocument();
-
- passRequestParameters(flowHelper, usecase);
-
- var view = selectView(usecaseName);
-
- var ready = false;
var success = false;
+ passRequestParameters(flowHelper, usecase);
usecase.checkPreconditions();
- while (!ready) {
-
- cocoon.sendPageAndWait(view, {
- "usecase" : usecase
- });
+ if (usecase.isInteractive()) {
+ var view = selectView(usecaseName);
+ var ready = false;
+ while (!ready) {
- passRequestParameters(flowHelper, usecase);
- usecase.advance();
-
- if (cocoon.request.getParameter("submit")) {
- usecase.checkExecutionConditions();
- if (usecase.getErrorMessages().isEmpty()) {
- usecase.execute();
+ cocoon.sendPageAndWait(view, {
+ "usecase" : usecase
+ });
+
+ passRequestParameters(flowHelper, usecase);
+ usecase.advance();
+
+ if (cocoon.request.getParameter("submit")) {
+ usecase.checkExecutionConditions();
if (usecase.getErrorMessages().isEmpty()) {
- usecase.checkPostconditions();
+ usecase.execute();
if (usecase.getErrorMessages().isEmpty()) {
- ready = true;
- success = true;
+ usecase.checkPostconditions();
+ if (usecase.getErrorMessages().isEmpty()) {
+ ready = true;
+ success = true;
+ }
}
}
}
+ else if (cocoon.request.getParameter("cancel")) {
+ ready = true;
+ }
}
- else if (cocoon.request.getParameter("cancel")) {
- ready = true;
+ }
+ else {
+ usecase.execute();
+ if (usecase.getErrorMessages().isEmpty()) {
+ usecase.checkPostconditions();
+ if (usecase.getErrorMessages().isEmpty()) {
+ success = true;
+ }
}
-
}
var url = envelope.getContext() + usecase.getTargetURL(success);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org