You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/07/12 22:22:09 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/modules/screens TemplateScreen.java TemplateSecureScreen.java RawScreen.java
jvanzyl 01/07/12 13:22:09
Modified: src/java/org/apache/turbine/modules Module.java
src/java/org/apache/turbine/modules/actions
TemplateSecureAction.java
src/java/org/apache/turbine/modules/actions/sessionvalidator
TemplateSessionValidator.java
src/java/org/apache/turbine/modules/layouts
TemplateLayout.java
src/java/org/apache/turbine/modules/navigations
TemplateNavigation.java
src/java/org/apache/turbine/modules/screens
TemplateScreen.java TemplateSecureScreen.java
Removed: src/java/org/apache/turbine/modules Layout.java
Navigation.java Page.java Screen.java
src/java/org/apache/turbine/modules/layouts JspLayout.java
VelocityXslLayout.java
src/java/org/apache/turbine/modules/pages TemplatePage.java
src/java/org/apache/turbine/modules/screens RawScreen.java
Log:
- updating module system
Revision Changes Path
1.3 +30 -8 jakarta-turbine/src/java/org/apache/turbine/modules/Module.java
Index: Module.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/Module.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Module.java 2001/07/10 01:03:17 1.2
+++ Module.java 2001/07/12 20:21:30 1.3
@@ -62,26 +62,48 @@
* future use is yet to be determined.
*
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @version $Id: Module.java,v 1.2 2001/07/10 01:03:17 jvanzyl Exp $
+ * @version $Id: Module.java,v 1.3 2001/07/12 20:21:30 jvanzyl Exp $
*/
public abstract class Module
{
/**
- * The output generated by the module will be
- * directly output.
+ * A subclass must override this method to build itself.
+ * Subclasses override this method to store the layout in RunData
+ * or to write the layout to the output stream referenced in
+ * RunData.
+ *
+ * @param data Turbine information.
+ * @exception Exception a generic exception.
*/
- public void execute(RunData data)
+ protected String doBuild( RunData data )
throws Exception
{
+ return "";
}
-
+
/**
- * The output generated will be collected in
- * a String object.
+ * Subclasses can override this method to add additional
+ * functionality. This method is protected to force clients to
+ * use LayoutLoader to build a Layout.
+ *
+ * @param data Turbine information.
+ * @exception Exception a generic exception.
*/
+ protected String build( RunData data )
+ throws Exception
+ {
+ return doBuild( data );
+ }
+
public String evaluate(RunData data)
throws Exception
{
- return "";
+ return doBuild(data);
}
+
+ public void execute(RunData data)
+ throws Exception
+ {
+ doBuild(data);
+ }
}
1.2 +3 -2 jakarta-turbine/src/java/org/apache/turbine/modules/actions/TemplateSecureAction.java
Index: TemplateSecureAction.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/actions/TemplateSecureAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TemplateSecureAction.java 2001/07/10 01:13:23 1.1
+++ TemplateSecureAction.java 2001/07/12 20:21:39 1.2
@@ -71,7 +71,7 @@
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
- * @version $Id: TemplateSecureAction.java,v 1.1 2001/07/10 01:13:23 jvanzyl Exp $
+ * @version $Id: TemplateSecureAction.java,v 1.2 2001/07/12 20:21:39 jvanzyl Exp $
*/
public abstract class TemplateSecureAction
extends TemplateAction
@@ -83,7 +83,8 @@
* @param data Turbine information.
* @exception Exception, a generic exception.
*/
- protected void perform( RunData data ) throws Exception
+ protected void perform( RunData data )
+ throws Exception
{
if ( isAuthorized( data ) )
{
1.12 +5 -3 jakarta-turbine/src/java/org/apache/turbine/modules/actions/sessionvalidator/TemplateSessionValidator.java
Index: TemplateSessionValidator.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/actions/sessionvalidator/TemplateSessionValidator.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- TemplateSessionValidator.java 2001/07/10 01:03:35 1.11
+++ TemplateSessionValidator.java 2001/07/12 20:21:44 1.12
@@ -71,9 +71,10 @@
* @see TemplateSecureSessionValidator
* @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
- * @version $Id: TemplateSessionValidator.java,v 1.11 2001/07/10 01:03:35 jvanzyl Exp $
+ * @version $Id: TemplateSessionValidator.java,v 1.12 2001/07/12 20:21:44 jvanzyl Exp $
*/
-public class TemplateSessionValidator extends SessionValidator
+public class TemplateSessionValidator
+ extends SessionValidator
{
private String COUNTER = "_session_access_counter";
// the COUNTER can be placed as a hidden field in
@@ -86,7 +87,8 @@
* @param data Turbine information.
* @exception Exception, a generic exception.
*/
- public void doPerform( RunData data ) throws Exception
+ public void doPerform( RunData data )
+ throws Exception
{
// pull user from session, update access times, counters
data.populate();
1.2 +5 -34 jakarta-turbine/src/java/org/apache/turbine/modules/layouts/TemplateLayout.java
Index: TemplateLayout.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/layouts/TemplateLayout.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TemplateLayout.java 2001/07/10 01:13:24 1.1
+++ TemplateLayout.java 2001/07/12 20:21:50 1.2
@@ -54,17 +54,13 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.modules.Layout;
-import org.apache.turbine.Turbine;
-import org.apache.turbine.services.template.TurbineTemplate;
-import org.apache.turbine.TemplateContext;
import org.apache.turbine.RunData;
-import org.apache.turbine.util.template.TemplateNavigation;
+import org.apache.turbine.modules.Module;
/**
*/
public class TemplateLayout
- extends Layout
+ extends Module
{
/**
* Method called by LayoutLoader.
@@ -72,34 +68,9 @@
* @param RunData
* @return processed template in a String
*/
- public String doBuild( RunData data ) throws Exception
+ public String doBuild( RunData data )
+ throws Exception
{
- // This doesn't make it easy to add new module types.
- //TurbineTemplate.doBuildLayout(data);
-
- // Get the context needed for template rendering.
- TemplateContext context = TurbineTemplate.getTemplateContext( data );
-
- String returnValue = "";
-
- // First, generate the screen and put it in the context so
- // we can grab it the layout template.
- returnValue = Turbine.getModuleLoader().getModule(
- Turbine.SCREENS, data.getScreen()).evaluate(data);
-
- // variable for the screen in the layout template
- context.put("screen_placeholder", returnValue);
-
- // Variable to reference the navigation screen in the layout
- // template.
- context.put("navigation", new TemplateNavigation( data ));
-
- // Grab the layout template set in the TemplatePage.
- // If null, then use the default layout template
- // (done by the TemplateInfo object )
- String templateName = data.getTemplateInfo().getLayoutTemplate();
-
- return TurbineTemplate
- .handleRequest(context, "layouts" + templateName);
+ return "";
}
}
1.8 +4 -19 jakarta-turbine/src/java/org/apache/turbine/modules/navigations/TemplateNavigation.java
Index: TemplateNavigation.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/navigations/TemplateNavigation.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TemplateNavigation.java 2001/07/10 01:03:42 1.7
+++ TemplateNavigation.java 2001/07/12 20:21:56 1.8
@@ -55,15 +55,14 @@
*/
import org.apache.turbine.RunData;
-import org.apache.turbine.modules.Navigation;
-import org.apache.turbine.services.template.TurbineTemplate;
import org.apache.turbine.TemplateContext;
-
+import org.apache.turbine.modules.Module;
+import org.apache.turbine.services.template.TurbineTemplate;
/**
*/
public class TemplateNavigation
- extends Navigation
+ extends Module
{
/**
* Velocity Navigations extending this class should overide this
@@ -91,7 +90,6 @@
protected void doBuildTemplate( RunData data )
throws Exception
{
- doBuildTemplate( data, TurbineTemplate.getTemplateContext(data) );
}
/**
@@ -104,19 +102,7 @@
public String buildTemplate( RunData data )
throws Exception
{
- TemplateContext context = TurbineTemplate.getTemplateContext( data );
-
- String templateName = data.getTemplateInfo().getNavigationTemplate();
-
- // Usually adds the leading slash, but make it sure.
- if ((templateName.length() > 0) &&
- (templateName.charAt(0) != '/'))
- {
- templateName = '/' + templateName;
- }
-
- return TurbineTemplate.handleRequest(
- context,"navigations" + templateName);
+ return "";
}
/**
@@ -132,5 +118,4 @@
doBuildTemplate(data);
return buildTemplate(data);
}
-
}
1.14 +17 -71 jakarta-turbine/src/java/org/apache/turbine/modules/screens/TemplateScreen.java
Index: TemplateScreen.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/screens/TemplateScreen.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TemplateScreen.java 2001/07/10 01:03:49 1.13
+++ TemplateScreen.java 2001/07/12 20:22:05 1.14
@@ -55,12 +55,10 @@
*/
import org.apache.turbine.Turbine;
-import org.apache.turbine.modules.Screen;
+import org.apache.turbine.TemplateContext;
import org.apache.turbine.RunData;
-import org.apache.turbine.util.StringUtils;
+import org.apache.turbine.modules.Module;
import org.apache.turbine.services.template.TurbineTemplate;
-import org.apache.turbine.TemplateContext;
-import org.apache.turbine.services.resources.TurbineResources;
/**
* Template Screen.
@@ -75,10 +73,10 @@
* going on there (it is quite simple really).
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
- * @version $Id: TemplateScreen.java,v 1.13 2001/07/10 01:03:49 jvanzyl Exp $
+ * @version $Id: TemplateScreen.java,v 1.14 2001/07/12 20:22:05 jvanzyl Exp $
*/
public class TemplateScreen
- extends Screen
+ extends Module
{
/**
* This method should be overidden by subclasses that wish to add
@@ -108,57 +106,10 @@
* @return A ConcreteElement.
* @exception Exception, a generic exception.
*/
- public String buildTemplate( RunData data ) throws Exception
+ public String buildTemplate( RunData data )
+ throws Exception
{
- String screenData = null;
- TemplateContext context = TurbineTemplate.getTemplateContext(data);
-
- // This will already be properly set and will not be null
- // because of TemplateSessionValidator.
- String templateName = TurbineTemplate.getScreenTemplate(
- data.getTemplateInfo().getScreenTemplate() );
-
- // Template service adds the leading slash, but make it sure.
- if ((templateName.length() > 0) &&
- (templateName.charAt(0) != '/'))
- {
- templateName = '/' + templateName;
- }
-
- try
- {
- // if a layout has been defined return the results, otherwise
- // send the results directly to the output stream.
- if (getLayout(data) == null)
- {
- TurbineTemplate.handleRequest(context, "screens" + templateName,
- data.getResponse().getOutputStream());
- }
- else
- {
- screenData = TurbineTemplate.handleRequest(
- context,"screens" + templateName);
- }
- }
- catch (Exception e)
- {
- // If there is an error, build a $processingException and
- // attempt to call the error.vm template in the screens
- // directory.
- context.put ( "processingException", e.toString() );
- context.put ( "stackTrace", StringUtils.stackTrace(e) );
- templateName = TurbineResources.getString(
- "template.error", "/error.vm");
- if ((templateName.length() > 0) &&
- (templateName.charAt(0) != '/'))
- {
- templateName = '/' + templateName;
- }
- screenData = TurbineTemplate.handleRequest(
- context, "screens" + templateName);
- }
-
- return screenData;
+ return "";
}
/**
@@ -189,6 +140,10 @@
doBuildTemplate(data);
out = buildTemplate(data);
}
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
finally
{
doPostBuildTemplate(data);
@@ -210,19 +165,8 @@
*/
public static void setTemplate(RunData data, String template)
{
- data.getTemplateInfo().setScreenTemplate(template);
- try
- {
- // We have do call getScreenTemplate because of the path
- // separator.
- data.getTemplateInfo().setLayoutTemplate(
- TurbineTemplate.getLayoutTemplate(
- data.getTemplateInfo().getScreenTemplate()));
- }
- catch( Exception e )
- {
- // Nothing to do.
- }
+ //!! need to know what the target template type is.
+ data.setTarget(template);
}
/**
@@ -247,7 +191,8 @@
public void doRedirect(RunData data, String screen, String template )
throws Exception
{
- setTemplate(data, template);
+ //!! need more generic way to do a redirect.
+ //setTemplate(data, template);
Turbine.getModuleLoader().getModule(
Turbine.SCREENS, screen).execute(data);
@@ -274,7 +219,8 @@
public void doRedirect(RunData data, String template)
throws Exception
{
- doRedirect (data, TurbineTemplate.getScreenModule(template), template );
+ //!! use the resolver for this.
+ //doRedirect (data, TurbineTemplate.getScreenModule(template), template );
}
public org.apache.turbine.TemplateContext getTemplateContext(RunData data)
1.2 +5 -15 jakarta-turbine/src/java/org/apache/turbine/modules/screens/TemplateSecureScreen.java
Index: TemplateSecureScreen.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/screens/TemplateSecureScreen.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TemplateSecureScreen.java 2001/07/10 01:13:25 1.1
+++ TemplateSecureScreen.java 2001/07/12 20:22:06 1.2
@@ -55,8 +55,8 @@
*/
import org.apache.turbine.RunData;
-import org.apache.turbine.services.template.TurbineTemplate;
import org.apache.turbine.TemplateContext;
+import org.apache.turbine.services.template.TurbineTemplate;
/**
* VelocitySecureScreen
@@ -70,32 +70,22 @@
* your base screen.
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
- * @version $Id: TemplateSecureScreen.java,v 1.1 2001/07/10 01:13:25 jvanzyl Exp $
+ * @version $Id: TemplateSecureScreen.java,v 1.2 2001/07/12 20:22:06 jvanzyl Exp $
*/
public abstract class TemplateSecureScreen
extends TemplateScreen
{
/**
- * Implement this to add information to the context.
- *
- * @param data Turbine information.
- * @param context Context for web pages.
- * @exception Exception, a generic exception.
- */
- protected abstract void doBuildTemplate( RunData data,
- TemplateContext context )
- throws Exception;
-
- /**
* This method overrides the method in WebMacroSiteScreen to
* perform a security check first.
*
* @param data Turbine information.
* @exception Exception, a generic exception.
*/
- protected void doBuildTemplate( RunData data ) throws Exception
+ protected void doBuildTemplate( RunData data )
+ throws Exception
{
- if ( isAuthorized( data ) )
+ if (isAuthorized(data))
{
doBuildTemplate( data, TurbineTemplate.getTemplateContext( data ) );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org