mpo         2003/12/29 07:43:58

  Modified:    src/blocks/woody/java/org/apache/cocoon/woody/generation
                        WoodyGenerator.java
               src/blocks/woody/samples/resources woody-field-styling.xsl
  Log:
  Lining up more features between Woody's Generator and Transformer.
  Introducing a wi:form-generated wrapper similar to the wi:form-template.
  PR:
  Obtained from:
  Submitted by: 
  Reviewed by:  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.6       +11 -4     
cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/generation/WoodyGenerator.java
  
  Index: WoodyGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/woody/java/org/apache/cocoon/woody/generation/WoodyGenerator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WoodyGenerator.java       23 Dec 2003 08:46:17 -0000      1.5
  +++ WoodyGenerator.java       29 Dec 2003 15:43:58 -0000      1.6
  @@ -61,6 +61,7 @@
   import org.apache.cocoon.woody.Constants;
   import org.apache.cocoon.woody.formmodel.Form;
   import org.apache.cocoon.woody.transformation.WoodyPipelineConfig;
  +import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
   /**
  @@ -79,25 +80,31 @@
    */
   public class WoodyGenerator extends AbstractGenerator {
       
  -    protected Form form;
  +    protected WoodyPipelineConfig config;
  +    private static final String FORM_GENERATED_EL = "form-generated";
   
       public void setup(SourceResolver resolver, Map objectModel, String src, 
Parameters par)
               throws ProcessingException, SAXException, IOException {
           super.setup(resolver, objectModel, src, par);
           
  -        WoodyPipelineConfig config = 
WoodyPipelineConfig.createConfig(objectModel, parameters);
  -        form = config.findForm();     
  +        this.config = WoodyPipelineConfig.createConfig(objectModel, 
parameters);            
       }
   
       public void recycle() {
           super.recycle();
  -        form = null;
  +        this.config = null;
       }
   
       public void generate() throws IOException, SAXException, 
ProcessingException {
           contentHandler.startDocument();
           contentHandler.startPrefixMapping(Constants.WI_PREFIX, 
Constants.WI_NS);
  +        Attributes formAtts = this.config.getFormAttributes();
  +        
  +        contentHandler.startElement(Constants.WI_NS, FORM_GENERATED_EL, 
Constants.WI_PREFIX_COLON +FORM_GENERATED_EL, formAtts);
  +        Form form = config.findForm(); 
           form.generateSaxFragment(contentHandler, Locale.US);
  +        contentHandler.endElement(Constants.WI_NS, FORM_GENERATED_EL, 
Constants.WI_PREFIX_COLON +FORM_GENERATED_EL);
  +        
           contentHandler.endPrefixMapping(Constants.WI_PREFIX);
           contentHandler.endDocument();
       }
  
  
  
  1.28      +7 -2      
cocoon-2.1/src/blocks/woody/samples/resources/woody-field-styling.xsl
  
  Index: woody-field-styling.xsl
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/woody/samples/resources/woody-field-styling.xsl,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- woody-field-styling.xsl   23 Dec 2003 18:05:19 -0000      1.27
  +++ woody-field-styling.xsl   29 Dec 2003 15:43:58 -0000      1.28
  @@ -393,15 +393,20 @@
     </xsl:template>
   
     <!--+
  -      | wi:form-template
  +      | wi:form-template|wi:form-generated 
         +-->
  -  <xsl:template match="wi:form-template">
  +  <xsl:template match="wi:form-template|wi:form-generated">
       <form>
         <xsl:copy-of select="@*"/>
         <xsl:attribute name="onsubmit">woody_onsubmit(); <xsl:value-of 
select="@onsubmit"/></xsl:attribute>
         <!-- hidden field to store the submit id -->
         <input type="hidden" name="woody_submit_id"/>
         <xsl:apply-templates/>
  +      
  +      <!-- TODO: consider putting this in the xml stream from the generator? 
-->
  +      <xsl:if test="local-name(.) = 'form-generated' ">
  +        <input type="submit" />
  +      </xsl:if>
       </form>
     </xsl:template>
   
  
  
  

Reply via email to