vgritsenko 2002/10/21 20:21:42 Modified: . Tag: cocoon_2_0_3_branch changes.xml src/java/org/apache/cocoon/generation Tag: cocoon_2_0_3_branch SessionAttributeGenerator.java Log: Src attribute can be used now with SessionAttributeGenerator to specify session attribute name. Old syntax preserved. Revision Changes Path No revision No revision 1.138.2.61 +5 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.138.2.60 retrieving revision 1.138.2.61 diff -u -r1.138.2.60 -r1.138.2.61 --- changes.xml 22 Oct 2002 02:21:59 -0000 1.138.2.60 +++ changes.xml 22 Oct 2002 03:21:41 -0000 1.138.2.61 @@ -40,6 +40,10 @@ <release version="@version@" date="@date@"> <action dev="VG" type="update"> + Src attribute can be used now with SessionAttributeGenerator to specify + session attribute name. Old syntax preserved. + </action> + <action dev="VG" type="update"> Local parameters in SessionStateAction still do override global parameters, but do NOT change global parameters. </action> No revision No revision 1.1.2.1 +16 -17 xml-cocoon2/src/java/org/apache/cocoon/generation/SessionAttributeGenerator.java Index: SessionAttributeGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/SessionAttributeGenerator.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- SessionAttributeGenerator.java 5 Mar 2002 15:45:11 -0000 1.1 +++ SessionAttributeGenerator.java 22 Oct 2002 03:21:42 -0000 1.1.2.1 @@ -70,24 +70,28 @@ import java.util.Map; /** - * Generates a document from a session attribute. The attribute may be a DOM node, an - * an <code>XMLizable</code>, or any other object, and is streamed using the same - * rules as for <xsp:expr> in XSPs (see {@link XSPObjectHelper}). + * Generates a document from a session attribute. The attribute may be a DOM + * node, an <code>XMLizable</code>, or any other object, and is streamed using + * the same rules as for <xsp:expr> in XSPs (see {@link XSPObjectHelper}). * <p> - * This generator has 2 parameters : + * Name of the session attribute is specified using src attribute of the generate + * tag, or, if no src tag present, using attr-name parameter. + * <p> + * This generator has 2 parameters: * <ul> - * <li><code>attr-name</code> : the session attribute name (mandatory). + * <li><code>attr-name</code> : the session attribute name (mandatory if no src + * attribute specified). * </li> - * <li><code>root-element</code> (optional) : the name of the root element of the produced - * document. This parameter is optional if the session attribute is a DOM or an - * <code>XMLizable</code>. + * <li><code>root-element</code> (optional) : the name of the root element of the + * produced document. This parameter is optional if the session attribute is + * a DOM or an <code>XMLizable</code>. * </li> * </ul> * <p> * Example usage : * <pre> * <map:generator name="session-attr" logger="sitemap.generator.session-attr" - * src="org.apache.cocoon.generation.ReadDOMSessionGenerator"/> + * src="org.apache.cocoon.generation.SessionAttributeGenerator"/> * ... * <map:generate type="session-attr"> * <map:parameter name="attr-name" value="myAttribute"/> @@ -101,8 +105,7 @@ * @author <a href="mailto:sylvain@;apache.org">Sylvain Wallez</a> * @version $Id$ */ - -public class SessionAttributeGenerator extends AbstractGenerator{ +public class SessionAttributeGenerator extends AbstractGenerator { public static final String ATTR_NAME = "attr-name"; public static final String ELEMENT_NAME = "root-element"; @@ -125,7 +128,7 @@ this.elementName = par.getParameter(ELEMENT_NAME, null); // Get the attribute name - String attrName = par.getParameter(ATTR_NAME, null); + String attrName = par.getParameter(ATTR_NAME, src); if (attrName == null) { String msg = "SessionAttributeGenerator needs an attribute name !"; getLogger().error(msg); @@ -141,13 +144,11 @@ // Controls if (this.attrObject == null) { - if (this.elementName == null) { // Can't generate nothing... String msg = "Session attribute '" + attrName + "' doesn't exist"; getLogger().error(msg); throw new ProcessingException(msg); - } else { if (getLogger().isDebugEnabled()) { getLogger().debug("Session attribute '" + attrName + @@ -155,9 +156,7 @@ "' element."); } } - } else { - // Need an element name for non-xml objects if (this.elementName == null && ! (this.attrObject instanceof XMLizable) &&
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]