cedric 01/12/27 09:35:38
Modified: contrib/tiles/src/share/org/apache/struts/taglib/tiles
AddTag.java AddTagParent.java
AttributeToScopeTag.java ComponentConstants.java
DefinitionTag.java GetAttributeTag.java GetTag.java
ImportAttributeTag.java InitDefinitionsTag.java
InsertTag.java PutListTag.java
PutListTagParent.java PutTag.java PutTagParent.java
UseAttributeTag.java UseAttributeTei.java
contrib/tiles/src/share/org/apache/struts/taglib/tiles/ext
TextTag.java
contrib/tiles/src/share/org/apache/struts/taglib/tiles/util
TagUtils.java
contrib/tiles/src/share/org/apache/struts/tiles
ActionComponentServlet.java
AttributeDefinition.java ComponentContext.java
ComponentDefinition.java
ComponentDefinitionsFactory.java
DefinitionAttribute.java
DefinitionNameAttribute.java
DefinitionsFactoryException.java
DefinitionsUtil.java DirectStringAttribute.java
FactoryNotFoundException.java
NoSuchDefinitionException.java PathAttribute.java
UntyppedAttribute.java
contrib/tiles/src/share/org/apache/struts/tiles/resources
tiles-config.dtd
contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition
DefinitionsFactory.java I18nFactorySet.java
XmlAttribute.java XmlDefinition.java
XmlListAttribute.java XmlParser.java
contrib/tiles/src/tutorial/org/apache/struts/example/tiles
InitServlet.java
contrib/tiles/src/tutorial/org/apache/struts/example/tiles/invoice
EditInvoiceAction.java
contrib/tiles/src/tutorial/org/apache/struts/example/tiles/rssChannel
Channels.java
Log:
Add individual controller and reload capabilities
Revision Changes Path
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AddTag.java
Index: AddTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AddTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddTag.java 2001/08/01 14:36:40 1.1
+++ AddTag.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AddTag.java,v
1.1 2001/08/01 14:36:40 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:40 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AddTag.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AddTagParent.java
Index: AddTagParent.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AddTagParent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddTagParent.java 2001/08/01 14:36:40 1.1
+++ AddTagParent.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AddTagParent.java,v
1.1 2001/08/01 14:36:40 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:40 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AddTagParent.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AttributeToScopeTag.java
Index: AttributeToScopeTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AttributeToScopeTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AttributeToScopeTag.java 2001/08/01 14:36:40 1.1
+++ AttributeToScopeTag.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AttributeToScopeTag.java,v
1.1 2001/08/01 14:36:40 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:40 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/AttributeToScopeTag.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.3 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ComponentConstants.java
Index: ComponentConstants.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ComponentConstants.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ComponentConstants.java 2001/09/10 13:02:06 1.2
+++ ComponentConstants.java 2001/12/27 17:35:37 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ComponentConstants.java,v
1.2 2001/09/10 13:02:06 cedric Exp $
- * $Revision: 1.2 $
- * $Date: 2001/09/10 13:02:06 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ComponentConstants.java,v
1.3 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +24 -90
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/DefinitionTag.java
Index: DefinitionTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/DefinitionTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefinitionTag.java 2001/08/01 14:36:40 1.1
+++ DefinitionTag.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/DefinitionTag.java,v
1.1 2001/08/01 14:36:40 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:40 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/DefinitionTag.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
@@ -17,14 +17,14 @@
import javax.servlet.jsp.JspException;
/**
- * This is the tag handler for <template:definition>, which defines
- * a template / component. Definition is put in requested context, and can be
- * used in <template:insert>.
- *
+ * This is the tag handler for <tiles:definition>, which defines
+ * a tiles (or template / component). Definition is put in requested context, and
can be
+ * used in <tiles:insert>.
+ *
* @author Cedric Dumoulin
- * @version $Revision: 1.1 $ $Date: 2001/08/01 14:36:40 $
+ * @version $Revision: 1.2 $ $Date: 2001/12/27 17:35:37 $
*/
-public class DefinitionTag extends TagSupport implements PutTagParent,
PutListTagParent
+public class DefinitionTag extends DefinitionTagSupport implements PutTagParent,
PutListTagParent
{
/* JSP Tag attributes */
@@ -32,24 +32,12 @@
* Definition identifier.
*/
private String id;
-
- /**
- * Template page defined for this definition.
- */
- private String template;
/**
* Scope into which definition will be saved.
*/
private String scope;
- /**
- * Role associated to definition.
- * Role is not checked by this tag. Role checking is left to 'user'
- * of this class (ex : insert tag).
- */
- private String role;
-
/**
* Extends attribute value.
*/
@@ -69,7 +57,7 @@
{
super.release();
id = null;
- template = null;
+ page = null;
scope = null;
role = null;
extendsDefinition = null;
@@ -86,7 +74,7 @@
/**
* This method is a convenience for others tags for
- * putting content into the template definition.
+ * putting content into the tile definition.
* Content is already typed by caller.
*/
public void putAttribute(String name, Object content)
@@ -155,93 +143,49 @@
/**
* Access method for the id property.
- *
+ *
* @return the current value of the id property
- * @roseuid
+ * @roseuid
*/
- public String getId()
+ public String getId()
{
return id;
}
-
+
/**
* Sets the value of the id property.
- *
+ *
* @param aId the new value of the id property
*/
public void setId(String id)
{
this.id = id;
}
-
+
/**
* Access method for the scope property.
- *
+ *
* @return the current value of the scope property
*/
- public String getScope()
+ public String getScope()
{
return scope;
}
-
+
/**
* Sets the value of the scope property.
- *
+ *
* @param aScope the new value of the scope property
*/
public void setScope(String aScope)
{
scope = aScope;
}
-
- /**
- * Access method for the template property.
- *
- * @return the current value of the template property
- * @roseuid
- */
- public String getTemplate()
- {
- return template;
- }
-
- /**
- * Sets the value of the template property.
- * Same as setPage()
- *
- * @param aTemplate the new value of the template property
- * @roseuid
- */
- public void setTemplate(String template)
- {
- this.template = template;
- }
- /**
- * Sets the value of the page property.
- *
- * @param aTemplate the new value of the template property
- * @roseuid
- */
- public void setPage(String page)
- {
- this.template = page;
- }
-
- /**
- * Access method for the role property.
- * @return the current value of the template property
- */
- public String getRole()
- {
- return role;
- }
-
/**
- * @return void
- * Sets the value of the role property.
+ * Sets the value of the extends property.
*
- * @param template the new value of the path property
+ * @param definitionName Name of parent definition.
*/
public void setExtends(String definitionName)
{
@@ -249,26 +193,16 @@
}
/**
- * Access method for the role property.
- * @return the current value of the template property
+ * Access method for the extends property.
+ * @return the current value of the extends property
*/
public String getExtends()
{
return extendsDefinition;
}
- /**
- * Sets the value of the role property.
- *
- * @param template the new value of the path property
- */
- public void setRole(String role)
- {
- this.role = role;
- }
-
/**
- * Process the start tag by creating a new template definition.
+ * Process the start tag by creating a new definition.
*/
public int doStartTag() throws JspException
{
@@ -283,8 +217,8 @@
definition = new ComponentDefinition();
// Set definitions attributes
- if( template != null )
- definition.setTemplate(template);
+ if( page != null )
+ definition.setTemplate(page);
if( role != null )
definition.setRole(role);
1.3 +3 -3
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/GetAttributeTag.java
Index: GetAttributeTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/GetAttributeTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GetAttributeTag.java 2001/09/17 08:55:51 1.2
+++ GetAttributeTag.java 2001/12/27 17:35:37 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/GetAttributeTag.java,v
1.2 2001/09/17 08:55:51 cedric Exp $
- * $Revision: 1.2 $
- * $Date: 2001/09/17 08:55:51 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/GetAttributeTag.java,v
1.3 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.4 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/GetTag.java
Index: GetTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/GetTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- GetTag.java 2001/09/28 17:00:11 1.3
+++ GetTag.java 2001/12/27 17:35:37 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/GetTag.java,v
1.3 2001/09/28 17:00:11 cedric Exp $
- * $Revision: 1.3 $
- * $Date: 2001/09/28 17:00:11 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/GetTag.java,v
1.4 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.3 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ImportAttributeTag.java
Index: ImportAttributeTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ImportAttributeTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ImportAttributeTag.java 2001/11/02 16:50:05 1.2
+++ ImportAttributeTag.java 2001/12/27 17:35:37 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ImportAttributeTag.java,v
1.2 2001/11/02 16:50:05 cedric Exp $
- * $Revision: 1.2 $
- * $Date: 2001/11/02 16:50:05 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ImportAttributeTag.java,v
1.3 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.3 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/InitDefinitionsTag.java
Index: InitDefinitionsTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/InitDefinitionsTag.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InitDefinitionsTag.java 2001/09/28 17:00:11 1.2
+++ InitDefinitionsTag.java 2001/12/27 17:35:37 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/InitDefinitionsTag.java,v
1.2 2001/09/28 17:00:11 cedric Exp $
- * $Revision: 1.2 $
- * $Date: 2001/09/28 17:00:11 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/InitDefinitionsTag.java,v
1.3 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.5 +73 -49
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/InsertTag.java
Index: InsertTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/InsertTag.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- InsertTag.java 2001/11/02 16:50:04 1.4
+++ InsertTag.java 2001/12/27 17:35:37 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/InsertTag.java,v
1.4 2001/11/02 16:50:04 cedric Exp $
- * $Revision: 1.4 $
- * $Date: 2001/11/02 16:50:04 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/InsertTag.java,v
1.5 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
@@ -10,6 +10,7 @@
import org.apache.struts.tiles.ComponentContext;
import org.apache.struts.tiles.ComponentDefinition;
+import org.apache.struts.tiles.Controller;
import org.apache.struts.tiles.DefinitionsUtil;
import org.apache.struts.tiles.NoSuchDefinitionException;
import org.apache.struts.tiles.FactoryNotFoundException;
@@ -33,6 +34,7 @@
import javax.servlet.jsp.PageContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
/**
* This is the tag handler for <template:insert>, which includes
@@ -41,20 +43,19 @@
*
* @author David Geary
* @author Cedric Dumoulin
- * @version $Revision: 1.4 $ $Date: 2001/11/02 16:50:04 $
+ * @version $Revision: 1.5 $ $Date: 2001/12/27 17:35:37 $
*/
-public class InsertTag extends TagSupport implements PutTagParent,
ComponentConstants, PutListTagParent
+public class InsertTag extends DefinitionTagSupport implements PutTagParent,
ComponentConstants, PutListTagParent
{
/** debug flag */
- public final static boolean debug = true;
+ public final static boolean debug = false;
/* JSP Tag attributes */
/** Flush attribute value */
protected boolean flush = true;
- /** Name of entity to include */
- protected String name = null;
- /** Name of page, component or template to include */
- private String page = null;
+
+ /** Name to insert */
+ private String name = null;
/** Name of attribute from which to read page name to include */
private String attribute = null;
/** Name of bean used as entity to include */
@@ -63,8 +64,7 @@
private String beanProperty = null;
/** Scope of bean, if any */
private String beanScope = null;
- /** Role attribute */
- protected String role = null;
+
/**
* Is errors ignored ? This is the property for attribute 'ignore'.
* Default value is false, which throw an exception.
@@ -130,28 +130,22 @@
this.pageContext = pc;
super.setPageContext(pc);
}
+
/**
- * Set property
+ * Set property.
*/
- public void setComponent(String name){
- this.page = name;
+ public void setName(String value){
+ this.name = value;
}
/**
* Set property
*/
- public void setTemplate(String name){
+ public void setComponent(String name){
this.page = name;
}
/**
- * Set name property
- */
- public void setName(String name){
- this.name = name;
- }
-
- /**
* Set property
* @deprecated Use setDefinition() instead.
*/
@@ -166,13 +160,6 @@
this.definitionName = name;
}
- /**
- * Set property
- */
- public void setPage(String page){
- this.page = page;
- }
-
/**
* Set property
*/
@@ -217,14 +204,6 @@
}
/**
- * Set role attribute
- * @param name The role the user must be in to store content.
- */
- public void setRole(String role) {
- this.role = role;
- }
-
- /**
* Set ignore attribute
*/
public void setIgnore(boolean ignore)
@@ -313,6 +292,28 @@
return cachedCurrentContext;
}
+ /**
+ * Get instanciated Controller.
+ * Return controller denoted by controllerType, or null if controllerType
+ * is null.
+ * @throws JspException If controller can't be created.
+ */
+ private Controller getController() throws JspException
+ {
+ if( controllerType == null )
+ {
+ return null;
+ }
+ try
+ {
+ return ComponentDefinition.createController( controllerName, controllerType );
+ }
+ catch( InstantiationException ex )
+ {
+ throw new JspException( ex.getMessage() );
+ }
+ }
+
/**
* Process the start tag by checking tag's attributes and creating
appropriate handler.
* Possible handlers :
@@ -459,11 +460,11 @@
/**
* Process
- * @roseuid 3AB4CE540211
+ * @throws JspException If failed to create controller
*/
- public TagHandler processUrl(String url)
+ public TagHandler processUrl(String url) throws JspException
{
- return new InsertHandler(url, role );
+ return new InsertHandler(url, role, getController() );
}
/**
@@ -474,7 +475,7 @@
* @throws JspException- NoSuchDefinitionException No Definition
found for name.
* @throws JspException- FactoryNotFoundException Can't find
Definitions factory.
* @throws JspException- DefinedComponentFactoryException General
error in factory.
- * @roseuid 3AB4CEFB01CB
+ * @throws JspException InstantiationException Can't create requested controller
*/
protected TagHandler processDefinitionName(String name)
throws JspException
@@ -516,19 +517,35 @@
* Then, create appropriate tag handler.
* @param definition Definition to process.
* @return Appropriate TagHandler.
+ * @throws JspException InstantiationException Can't create requested controller
*/
protected TagHandler processDefinition(ComponentDefinition definition)
+ throws JspException
{
// Declare local variable in order to not change Tag attribute values.
String role = this.role;
String page = this.page;
- // Overload definition with tag's template and role.
- if(role == null )
- role = definition.getRole();
- if( page == null )
- page = definition.getTemplate();
- // Can check if page is set
- return new InsertHandler( definition.getAttributes(), page, role );
+ Controller controller = null;
+
+ try
+ {
+ controller = definition.getOrCreateController();
+
+ // Overload definition with tag's template and role.
+ if(role == null )
+ role = definition.getRole();
+ if( page == null )
+ page = definition.getTemplate();
+ if( controllerName != null )
+ controller = ComponentDefinition.createController( controllerName,
controllerType );
+
+ // Can check if page is set
+ return new InsertHandler( definition.getAttributes(), page, role, controller
);
+ }
+ catch( InstantiationException ex )
+ {
+ throw new JspException( ex.getMessage() );
+ }
}
/**
@@ -586,9 +603,10 @@
* Try to process name as a definition, or as an URL if not found.
* @param name Name to process.
* @return appropriate TagHandler
- * @roseuid 3AB4D8DC002D
+ * @throws JspException InstantiationException Can't create requested controller
*/
public TagHandler processAsDefinitionOrURL( String name )
+ throws JspException
{
try
{
@@ -625,7 +643,7 @@
return processDefinitionName( (String)value.getValue() );
}
//else if( value instanceof PathAttribute )
- return new InsertHandler( (String)value.getValue(), role );
+ return new InsertHandler( (String)value.getValue(), role, getController() );
}
/////////////////////////////////////////////////////////////////////////////
@@ -662,15 +680,17 @@
protected ComponentContext currentContext;
protected ComponentContext subCompContext;
protected String role;
+ protected Controller controller;
/**
* Constructor.
* Create insert handler using Component definition.
*/
- public InsertHandler( Map attributes, String page, String role )
+ public InsertHandler( Map attributes, String page, String role, Controller
controller )
{
this.page = page;
this.role = role;
+ this.controller = controller;
subCompContext = new ComponentContext( attributes );
}
@@ -678,10 +698,11 @@
* Constructor.
* Create insert handler to insert page at specified location.
*/
- public InsertHandler( String page, String role )
+ public InsertHandler( String page, String role, Controller controller )
{
this.page = page;
this.role = role;
+ this.controller = controller;
subCompContext = new ComponentContext();
}
@@ -727,6 +748,9 @@
// set new context for included component.
pageContext.setAttribute( ComponentConstants.COMPONENT_CONTEXT,
subCompContext, pageContext.REQUEST_SCOPE);
+ // Call controller if any
+ if( controller != null )
+ controller.perform(subCompContext,
(HttpServletRequest)pageContext.getRequest(),
(HttpServletResponse)pageContext.getResponse(), pageContext.getServletContext());
// include requested component.
if( flush )
pageContext.getOut().flush();
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutListTag.java
Index: PutListTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutListTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PutListTag.java 2001/08/01 14:36:41 1.1
+++ PutListTag.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutListTag.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutListTag.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutListTagParent.java
Index: PutListTagParent.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutListTagParent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PutListTagParent.java 2001/08/01 14:36:41 1.1
+++ PutListTagParent.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutListTagParent.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutListTagParent.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutTag.java
Index: PutTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PutTag.java 2001/08/01 14:36:41 1.1
+++ PutTag.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutTag.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutTag.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutTagParent.java
Index: PutTagParent.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutTagParent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PutTagParent.java 2001/08/01 14:36:41 1.1
+++ PutTagParent.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutTagParent.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/PutTagParent.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/UseAttributeTag.java
Index: UseAttributeTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/UseAttributeTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UseAttributeTag.java 2001/08/01 14:36:41 1.1
+++ UseAttributeTag.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/UseAttributeTag.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/UseAttributeTag.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/UseAttributeTei.java
Index: UseAttributeTei.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/UseAttributeTei.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UseAttributeTei.java 2001/08/01 14:36:41 1.1
+++ UseAttributeTei.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/UseAttributeTei.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/UseAttributeTei.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ext/TextTag.java
Index: TextTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ext/TextTag.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TextTag.java 2001/08/01 14:36:41 1.1
+++ TextTag.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ext/TextTag.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/ext/TextTag.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
*
* ====================================================================
*
@@ -83,7 +83,7 @@
*
* @author Craig R. McClanahan
* @author Cedric Dumoulin
- * @version $Revision: 1.1 $ $Date: 2001/08/01 14:36:41 $
+ * @version $Revision: 1.2 $ $Date: 2001/12/27 17:35:37 $
*/
public class TextTag extends BaseFieldTag {
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/util/TagUtils.java
Index: TagUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/util/TagUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TagUtils.java 2001/08/01 14:36:41 1.1
+++ TagUtils.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/util/TagUtils.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/taglib/tiles/util/TagUtils.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.4 +34 -22
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ActionComponentServlet.java
Index: ActionComponentServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ActionComponentServlet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ActionComponentServlet.java 2001/09/28 17:05:23 1.3
+++ ActionComponentServlet.java 2001/12/27 17:35:37 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ActionComponentServlet.java,v
1.3 2001/09/28 17:05:23 cedric Exp $
- * $Revision: 1.3 $
- * $Date: 2001/09/28 17:05:23 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ActionComponentServlet.java,v
1.4 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
@@ -189,33 +189,41 @@
/**
* Process forward.
- *
- * 'forward' contains screen name. This later is used to find appropriate
mapping.
- * Then, request is forwarded to this mapping.
+ * Forward to requested uri.
+ * Uri can be a valid uri, or a definition name. If definition name, search
+ * definition and use definition path.
+ * @param uri Uri or Definition name to forward
+ * @param request Current page request
+ * @param response Current page response
*/
protected void processForward(String uri, HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
// Do we do a forward (original behavior) or an include ?
boolean doInclude = false;
+ // Controller associated to a definition, if any
+ Controller controller = null;
+ ComponentContext tileContext = null;
try
{
-
// Get current tile context if any.
// If context exist, we will do an include
- ComponentContext tileContext = ComponentContext.getContext( request );
+ tileContext = ComponentContext.getContext( request );
doInclude = (tileContext!=null );
ComponentDefinition definition;
- // Process tiles definition names only if a definition factory exist.
+ // Process tiles definition names only if a definition factory exist,
+ // and definition found.
if( definitionsFactory != null )
{ // Get definition of tiles/component corresponding to uri.
definition = definitionsFactory.getDefinition(uri, request,
getServletContext());
if( definition != null )
{ // We have a definition.
// We use it to complete missing attribute in context.
+ // We also get uri, controller.
uri = definition.getPath();
+ controller = definition.getOrCreateController();
if( tileContext == null )
{
tileContext = new ComponentContext( definition.getAttributes() );
@@ -225,13 +233,17 @@
tileContext.addMissing( definition.getAttributes() );
} // end if
} // end if
- // Check if there is a definition set in jsp context.
+
+ // Process definition set in Action, if any.
definition = DefinitionsUtil.getActionDefinition(request);
if( definition != null )
{ // We have a definition.
// We use it to complete missing attribute in context.
- // We also overload uri.
- uri = definition.getPath();
+ // We also overload uri and controller if set in definition.
+ if(definition.getPath()!=null)
+ uri = definition.getPath();
+ if(definition.getOrCreateController()!=null)
+ controller = definition.getOrCreateController();
if( tileContext == null )
{
tileContext = new ComponentContext( definition.getAttributes() );
@@ -242,12 +254,22 @@
} // end if
}
+ catch( java.lang.InstantiationException ex )
+ {
+ throw new ServletException( "Can't create associated controller", ex );
+ }
catch( DefinitionsFactoryException ex )
{
throw new ServletException( ex );
}
+
+ // Execute controller associated to definition, if any.
+ if(controller !=null)
+ {
+ controller.perform( tileContext, request, response, getServletContext());
+ } // end if
- // Do dispatching
+ // Do dispatching : search dispatcher, then dispatch
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
if (rd == null)
{ // error
@@ -256,23 +278,13 @@
return;
} // end if
- // If request comes from a previous component, do an include.
- // This allows to insert an action in a components.
+ // If request comes from a previous Tile, do an include.
+ // This allows to insert an action in a Tile.
if( doInclude )
rd.include(request, response);
else
rd.forward(request, response); // original behavior
-/*
- try
- { // original behavior
- rd.forward(request, response);
- }
- catch( IllegalStateException ex )
- { // Response already committed : do include
- rd.include( request, response);
- }
-*/
}
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/AttributeDefinition.java
Index: AttributeDefinition.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/AttributeDefinition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AttributeDefinition.java 2001/08/01 14:36:41 1.1
+++ AttributeDefinition.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/AttributeDefinition.java,v
1.1 2001/08/01 14:36:41 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:41 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/AttributeDefinition.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.4 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentContext.java
Index: ComponentContext.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ComponentContext.java 2001/11/02 16:50:05 1.3
+++ ComponentContext.java 2001/12/27 17:35:37 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentContext.java,v
1.3 2001/11/02 16:50:05 cedric Exp $
- * $Revision: 1.3 $
- * $Date: 2001/11/02 16:50:05 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentContext.java,v
1.4 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +270 -1
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentDefinition.java
Index: ComponentDefinition.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentDefinition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ComponentDefinition.java 2001/08/01 14:36:42 1.1
+++ ComponentDefinition.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentDefinition.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentDefinition.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
@@ -9,10 +9,14 @@
package org.apache.struts.tiles;
+import org.apache.struts.tiles.Controller;
+import org.apache.struts.action.Action;
+
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.io.Serializable;
+import org.apache.struts.taglib.tiles.DefinitionTagSupport;
/**
* Definition of a template / component attributes.
@@ -21,8 +25,11 @@
*/
public class ComponentDefinition implements Serializable
{
+ /** Debug flag */
+ public static final boolean debug = false;
+
/**
- * Instance name
+ * Definition name
*/
protected String name;
@@ -38,6 +45,25 @@
/** role associated to definition */
protected String role;
+ /** Associated Controller URL or classname, if defined */
+ protected String controller;
+ /** Associated Controller typename, if controllerName defined.
+ * Can be CONTROLLER, ACTION or URL, or null */
+ protected String controllerType;
+
+ /** Controller name type */
+ public static final String URL = "url";
+ /** Controller name type */
+ public static final String CONTROLLER = "controller";
+ /** Controller name type */
+ public static final String ACTION = "action";
+
+ /**
+ * Controller associated to Definition.
+ * Lazy creation : only on first request
+ */
+ private Controller controllerInstance;
+
/**
* @return void
* Sets the value of the attributes property.
@@ -70,8 +96,31 @@
this.name = definition.getName();
this.path = definition.getPath();
this.role = definition.getRole();
+ this.controllerInstance = definition.getControllerInstance();
+ this.controller = definition.getController();
+ this.controllerType = definition.getControllerType();
}
+ /**
+ * Constructor.
+ * Create a new definition initialized from a RawDefinition.
+ * Raw definitions are used to read definition from a data source (xml file, db,
...).
+ * A RawDefinition mainly contains properties of type String, while Definition
+ * contains more complex type (ex : Controller).
+ * Do a shallow copy : attributes are shared between objects, but not the Map
+ * containing attributes.
+ * OO Design issues : Actually RawDefinition (XmlDefinition) extends
ComponentDefinition.
+ * This must not be the case. I have do it because I am lazy.
+ * @throw InstantiationException if an error occur while instanciating
Controller :
+ * (classname can't be instanciated, Illegal access with instanciated class,
+ * Error while instanciating class, classname can't be instanciated.
+ */
+ public ComponentDefinition( org.apache.struts.tiles.xmlDefinition.XmlDefinition
definition )
+ {
+ this((ComponentDefinition)definition);
+ }
+
+
/**
* Constructor.
*/
@@ -104,6 +153,27 @@
*
* @return the current value of the path property
*/
+ public String getPage()
+ {
+ return path;
+ }
+
+ /**
+ * Sets the value of the path property.
+ *
+ * @param aPath the new value of the path property
+ * @return void
+ */
+ public void setPage(String page)
+ {
+ path = page;
+ }
+
+ /**
+ * Access method for the path property.
+ *
+ * @return the current value of the path property
+ */
public String getPath()
{
return path;
@@ -292,7 +362,206 @@
return "{name="+ name +
", path="+ path +
", role="+ role +
+ ", controller="+ controller +
+ ", controllerType="+ controllerType +
+ ", controllerInstance="+ controllerInstance +
", attributes=" + attributes + "}\n";
}
+
+ /**
+ * Get associated controller type.
+ * Type denote a fully qualified classname.
+ */
+ public String getControllerType()
+ {
+ return controllerType;
+ }
+
+ /**
+ * Set associated controller type.
+ * Type denote a fully qualified classname.
+ * @param controllerType Typeof associated controller
+ */
+ public void setControllerType(String controllerType)
+ {
+ this.controllerType = controllerType;
+ }
+
+ /**
+ * Set associated controller name as an url, and controller
+ * type as "url".
+ * Name must be an url (not checked).
+ * Convenience method.
+ * @param controller Controller url
+ */
+ public void setControllerUrl(String controller)
+ {
+ setController( controller);
+ setControllerType( "url" );
+ }
+
+ /**
+ * Set associated controller name as a classtype, and controller
+ * type as "classname".
+ * Name denote a fully qualified classname
+ * Convenience method.
+ * @param controller Controller classname.
+ */
+ public void setControllerClass(String controller)
+ {
+ setController( controller);
+ setControllerType( "classname" );
+ }
+
+ /**
+ * Get associated controller local URL.
+ * URL should be local to webcontainer in order to allow request context followup.
+ * URL comes as a string.
+ */
+ public String getController()
+ {
+ return controller;
+ }
+
+ /**
+ * Set associated controller URL.
+ * URL should be local to webcontainer in order to allow request context followup.
+ * URL is specified as a string.
+ * @param url Url called locally
+ */
+ public void setController(String name)
+ {
+ this.controller = name;
+ }
+
+ /**
+ * Get controller instance.
+ * @return controller instance.
+ */
+ public Controller getControllerInstance()
+ {
+ return controllerInstance;
+ }
+
+ /**
+ * Get or create controller.
+ * Get controller, create it if necessary.
+ * @return controller if controller or controllerType is set, null otherwise.
+ * @throw InstantiationException if an error occur while instanciating
Controller :
+ * (classname can't be instanciated, Illegal access with instanciated class,
+ * Error while instanciating class, classname can't be instanciated.
+ */
+ public Controller getOrCreateController()
+ throws InstantiationException
+ {
+ if( controllerInstance != null )
+ return controllerInstance;
+
+ // Do we define a controller ?
+ if( controller == null && controllerType == null )
+ return null;
+
+ // check parameters
+ if( controllerType != null && controller == null )
+ throw new InstantiationException( "Controller name should be defined if
controllerType is set" );
+
+ controllerInstance = createController( controller, controllerType );
+
+ return controllerInstance;
+ }
+
+ /**
+ * Set controller.
+ */
+ public void setControllerInstance(Controller controller)
+ {
+ this.controllerInstance = controller;
+ }
+
+ /**
+ * Create a new instance of controller named in parameter.
+ * If controllerType is specified, create controller accordingly.
+ * Otherwise, if name denote a classname, create an instance of it. If class is
+ * subclass of org.apache.struts.action.Action, wrap controller
+ * appropriately.
+ * Otherwise, consider name as an url.
+ * @param name Controller name (classname, url, ...)
+ * @param controllerType Expected Controller type
+ * @return org.apache.struts.tiles.Controller
+ * @throw InstantiationException if an error occur while instanciating
Controller :
+ * (classname can't be instanciated, Illegal access with instanciated class,
+ * Error while instanciating class, classname can't be instanciated.
+ */
+ static public Controller createController(String name, String controllerType)
+ throws InstantiationException
+ {
+ if(debug)
+ System.out.println( "Create controller name="+ name+", type=" + controllerType
);
+ Controller controller = null;
+
+ if( controllerType == null )
+ { // first try as a classname
+ try {
+ return createControllerFromClassname(name);
+ }
+ catch( InstantiationException ex )
+ { // ok, try something else
+ controller = new UrlController( name );
+ }
+ }
+ else if( "url".equalsIgnoreCase( controllerType ) )
+ controller = new UrlController( name );
+ else if( "classname".equalsIgnoreCase( controllerType ) )
+ controller = createControllerFromClassname( name );
+
+ return controller;
+ }
+
+
+ /**
+ * Create a controller from specified classname
+ * @param classname Controller classname.
+ * @param controllerType Expected Controller type
+ * @return org.apache.struts.tiles.Controller
+ * @throw InstantiationException if an error occur while instanciating
Controller :
+ * (classname can't be instanciated, Illegal access with instanciated class,
+ * Error while instanciating class, classname can't be instanciated.
+ */
+ static public Controller createControllerFromClassname(String classname)
+ throws InstantiationException
+ {
+ try
+ {
+ Class requestedClass = Class.forName(classname);
+ Object instance = requestedClass.newInstance();
+ /*
+ if( instance instanceof org.apache.struts.action.Action )
+ { // wrap strutsinstance
+ instance = new ActionController( (Action)instance );
+ } // end if
+ */
+ if(debug)
+ System.out.println( "Controller created : " + instance );
+ return (Controller)instance;
+ }
+ catch( java.lang.ClassNotFoundException ex)
+ {
+ throw new InstantiationException( "Error - Class not found :" +
ex.getMessage() );
+ }
+ catch( java.lang.IllegalAccessException ex)
+ {
+ throw new InstantiationException( "Error - Illegal class access :" +
ex.getMessage() );
+ }
+ catch( java.lang.InstantiationException ex)
+ {
+ throw ex;
+ }
+ catch( java.lang.ClassCastException ex)
+ {
+ throw new InstantiationException( "Controller of class '" + classname
+ + "' should implements 'Controller' or extends 'Action'" );
+ }
+ }
+
}
1.3 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentDefinitionsFactory.java
Index: ComponentDefinitionsFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentDefinitionsFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ComponentDefinitionsFactory.java 2001/09/10 13:01:30 1.2
+++ ComponentDefinitionsFactory.java 2001/12/27 17:35:37 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentDefinitionsFactory.java,v
1.2 2001/09/10 13:01:30 cedric Exp $
- * $Revision: 1.2 $
- * $Date: 2001/09/10 13:01:30 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/ComponentDefinitionsFactory.java,v
1.3 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionAttribute.java
Index: DefinitionAttribute.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionAttribute.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefinitionAttribute.java 2001/08/01 14:36:42 1.1
+++ DefinitionAttribute.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionAttribute.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionAttribute.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionNameAttribute.java
Index: DefinitionNameAttribute.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionNameAttribute.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefinitionNameAttribute.java 2001/08/01 14:36:42 1.1
+++ DefinitionNameAttribute.java 2001/12/27 17:35:37 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionNameAttribute.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionNameAttribute.java,v
1.2 2001/12/27 17:35:37 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:37 $
* $Author: cedric $
*
*/
1.2 +1 -1
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionsFactoryException.java
Index: DefinitionsFactoryException.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionsFactoryException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefinitionsFactoryException.java 2001/08/01 14:36:42 1.1
+++ DefinitionsFactoryException.java 2001/12/27 17:35:38 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionsFactoryException.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionsFactoryException.java,v
1.2 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
@@ -12,7 +12,7 @@
* Exception throw when an error occur while factory try to
* create a new instance mapper.
*/
-public class DefinitionsFactoryException extends Exception
+public class DefinitionsFactoryException extends TilesException
{
/**
* Constructor.
1.3 +13 -104
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionsUtil.java
Index: DefinitionsUtil.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionsUtil.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefinitionsUtil.java 2001/09/10 12:51:31 1.2
+++ DefinitionsUtil.java 2001/12/27 17:35:38 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionsUtil.java,v
1.2 2001/09/10 12:51:31 cedric Exp $
- * $Revision: 1.2 $
- * $Date: 2001/09/10 12:51:31 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DefinitionsUtil.java,v
1.3 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
@@ -22,7 +22,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
-//import org.apache.struts.tiles.xmlDefinition.XmlConfigInstancesFactory;
+import org.apache.struts.tiles.definition.ReloadableDefinitionsFactory;
import org.apache.struts.tiles.xmlDefinition.I18nFactorySet;
import org.apache.struts.taglib.tiles.ComponentConstants;
@@ -109,41 +109,13 @@
* @param properties Map of name/property passed to newly created factory.
* @return newly created factory.
* @throw DefinitionsFactoryException If an error occur while initializing factory
+ * @deprecated Use createDefinitionsFactory(ServletContext servletContext, Map
properties)
*/
public static ComponentDefinitionsFactory createDefinitionsFactory(ServletContext
servletContext, Map properties, String classname)
throws DefinitionsFactoryException
{
- if( classname == null )
- return createDefinitionsFactory( servletContext, properties );
-
- // Try to create from classname
- try
- {
- Class factoryClass = Class.forName(classname);
- ComponentDefinitionsFactory factory =
(ComponentDefinitionsFactory)factoryClass.newInstance();
- factory.initFactory( servletContext, properties);
- DefinitionsUtil.setDefinitionsFactory(factory, servletContext );
- return factory;
- }
- catch( ClassCastException ex )
- { // Bad classname
- throw new DefinitionsFactoryException( "Error - createDefinitionsFactory :
Factory class '"
- + classname +" must implements
'ComponentDefinitionsFactory'.", ex );
- }
- catch( ClassNotFoundException ex )
- { // Bad classname
- throw new DefinitionsFactoryException( "Error - createDefinitionsFactory : Bad
class name '"
- + classname +"'.", ex );
- }
- catch( InstantiationException ex )
- { // Bad constructor or error
- throw new DefinitionsFactoryException( ex );
- }
- catch( IllegalAccessException ex )
- { //
- throw new DefinitionsFactoryException( ex );
- }
-
+ properties.put( ReloadableDefinitionsFactory.DEFINITIONS_FACTORY_CLASSNAME,
classname );
+ return createDefinitionsFactory(servletContext, properties);
}
/**
@@ -157,9 +129,9 @@
public static ComponentDefinitionsFactory createDefinitionsFactory(ServletContext
servletContext, Map properties)
throws DefinitionsFactoryException
{
- ComponentDefinitionsFactory factory = new I18nFactorySet(servletContext,
properties); ;
- DefinitionsUtil.setDefinitionsFactory(factory, servletContext );
- return factory;
+ ComponentDefinitionsFactory factory = new
ReloadableDefinitionsFactory(servletContext, properties); ;
+ DefinitionsUtil.setDefinitionsFactory(factory, servletContext );
+ return factory;
}
/**
@@ -173,47 +145,18 @@
public static ComponentDefinitionsFactory createDefinitionsFactory(ServletContext
servletContext, ServletConfig servletConfig)
throws DefinitionsFactoryException
{
- initUserDebugLevel( servletConfig );
- String classname =
servletConfig.getInitParameter(DEFINITIONS_FACTORY_CLASSNAME);
- Map properties = new ServletPropertiesMap( servletConfig );
-
- return createDefinitionsFactory( servletContext, properties, classname);
+ initUserDebugLevel(servletConfig);
+ ComponentDefinitionsFactory factory = new
ReloadableDefinitionsFactory(servletContext, servletConfig); ;
+ DefinitionsUtil.setDefinitionsFactory(factory, servletContext );
+ return factory;
}
- /**
- * Create Definition factory.
- * @deprecated Use createDefinitionFactory instead.
- */
- public static ComponentDefinitionsFactory initDefinitionsFactory(ServletContext
servletContext, ServletConfig servletConfig)
- throws DefinitionsFactoryException
- {
- return createDefinitionsFactory( servletContext, servletConfig);
- }
-
- /**
- * Create Definition factory.
- * @param definitionName Name of definition to include.
- * @param pageContext Current page context.
- */
-/* public static void includeDefinition(String definitionName, PageContext
pageContext)
- throws DefinitionsFactoryException
- {
- // Search definition
- ComponentDefinition definition = getDefinition( definitionName, pageContext);
-
- ComponentContext context = new ComponentContext(definition);
- pageContext.getRequest().setAttribute( ComponentConstants.COMPONENT_CONTEXT,
context);
-
- pageContext.include( definition.getPath() );
- }
-*/
-
/**
* Set definition factory in appropriate servlet context.
* @param factory Factory to store.
* @param servletContext Servlet context that will hold factory.
*/
- static public void setDefinitionsFactory(ComponentDefinitionsFactory factory,
ServletContext servletContext)
+ static protected void setDefinitionsFactory(ComponentDefinitionsFactory factory,
ServletContext servletContext)
{
servletContext.setAttribute(DEFINITIONS_FACTORY, factory);
}
@@ -224,7 +167,7 @@
* @param factory Factory to store.
* @param pageContext Page context containing servlet context.
*/
- static public void setDefinitionsFactory(ComponentDefinitionsFactory factory,
PageContext pageContext)
+ static protected void setDefinitionsFactory(ComponentDefinitionsFactory factory,
PageContext pageContext)
{
setDefinitionsFactory( factory, pageContext.getServletContext() );
}
@@ -293,17 +236,6 @@
}
/**
- * Get ComponentContext defined for current Tile.
- * @return ComponentContext ComponentContext or null.
- *
- */
- static public ComponentContext getComponentContextOld(ServletRequest request)
- {
- return ComponentContext.getContext(request);
- }
-
-
- /**
* Get Definition stored in jsp context by an action.
* @return ComponentDefinition or null if not found.
*/
@@ -331,26 +263,3 @@
}
}
- /**
- * Inner class.
- * Wrapper for ServletContext init parameters.
- * Object of this class is an hashmap containing parameters and values
- * defined in the servlet config file (web.xml).
- */
- class ServletPropertiesMap extends HashMap {
- /**
- * Constructor.
- */
- ServletPropertiesMap( ServletConfig config )
- {
- // This implementation is very simple.
- // It is possible to avoid creation of a new structure, but this need
- // imply writing all Map interface.
- Enumeration enum = config.getInitParameterNames();
- while( enum.hasMoreElements() )
- {
- String key = (String)enum.nextElement();
- put( key, config.getInitParameter( key ) );
- }
- }
-} // end inner class
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DirectStringAttribute.java
Index: DirectStringAttribute.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DirectStringAttribute.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DirectStringAttribute.java 2001/08/01 14:36:42 1.1
+++ DirectStringAttribute.java 2001/12/27 17:35:38 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DirectStringAttribute.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/DirectStringAttribute.java,v
1.2 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/FactoryNotFoundException.java
Index: FactoryNotFoundException.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/FactoryNotFoundException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FactoryNotFoundException.java 2001/08/01 14:36:42 1.1
+++ FactoryNotFoundException.java 2001/12/27 17:35:38 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/FactoryNotFoundException.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/FactoryNotFoundException.java,v
1.2 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/NoSuchDefinitionException.java
Index: NoSuchDefinitionException.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/NoSuchDefinitionException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NoSuchDefinitionException.java 2001/08/01 14:36:42 1.1
+++ NoSuchDefinitionException.java 2001/12/27 17:35:38 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/NoSuchDefinitionException.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/NoSuchDefinitionException.java,v
1.2 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/PathAttribute.java
Index: PathAttribute.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/PathAttribute.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PathAttribute.java 2001/08/01 14:36:42 1.1
+++ PathAttribute.java 2001/12/27 17:35:38 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/PathAttribute.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/PathAttribute.java,v
1.2 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
1.2 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/UntyppedAttribute.java
Index: UntyppedAttribute.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/UntyppedAttribute.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UntyppedAttribute.java 2001/08/01 14:36:42 1.1
+++ UntyppedAttribute.java 2001/12/27 17:35:38 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/UntyppedAttribute.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/UntyppedAttribute.java,v
1.2 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
1.3 +37 -5
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/resources/tiles-config.dtd
Index: tiles-config.dtd
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/resources/tiles-config.dtd,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- tiles-config.dtd 2001/10/29 17:32:24 1.2
+++ tiles-config.dtd 2001/12/27 17:35:38 1.3
@@ -1,15 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- edited with XML Spy v3.5 NT (http://www.xmlspy.com) by () -->
-<!--DTD generated by XML Spy v3.5 NT (http://www.xmlspy.com)-->
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ DTD for the Tile Definition File, Version 1.0
+
+ To support validation of your configuration file, include the following
+ DOCTYPE element at the beginning (after the "xml" declaration):
+
+ <!DOCTYPE tiles-definitions PUBLIC
+ "-//Apache Software Foundation//DTD Tiles Configuration//EN"
+ "http://jakarta.apache.org/struts/dtds/tiles-config.dtd">
+
+ $Id: tiles-config.dtd,v 1.3 2001/12/27 17:35:38 cedric Exp $
+-->
<!ELEMENT component-definitions (definition+)>
<!ELEMENT tiles-definitions (definition+)>
<!ELEMENT definition (put*, putList*)>
<!ATTLIST definition
name CDATA #REQUIRED
+ page CDATA #IMPLIED
path CDATA #IMPLIED
extends CDATA #IMPLIED
role CDATA #IMPLIED
template CDATA #IMPLIED
+ controllerClass CDATA #IMPLIED
+ controllerUrl CDATA #IMPLIED
>
<!ELEMENT put (#PCDATA)>
<!ATTLIST put
@@ -19,11 +32,30 @@
content CDATA #IMPLIED
direct (true | false) #IMPLIED
>
-<!ELEMENT putList (add+)>
+<!ELEMENT putList ( (add* | item* | bean*)+) >
<!ATTLIST putList
name CDATA #REQUIRED
>
-<!ELEMENT add EMPTY>
+<!ELEMENT putListElements (add | item | bean)>
+
+<!ELEMENT add (#PCDATA)>
<!ATTLIST add
+ value CDATA #IMPLIED
+ type (string | page | template | definition) #IMPLIED
+ content CDATA #IMPLIED
+ direct (true | false) #IMPLIED
+>
+
+<!ELEMENT bean (#PCDATA)>
+<!ATTLIST bean
+ classtype CDATA #REQUIRED
+>
+
+<!ELEMENT item (#PCDATA)>
+<!ATTLIST item
value CDATA #REQUIRED
+ link CDATA #REQUIRED
+ classtype CDATA #IMPLIED
+ icon CDATA #IMPLIED
+ tooltip CDATA #IMPLIED
>
1.3 +3 -1
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/DefinitionsFactory.java
Index: DefinitionsFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/DefinitionsFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefinitionsFactory.java 2001/09/28 17:05:22 1.2
+++ DefinitionsFactory.java 2001/12/27 17:35:38 1.3
@@ -53,6 +53,8 @@
* Constructor.
* Create a factory initialized with definitions from XmlDefinitionsSet.
* @param xmlDefinitions resolved definition from XmlDefinitionSet.
+ * @throws DefinitionsFactoryException If an error occurs while creating a
definition.
+ * @throws NoSuchDefinitionException If an error occurs while resolving
inheritance
*/
public DefinitionsFactory(XmlDefinitionsSet xmlDefinitions)
throws NoSuchDefinitionException
@@ -67,7 +69,7 @@
while( i.hasNext() )
{
XmlDefinition xmlDefinition = (XmlDefinition)i.next();
- putDefinition( new ComponentDefinition( xmlDefinition) );
+ putDefinition( new ComponentDefinition( xmlDefinition) );
} // end loop
}
/**
1.3 +4 -3
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/I18nFactorySet.java
Index: I18nFactorySet.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/I18nFactorySet.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- I18nFactorySet.java 2001/09/28 17:05:22 1.2
+++ I18nFactorySet.java 2001/12/27 17:35:38 1.3
@@ -46,7 +46,7 @@
public static final String INSTANCES_CONFIG_PARAMETER_NAME = "instances-config";
/** Default name */
- public static final String DEFAULT_DEFINITIONS_FILE_NAME =
"/WEB-INF/componentDefinitions.xml";
+ //public static final String DEFAULT_DEFINITIONS_FILE_NAME =
"/WEB-INF/componentDefinitions.xml";
/** Config file parameter name */
public static final String DEFINITIONS_CONFIG_PARAMETER_NAME =
"definitions-config";
/** Config file parameter name */
@@ -231,10 +231,11 @@
XmlDefinitionsSet rootXmlConfig = parseXmlFiles( servletContext, "", null );
if( rootXmlConfig == null )
throw new FileNotFoundException();
- if(debug)
- System.out.println( rootXmlConfig );
rootXmlConfig.resolveInheritances();
+
+ if(debug)
+ System.out.println( rootXmlConfig );
DefinitionsFactory factory = new DefinitionsFactory( rootXmlConfig );
if( DefinitionsUtil.userDebugLevel > DefinitionsUtil.NO_DEBUG )
1.5 +0 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlAttribute.java
Index: XmlAttribute.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlAttribute.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XmlAttribute.java 2001/11/02 16:50:04 1.4
+++ XmlAttribute.java 2001/12/27 17:35:38 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlAttribute.java,v
1.4 2001/11/02 16:50:04 cedric Exp $
- * $Revision: 1.4 $
- * $Date: 2001/11/02 16:50:04 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlAttribute.java,v
1.5 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
1.4 +5 -5
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlDefinition.java
Index: XmlDefinition.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlDefinition.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XmlDefinition.java 2001/10/08 13:36:36 1.3
+++ XmlDefinition.java 2001/12/27 17:35:38 1.4
@@ -1,4 +1,3 @@
-//Source file:
D:\\tmp\\generated\\s1\\struts\\component\\xmlDefinition\\XmlDefinition.java
package org.apache.struts.tiles.xmlDefinition;
@@ -8,16 +7,17 @@
import java.util.Iterator;
/**
-A definition red from an XML definitions file.
-*/
+ *A definition red from an XML definitions file.
+ */
public class XmlDefinition extends ComponentDefinition
{
- /** Debug flag */
- static public final boolean debug = false;
/**
* Extends attribute value.
*/
private String inherit;
+
+ /** Debug flag */
+ static public final boolean debug = false;
/**
* Use for resolving inheritance.
1.2 +8 -0
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlListAttribute.java
Index: XmlListAttribute.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlListAttribute.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XmlListAttribute.java 2001/08/01 14:36:42 1.1
+++ XmlListAttribute.java 2001/12/27 17:35:38 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlListAttribute.java,v
1.1 2001/08/01 14:36:42 cedric Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/01 14:36:42 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlListAttribute.java,v
1.2 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/12/27 17:35:38 $
* $Author: cedric $
*
*/
@@ -59,6 +59,14 @@
* Add an element in list.
*/
public void add( Object value )
+ {
+ list.add( value );
+ }
+
+ /**
+ * Add an element in list.
+ */
+ public void addObject( Object value )
{
list.add( value );
}
1.4 +12 -2
jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlParser.java
Index: XmlParser.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/share/org/apache/struts/tiles/xmlDefinition/XmlParser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XmlParser.java 2001/10/29 17:32:24 1.3
+++ XmlParser.java 2001/12/27 17:35:38 1.4
@@ -178,6 +178,15 @@
digester.addSetNext( ADD_LIST_ELE_TAG, "add", putAttributeHandlerClass);
digester.addSetProperties( ADD_LIST_ELE_TAG);
digester.addCallMethod( ADD_LIST_ELE_TAG, "setBody", 0);
+ // list elements rules
+ // We use Attribute class to avoid rewriting a new class.
+ // Name part can't be used in listElement attribute.
+ //String ADD_WILDCARD = LIST_TAG + "/addItem";
+ // non String ADD_WILDCARD = LIST_TAG + "/addx*";
+ String ADD_WILDCARD = "*/item";
+ digester.addObjectCreate( ADD_WILDCARD, putAttributeHandlerClass,
"classtype");
+ digester.addSetNext( ADD_WILDCARD, "add", "java.lang.Object");
+ digester.addSetProperties( ADD_WILDCARD);
}
/**
@@ -268,7 +277,8 @@
*/
public static void main(String[] args)
{
- String filename =
"E:/programs/jakarta-tomcat/webapps/wtiles-struts/WEB-INF/tilesDefinitions.xml";
+ String filename =
"E:/programs/jakarta-tomcat/webapps/wtiles-struts/WEB-INF/tiles-examples-defs.xml";
+ //String filename =
"E:/programs/jakarta-tomcat/webapps/wtiles-struts/WEB-INF/tilesDefinitions.xml";
//String filename =
"E:/programs/jakarta-tomcat/webapps/wtiles-channel/WEB-INF/componentDefinitions.xml";
//String filename2 =
"E:/programs/jakarta-tomcat/webapps/wtiles-tutorial/WEB-INF/componentDefinitions.xml";
@@ -299,7 +309,7 @@
{
XmlParser parser = new XmlParser();
parser.setValidating(true);
- parser.setDetailLevel(2);
+ parser.setDetailLevel(0);
XmlDefinitionsSet definitions = new XmlDefinitionsSet();
System.out.println( " Parse file" );
parser.parse( input, definitions);
1.2 +6 -11
jakarta-struts/contrib/tiles/src/tutorial/org/apache/struts/example/tiles/InitServlet.java
Index: InitServlet.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/tutorial/org/apache/struts/example/tiles/InitServlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InitServlet.java 2001/08/01 14:36:42 1.1
+++ InitServlet.java 2001/12/27 17:35:38 1.2
@@ -2,29 +2,23 @@
import org.apache.struts.tiles.DefinitionsUtil;
import org.apache.struts.tiles.DefinitionsFactoryException;
-import org.apache.struts.taglib.tiles.ComponentConstants;
import javax.servlet.ServletException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet;
-import java.util.Enumeration;
/**
- * <strong>InitServlet</strong> initializes webshop application.
- *
+ * Example of servlet initializing Tiles.
+ * This servlet can be declared in web.xml, as well as all initialization
+ * parameters available with the specified factory.
+ * This servlet is intended to be used in application using Tiles without Struts.
* @author Cedric Dumoulin
*/
public class InitServlet extends HttpServlet
{
- public static final String DEFAULT_INSTANCES_FILE_NAME =
"/WEB-INF/templateInstances.xml";
-
- public InitServlet()
- {
- }
-
/**
* Initialize this servlet
*
@@ -34,11 +28,12 @@
{
log( "Start initialization");
System.out.println( "Start initialization" );
+ super.init();
// init component instances
try
{
- DefinitionsUtil.initDefinitionsFactory( getServletContext(),
getServletConfig() );
+ DefinitionsUtil.createDefinitionsFactory( getServletContext(),
getServletConfig() );
log( "initialized");
}
catch( DefinitionsFactoryException ex )
1.2 +0 -0
jakarta-struts/contrib/tiles/src/tutorial/org/apache/struts/example/tiles/invoice/EditInvoiceAction.java
Index: EditInvoiceAction.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/tutorial/org/apache/struts/example/tiles/invoice/EditInvoiceAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EditInvoiceAction.java 2001/08/01 14:36:43 1.1
+++ EditInvoiceAction.java 2001/12/27 17:35:38 1.2
@@ -28,7 +28,7 @@
* <code>SubscriptionForm</code> from the currently specified subscription.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2001/08/01 14:36:43 $
+ * @version $Revision: 1.2 $ $Date: 2001/12/27 17:35:38 $
*/
public final class EditInvoiceAction extends Action {
1.3 +0 -0
jakarta-struts/contrib/tiles/src/tutorial/org/apache/struts/example/tiles/rssChannel/Channels.java
Index: Channels.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/tiles/src/tutorial/org/apache/struts/example/tiles/rssChannel/Channels.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Channels.java 2001/11/02 16:50:05 1.2
+++ Channels.java 2001/12/27 17:35:38 1.3
@@ -31,7 +31,7 @@
* @expects path={uri} on command line or as parameter property to ActionMapping.
* @expects an input page or error forwarding if exception digesting RSS
* @author Ted Husted
- * @version $Revision: 1.2 $ $Date: 2001/11/02 16:50:05 $
+ * @version $Revision: 1.3 $ $Date: 2001/12/27 17:35:38 $
*/
public final class Channels extends Action {
@@ -153,9 +153,9 @@
/*
- * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/tutorial/org/apache/struts/example/tiles/rssChannel/Channels.java,v
1.2 2001/11/02 16:50:05 cedric Exp $
- * $Revision: 1.2 $
- * $Date: 2001/11/02 16:50:05 $
+ * $Header:
/home/cvs/jakarta-struts/contrib/tiles/src/tutorial/org/apache/struts/example/tiles/rssChannel/Channels.java,v
1.3 2001/12/27 17:35:38 cedric Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/27 17:35:38 $
*
* ====================================================================
*
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>