Author: andreas
Date: Fri Aug 19 09:07:01 2005
New Revision: 233502
URL: http://svn.apache.org/viewcvs?rev=233502&view=rev
Log:
Allowing non-lenya-page usecase views (for instance plain XML)
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseView.java
lenya/trunk/src/webapp/lenya/usecases/usecases.js
Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseView.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseView.java?rev=233502&r1=233501&r2=233502&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseView.java
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/UsecaseView.java Fri Aug
19 09:07:01 2005
@@ -35,6 +35,7 @@
protected static final String ELEMENT_PARAMETER = "parameter";
protected static final String ATTRIBUTE_NAME = "name";
protected static final String ATTRIBUTE_VALUE = "value";
+ protected static final String ATTRIBUTE_URI = "uri";
private Map parameters = new HashMap();
@@ -42,7 +43,13 @@
* @see
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(Configuration config) throws ConfigurationException {
- this.templateUri = config.getAttribute(ATTRIBUTE_TEMPLATE_URI);
+ this.templateUri = config.getAttribute(ATTRIBUTE_TEMPLATE_URI, null);
+ this.viewUri = config.getAttribute(ATTRIBUTE_URI, null);
+
+ if (this.viewUri == null && this.templateUri == null) {
+ throw new ConfigurationException("Either uri or template attribute
must be declared!");
+ }
+
this.showMenu = config.getAttributeAsBoolean(ATTRIBUTE_SHOW_MENU,
false);
Configuration[] parameterConfigs =
config.getChildren(ELEMENT_PARAMETER);
@@ -59,10 +66,16 @@
* @return The URI of the JX template;
*/
public String getTemplateURI() {
- if (this.templateUri == null) {
- throw new RuntimeException("The template URI was not configured!");
- }
return this.templateUri;
+ }
+
+ private String viewUri;
+
+ /**
+ * @return The URI of the JX template;
+ */
+ public String getViewURI() {
+ return this.viewUri;
}
private boolean showMenu;
Modified: lenya/trunk/src/webapp/lenya/usecases/usecases.js
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/usecases.js?rev=233502&r1=233501&r2=233502&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/usecases.js (original)
+++ lenya/trunk/src/webapp/lenya/usecases/usecases.js Fri Aug 19 09:07:01 2005
@@ -107,13 +107,20 @@
while (!ready) {
try {
- var viewUri = "view/" + menu + "/" + view.getTemplateURI();
- if (cocoon.log.isDebugEnabled())
- cocoon.log.debug("usecases.js::executeUsecase() in usecase
" + usecaseName + ", creating view, calling Cocoon with viewUri = [" + viewUri
+ "]");
-
- cocoon.sendPageAndWait(viewUri, {
- "usecase" : proxy
- });
+ var templateUri = view.getTemplateURI();
+ if (templateUri) {
+ var viewUri = "view/" + menu + "/" + view.getTemplateURI();
+ if (cocoon.log.isDebugEnabled())
+ cocoon.log.debug("usecases.js::executeUsecase() in
usecase " + usecaseName + ", creating view, calling Cocoon with viewUri = [" +
viewUri + "]");
+ cocoon.sendPageAndWait(viewUri, {
+ "usecase" : proxy
+ });
+ }
+ else {
+ var viewUri = view.getViewURI();
+ cocoon.sendPage(viewUri);
+ return;
+ }
}
catch (exception) {
/* if an exception was thrown by the view, allow the usecase
to rollback the transition */
|