cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2003-03-08 Thread sylvain
sylvain 2003/03/08 06:13:08

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  Fix an NPE occuring when the transformer is recycled without setup() having being 
called
  can occur when the pipeline is "abandoned" for some reason)
  
  Revision  ChangesPath
  1.20  +0 -2  
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- XMLFormTransformer.java   23 Feb 2003 19:21:22 -  1.19
  +++ XMLFormTransformer.java   8 Mar 2003 14:13:07 -   1.20
  @@ -340,10 +340,8 @@
   public void recycle() 
   {
 // init tracking parameters
  -  formStack.clear();
 formStack = null;
 cannonicalRef = null;
  -  refStack.clear();
 refStack = null;
 currentTagDepth = 0;
 repeatTagDepth = -1;
  
  
  


cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2003-02-23 Thread coliver
coliver 2003/02/23 11:21:22

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  'Updated to support using the Cocoon flow layer with XMLForm'
  
  Revision  ChangesPath
  1.19  +28 -2 
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- XMLFormTransformer.java   31 Jan 2003 22:51:57 -  1.18
  +++ XMLFormTransformer.java   23 Feb 2003 19:21:22 -  1.19
  @@ -69,7 +69,8 @@
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
  -
  +import org.apache.cocoon.components.flow.WebContinuation;
  +import org.apache.cocoon.environment.Environment;
   /**
* Transforms a document with XMLForm
* elements into a document in the same namespace,
  @@ -526,7 +527,32 @@
  startElementWithOptionalRefAndSimpleContent( uri, name, raw, attributes 
);
}
 else if (
  -TAG_SUBMIT.equals(name) ||
  +TAG_SUBMIT.equals(name) )
  +   {
  +   String continuation = attributes.getValue("continuation");
  +   if (continuation != null) {
  +   WebContinuation kont
  +   = (WebContinuation)((Environment)resolver).getAttribute("kont");
  +   if (kont != null) {
  +   String id;
  +   int level = 0;
  +   if (continuation.equals("back")) {
  +   level = 3;
  +   }
  +   id = kont.getContinuation(level).getId();
  +   AttributesImpl impl = new AttributesImpl(attributes);
  +   int index = impl.getIndex("id");
  +   if (index >= 0) {
  +   impl.setValue(index, id);
  +   } else {
  +   impl.addAttribute("", "id", "id", "", id);
  +   }
  +   attributes = impl;
  +   }
  +   } 
  +   super.startElement(uri, name, raw, attributes);
  +   }
  +  else if (
   TAG_CANCEL.equals(name) ||
   TAG_RESET.equals(name) ||
   TAG_ITEM.equals(name) 
  
  
  


cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2002-12-16 Thread ivelin
ivelin  2002/12/16 20:17:12

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  reorged imports
  
  Revision  ChangesPath
  1.17  +11 -11
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- XMLFormTransformer.java   5 Dec 2002 10:32:57 -   1.16
  +++ XMLFormTransformer.java   17 Dec 2002 04:17:12 -  1.17
  @@ -8,14 +8,14 @@
   
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
  -
  + 
1. Redistributions of  source code must  retain the above copyright  notice,
   this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.
  -
  + 
3. The end-user documentation included with the redistribution, if any, must
   include  the following  acknowledgment:  "This product includes  software
   developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  @@ -51,6 +51,14 @@
   
   package org.apache.cocoon.transformation;
   
  +import java.io.IOException;
  +import java.lang.reflect.Array;
  +import java.util.Collection;
  +import java.util.Iterator;
  +import java.util.Map;
  +import java.util.SortedSet;
  +import java.util.Stack;
  +
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.validation.Violation;
  @@ -62,14 +70,6 @@
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
   
  -import java.io.IOException;
  -import java.lang.reflect.Array;
  -import java.util.Collection;
  -import java.util.Iterator;
  -import java.util.Map;
  -import java.util.SortedSet;
  -import java.util.Stack;
  -
   /**
* Transforms a document with XMLForm
* elements into a document in the same namespace,
  @@ -427,7 +427,7 @@
// when a new itemset tag (used within select) is discovered
// start recording
// the itemset will be unrolled after the tag ends
  - // The difference with the repeat tag is that itemset if
  + // The difference with the repeat tag is that itemset is
// unrolled in multiple item tags.
else if ( TAG_ITEMSET.equals( name ) )
{
  
  
  

--
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail:  [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2002-10-27 Thread ivelin
ivelin  2002/10/27 00:25:19

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  Implement automated population with default values of unchecked check-boxes
  
  Revision  ChangesPath
  1.15  +94 -11
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- XMLFormTransformer.java   28 Sep 2002 19:42:05 -  1.14
  +++ XMLFormTransformer.java   27 Oct 2002 07:25:19 -  1.15
  @@ -122,6 +122,7 @@
  */
 public final static String TAG_FORM = "form";
 public final static String TAG_FORM_ATTR_ID = "id";
  +  public final static String TAG_FORM_ATTR_VIEW = "view";
   
 /**
  * the only tag which can be used outside of the form tag
  @@ -284,13 +285,21 @@
 public final static String TAG_COMMON_ATTR_REF = "ref";
   
   
  -  // the stack of nested forms. 
  -  // Although nested form tags are not allowed, it is possible 
  -  // that an output tag (with reference to another form) might be nested within a 
form tag.
  -  // In this case elements under the output tag (like caption) can reference 
properties
  -  // of the form of the enclosing output tag.
  +  /** the stack of nested forms. 
  +   * Although nested form tags are not allowed, it is possible 
  +   * that an output tag (with reference to another form) might be nested within a 
form tag.
  +   * In this case elements under the output tag (like caption) can reference 
properties
  +   * of the form of the enclosing output tag.
  +   */
   
 private Stack formStack = null;
  +  
  +  
  +  /**
  +   * Since form elements cannot be nested,
  +   * at most one possible value for the current form view is available.
  +   */
  +  private String currentFormView = null;
   
   
 private Object value_;
  @@ -517,7 +526,7 @@
   TAG_SELECTMANY.equals(name)
)
 {
  -startElementSimpleField( uri, name, raw, attributes );
  +startElementInputField( uri, name, raw, attributes );
 }
 else if (
   TAG_CAPTION.equals(name) ||
  @@ -543,7 +552,7 @@
   // since there are intricacies in 
   // handling the value sub-element
  isHiddenTag = true;
  -   startElementSimpleField( uri, name, raw, attributes );
  +   startElementInputField( uri, name, raw, attributes );
 }  
 else
 {
  @@ -571,6 +580,7 @@
 {
   String id = attributes.getValue(TAG_FORM_ATTR_ID);
   
  +// currently form elements cannot be nested
   if ( !formStack.isEmpty() )
   {
 String error = "Form nodes should not be nested ! Current form [id=" + 
formStack.peek() + "], nested form [id=" + String.valueOf(id) + "]";
  @@ -582,7 +592,7 @@
   
   // load up the referenced form
   Form currentForm =  Form.lookup( objectModel, id );
  -
  +
   // if the form wasn't found, we're in trouble
   if (currentForm == null)
   {
  @@ -591,7 +601,16 @@
 throw new IllegalStateException( error );
   };
   
  +
   formStack.push( currentForm );
  +
  +// memorize the current form view
  +// it will be needed when saving expected references to properties
  +currentFormView = attributes.getValue(TAG_FORM_ATTR_VIEW);
  +
  +// clear previously saved form state for this view
  +resetSavedModelReferences();
  +
 } // end of startElementForm
   
   
  @@ -711,6 +730,27 @@
 } // end of startElementOutput
   
   
  +  /**
  +   * 
  +   * Renders elements, which are used for input
  +   * 
  +   * TAG_TEXTBOX, TAG_TEXTAREA, TAG_PASSWORD, TAG_SELECTBOOLEAN, 
  +   * TAG_SELECTONE, TAG_SELECTMANY
  +   * 
  +   */
  +  protected void startElementInputField(String uri, String name, String raw, 
Attributes attributes )
  +throws SAXException
  +  {
  +startElementSimpleField( uri, name, raw, attributes );
  +
  +String ref = attributes.getValue(TAG_COMMON_ATTR_REF);
  +if (ref == null)
  +{
  +   throw new SAXException( name + " element should provide a '" + 
TAG_COMMON_ATTR_REF + "' attribute" );
  +}
  +saveModelReferenceForFormView( ref, name );
  +  }
  + 
   
 protected void startElementSimpleField(String uri, String name, String raw, 
Attributes attributes )
   throws SAXException
  @@ -727,10 +767,11 @@
throw new SAXException( name + " element should be either nested within a 
form tag or provide a form attribute" );
 }
   
  -  Form form = (Form) formStack.peek();
  +  Form 

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2002-09-28 Thread ivelin

ivelin  2002/09/28 12:42:05

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  added support for xforms HINT and HELP tags,
  by Simon Price <[EMAIL PROTECTED]>
  
  Revision  ChangesPath
  1.14  +10 -3 
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XMLFormTransformer.java   27 Sep 2002 02:51:52 -  1.13
  +++ XMLFormTransformer.java   28 Sep 2002 19:42:05 -  1.14
  @@ -11,7 +11,7 @@
   
1. Redistributions of  source code must  retain the above copyright  notice,
   this list of conditions and the following disclaimer.
  -
  + 
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.
  @@ -93,7 +93,8 @@
* @author Andrew Timberlake <[EMAIL PROTECTED]>, June 2002
* @author Michael Ratliff, [EMAIL PROTECTED] <[EMAIL PROTECTED]>, May 
2002
* @author Torsten Curdt <[EMAIL PROTECTED]>, March 2002
  -
  + * @author Simon Price <[EMAIL PROTECTED]>, September 2002
  + * 
*/
   
   public class XMLFormTransformer extends AbstractSAXTransformer
  @@ -167,6 +168,8 @@
 public final static String TAG_RESET = "reset";
   
 public final static String TAG_CAPTION = "caption";
  +  public final static String TAG_HINT = "hint";
  +  public final static String TAG_HELP = "help";
 public final static String TAG_TEXTBOX = "textbox";
 public final static String TAG_TEXTAREA = "textarea";
 public final static String TAG_PASSWORD = "password";
  @@ -518,6 +521,8 @@
 }
 else if (
   TAG_CAPTION.equals(name) ||
  +TAG_HINT.equals(name) ||
  +TAG_HELP.equals(name) ||
   TAG_VALUE.equals(name) 
  )
{
  @@ -922,7 +927,9 @@
   TAG_SELECTMANY.equals(name) ||
   TAG_SUBMIT.equals(name) ||
   TAG_CAPTION.equals( name ) ||
  -TAG_VALUE.equals( name )
  +TAG_VALUE.equals( name ) ||
  +TAG_HINT.equals( name ) ||
  +TAG_HELP.equals( name ) 
   )
   { 
 super.endElement(uri, name, raw);
  
  
  

--
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail:  [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2002-09-26 Thread ivelin

ivelin  2002/09/26 19:51:52

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  added xf:textarea
  
  Revision  ChangesPath
  1.13  +1 -0  
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XMLFormTransformer.java   21 Sep 2002 22:57:18 -  1.12
  +++ XMLFormTransformer.java   27 Sep 2002 02:51:52 -  1.13
  @@ -915,6 +915,7 @@
   }
   else if (
   TAG_TEXTBOX.equals(name) ||
  +TAG_TEXTAREA.equals(name) ||
   TAG_PASSWORD.equals(name) ||
   TAG_SELECTBOOLEAN.equals(name) ||
   TAG_SELECTONE.equals(name) ||
  
  
  

--
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail:  [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2002-09-08 Thread ivelin

ivelin  2002/09/08 16:02:57

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  update for itemset
  
  Revision  ChangesPath
  1.11  +157 -42   
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XMLFormTransformer.java   7 Aug 2002 10:52:13 -   1.10
  +++ XMLFormTransformer.java   8 Sep 2002 23:02:57 -   1.11
  @@ -173,6 +173,8 @@
 public final static String TAG_SELECTBOOLEAN = "selectBoolean";
 public final static String TAG_SELECTONE = "selectOne";
 public final static String TAG_SELECTMANY = "selectMany";
  +  public final static String TAG_ITEMSET = "itemset";
  +  public final static String TAG_ITEM = "item";
 public final static String TAG_VALUE = "value";
 public final static String TAG_HIDDEN = "hidden";
  
  @@ -375,10 +377,10 @@
   // just record the SAX event
   super.startElement( uri, name, raw, attributes);
 }
  -   // when a new repeat tag is discovered
  -   // start recording
  -  // the repeat will be unrolled after the repeat tag ends
  - else if (TAG_REPEAT.equals( name) )
  + // when a new repeat tag is discovered
  + // start recording
  + // the repeat will be unrolled after the repeat tag ends
  + else if (TAG_REPEAT.equals( name ))
{
  repeatTagDepth = currentTagDepth;
  isRecording = true;
  @@ -396,6 +398,27 @@
  // and start recording its content
  startRecording();
}
  + // when a new itemset tag (used within select) is discovered
  + // start recording
  + // the itemset will be unrolled after the tag ends
  + // The difference with the repeat tag is that itemset if
  + // unrolled in multiple item tags.
  + else if ( TAG_ITEMSET.equals( name ) )
  + {
  +   repeatTagDepth = currentTagDepth;
  +   isRecording = true;
  +
  +  // get the nodeset selector string
  +  nodeset = attributes.getValue(TAG_REPEAT_ATTR_NODESET);
  +
  +  if (nodeset == null)
  +  {
  + throw new SAXException( name + " element should provide a '" + 
TAG_REPEAT_ATTR_NODESET + "' attribute" );
  +  }
  +
  +   // start recording its content
  +   startRecording();
  + }
   else // if not a repeat tag
   {
   // if this tag has a "ref" attribute, then
  @@ -434,11 +457,6 @@
   {
 startElementOutput( uri, name, raw, attributes );
   } // end if TAG_OUTPUT
  -else if ( TAG_CAPTION.equals( name ) )
  -{
  -  super.startElement( uri, name, raw, attributes);
  -  this.ignoreHooksCount = 0;
  -}
   else if (TAG_INSERTVIOLATIONS.equals(name))
 {
   startElementViolations( uri, name, raw, attributes );
  @@ -466,15 +484,20 @@
   TAG_TEXTAREA.equals(name) ||
   TAG_PASSWORD.equals(name) ||
   TAG_SELECTBOOLEAN.equals(name) ||
  -TAG_SELECTONE.equals(name))
  -  {
  -  startElementSimpleField( uri, name, raw, attributes, currentForm );
  -  }
  -  else if (TAG_SELECTMANY.equals(name))
  +TAG_SELECTONE.equals(name) ||
  +TAG_SELECTMANY.equals(name) 
  + )
 {
   startElementSimpleField( uri, name, raw, attributes, currentForm );
 }
 else if (
  +TAG_CAPTION.equals(name) ||
  +TAG_VALUE.equals(name) 
  +   )
  + {
  +   startElementWithOptionalRefAndSimpleContent( uri, name, raw, attributes, 
currentForm );
  + }
  +  else if (
   TAG_SUBMIT.equals(name) ||
   TAG_CANCEL.equals(name) ||
   TAG_RESET.equals(name) )
  @@ -486,8 +509,8 @@
   // raise the flag that we're within a hidden element
   // since there are intricacies in 
   // handling the value sub-element
  -   isHiddenTag = true;
  -   startElementSimpleField( uri, name, raw, attributes, 
currentForm );
  +   isHiddenTag = true;
  +   startElementSimpleField( uri, name, raw, attributes, 
currentForm );
 }  
 else
 {
  @@ -683,6 +706,39 @@
} // end of startElementSimpleField
   
   
  +  protected void startElementWithOptionalRefAndSimpleContent(String uri, String 
name, String raw, Attributes attributes, Form form)
  +throws SAXException

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2002-07-28 Thread ivelin

ivelin  2002/07/28 07:04:42

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  allowed violations to be used outside the form tag
  
  Revision  ChangesPath
  1.8   +38 -9 
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLFormTransformer.java   8 Jun 2002 17:57:38 -   1.7
  +++ XMLFormTransformer.java   28 Jul 2002 14:04:41 -  1.8
  @@ -406,7 +406,16 @@
   {
 // put on top of the ref stack the full ref
 // append the new ref to the last stack top if not referencing the root
  -  cannonicalRef = aref.startsWith ("/") ? aref : ( ((Entry) 
refStack.peek()).getValue() + "/" + aref );
  +  if ( !refStack.isEmpty() )
  +  {
  + // this is a nested reference 
  +   cannonicalRef = aref.startsWith ("/") ? aref : ( ((Entry) 
refStack.peek()).getValue() + "/" + aref );
  +  }
  +  else 
  +  {
  +// top level reference
  +cannonicalRef = aref;
  +  }
 Entry entry = new Entry( new Integer(currentTagDepth), cannonicalRef);
 refStack.push( entry );
   
  @@ -431,6 +440,11 @@
 super.startElement( uri, name, raw, attributes);
 this.ignoreHooksCount = 0;
   }
  +else if (TAG_INSERTVIOLATIONS.equals(name))
  +  {
  +startElementViolations( uri, name, raw, attributes );
  +  } // end if TAG_INSERTVIOLATIONS
  +  
   // if we're within a xf:hidden element
   // and a value sub-element has been provided 
   // in the markup, then it will be left
  @@ -439,20 +453,16 @@
   // attribute
   else if ( isHiddenTag && TAG_VALUE.equals( name ) )
   {
  - hasHiddenTagValue = true;
  -super.startElement( uri, name, raw, attributes);
  + hasHiddenTagValue = true;
  +  super.startElement( uri, name, raw, attributes);
   }

   // if the currentForm is still not available
   // then we can't process nested form tags
   else if (currentForm != null)
   {
  -  if (TAG_INSERTVIOLATIONS.equals(name))
  -  {
  -startElementViolations( uri, name, raw, attributes );
  -  } // end if TAG_INSERTVIOLATIONS
   
  -  else if (
  +  if (
   TAG_TEXTBOX.equals(name) ||
   TAG_TEXTAREA.equals(name) ||
   TAG_PASSWORD.equals(name) ||
  @@ -529,10 +539,29 @@
   
 protected void startElementViolations(String uri, String name, String raw, 
Attributes attributes) throws SAXException
 {
  -  SortedSet violations = currentForm.getViolationsAsSortedSet();
  +
  +  // we will either use the locally referenced form id
  +  // or the global id. At least one of the two must be available
  +  Form form = null;
  +  String formAttr = attributes.getValue( TAG_OUTPUT_ATTR_FORM );
  +  if (formAttr == null)
  +  {
  +if (currentForm == null)
  +{
  +  throw new SAXException( "When used outside of a form tag, the output tag 
requires an '" + TAG_OUTPUT_ATTR_FORM + "' attribute" );
  +}
  +form = currentForm;
  +  }
  +  else
  +  {
  +form = Form.lookup( objectModel, formAttr );
  +  }
  +
  +  SortedSet violations = form.getViolationsAsSortedSet();
   
 // if there are no violations, there is nothing to show
 if (violations == null)  return;
  +
   
 // if we're immediately under the form tag
 // and parent "ref" attribute is not available
  
  
  

--
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail:  [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2002-06-08 Thread ivelin

ivelin  2002/06/08 10:57:38

  Modified:src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  This patch will check to see if an xf:hidden element already has an
  xf:value child and will add the value from the model if not.
  
  by Andrew Timberlake
  
  Revision  ChangesPath
  1.7   +98 -30
xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java
  
  Index: XMLFormTransformer.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XMLFormTransformer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLFormTransformer.java   6 Jun 2002 14:43:41 -   1.6
  +++ XMLFormTransformer.java   8 Jun 2002 17:57:38 -   1.7
  @@ -89,12 +89,12 @@
* but with populated values for the XPath references
* to the form's model attributes
*
  - * The original code was built by Torsten Curdt as
  - * part of the Preceptor API
*
  - * @author Ivelin Ivanov <[EMAIL PROTECTED]>, May 2002
  - * @author Michael Ratliff, [EMAIL PROTECTED] <[EMAIL PROTECTED]>, May 
2002
  - * @author Torsten Curdt <[EMAIL PROTECTED]>, March 2002
  + * @author: Ivelin Ivanov <[EMAIL PROTECTED]>, June 2002
  + * @author: Andrew Timberlake <[EMAIL PROTECTED]>, June 2002
  + * @author: Michael Ratliff, [EMAIL PROTECTED] <[EMAIL PROTECTED]>, May 
2002
  + * @author: Torsten Curdt <[EMAIL PROTECTED]>, March 2002
  +
*/
   
   public class XMLFormTransformer extends AbstractSAXTransformer
  @@ -174,7 +174,9 @@
 public final static String TAG_SELECTBOOLEAN = "selectBoolean";
 public final static String TAG_SELECTONE = "selectOne";
 public final static String TAG_SELECTMANY = "selectMany";
  -
  +  public final static String TAG_VALUE = "value";
  +  public final static String TAG_HIDDEN = "hidden";
  +   
 /**
  * grouping tag
  *
  @@ -246,6 +248,19 @@
   
   
 /**
  +   * Flag to let us know if the transformer is working
  +   * on a hidden tag
  +   */
  +  private boolean isHiddenTag = false;
  +
  +  /**
  +   * Flag to let us know that the hidden element contains
  +   * a value child element.
  +   */
  +  private boolean hasHiddenTagValue = false;
  +
  +  
  +  /**
  * the ref value of the current field
  * used by the violations tag
  */
  @@ -416,6 +431,18 @@
 super.startElement( uri, name, raw, attributes);
 this.ignoreHooksCount = 0;
   }
  +// if we're within a xf:hidden element
  +// and a value sub-element has been provided 
  +// in the markup, then it will be left
  +// unchanged. Otherwise we will 
  +// render the value of the referenced model
  +// attribute
  +else if ( isHiddenTag && TAG_VALUE.equals( name ) )
  +{
  + hasHiddenTagValue = true;
  +super.startElement( uri, name, raw, attributes);
  +}
  + 
   // if the currentForm is still not available
   // then we can't process nested form tags
   else if (currentForm != null)
  @@ -445,6 +472,14 @@
 {
   super.startElement(uri, name, raw, attributes);
 }
  +  else if (TAG_HIDDEN.equals(name))
  +  {
  +// raise the flag that we're within a hidden element
  +// since there are intricacies in 
  +// handling the value sub-element
  +   isHiddenTag = true;
  +   startElementSimpleField( uri, name, raw, attributes, 
currentForm );
  +  }  
 else
 {
 getLogger().error("unknown element [" + String.valueOf(name) + "]");
  @@ -613,30 +648,48 @@
   
 getLogger().debug("Value of form [id=" + form.getId() + ", ref=" + 
String.valueOf(ref) + "] = [" + value_ + "]") ;
   
  -  // render the value subelement(s)
  -  if (value_ instanceof Collection)
  -  {
  -Iterator i=((Collection) value_).iterator();
  -while (i.hasNext())
  -{
  -  renderValueSubElement( i.next() );
  -}
  -  }
  -  else if ( value_ != null && value_.getClass().isArray () )
  -  {
  -int len = Array.getLength ( value_ );
  -for (int i = 0; i < len; i++ )
  -{
  -  renderValueSubElement( Array.get ( value_, i ) );
  -}
  -  }
  -  else
  -  {
  -renderValueSubElement( value_ );
  -  }
  -  } // end of startElementSimpleField
  -
  -
  +   // Only render value sub-elements
  +  // at this point
  +  // if this is not a xf:hidden element.
  +   if(! isHiddenTag) renderValueSubElements();
  + } // end of startElementSimpleField
  +
  +
  + /**
  +  * Renders one or more xf:value elements 
  + * depending on whether _value is a
  

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/transformation XMLFormTransformer.java

2002-06-04 Thread cziegeler

cziegeler2002/06/04 02:42:02

  Modified:src/java/org/apache/cocoon/generation
XMLDBCollectionGenerator.java XMLDBGenerator.java
   src/java/org/apache/cocoon/reading DatabaseReader.java
   src/java/org/apache/cocoon/transformation
XMLFormTransformer.java
  Log:
  Moved more components from Cacheable to CacheableProcessingComponent
  
  Revision  ChangesPath
  1.7   +8 -8  
xml-cocoon2/src/java/org/apache/cocoon/generation/XMLDBCollectionGenerator.java
  
  Index: XMLDBCollectionGenerator.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/XMLDBCollectionGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLDBCollectionGenerator.java 23 Feb 2002 16:47:39 -  1.6
  +++ XMLDBCollectionGenerator.java 4 Jun 2002 09:42:01 -   1.7
  @@ -59,9 +59,9 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.SourceValidity;
   import org.xml.sax.SAXException;
   import org.xml.sax.helpers.AttributesImpl;
   
  @@ -96,12 +96,12 @@
* slash in the base tag is important!
*
* @author mailto:[EMAIL PROTECTED]";>Gianugo Rabellino
  - * @version CVS $Id: XMLDBCollectionGenerator.java,v 1.6 2002/02/23 16:47:39 
gianugo Exp $
  + * @version CVS $Id: XMLDBCollectionGenerator.java,v 1.7 2002/06/04 09:42:01 
cziegeler Exp $
* @deprecated Use the XML:DB pseudo protocol instead.
*/
   
public class XMLDBCollectionGenerator extends ComposerGenerator
  -   implements Cacheable, Configurable,Initializable {
  +   implements CacheableProcessingComponent, Configurable,Initializable {
   
   protected static final String URI =
 "http://apache.org/cocoon/xmldb/1.0";;
  @@ -204,22 +204,22 @@
   /**
* The component isn't cached (yet)
*/
  -public CacheValidity getValidity() {
  +public SourceValidity getValidity() {
 return null;
   }
   
   /**
* The component isn't cached (yet)
*/
  -public CacheValidity generateValidity() {
  +public SourceValidity generateValidity() {
 return null;
   }
   
   /**
* The component isn't cached (yet)
*/
  -public long generateKey() {
  -  return 0;
  +public java.io.Serializable generateKey() {
  +  return null;
   }
   
  /**
  
  
  
  1.7   +8 -8  
xml-cocoon2/src/java/org/apache/cocoon/generation/XMLDBGenerator.java
  
  Index: XMLDBGenerator.java
  ===
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/XMLDBGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLDBGenerator.java   23 Feb 2002 16:47:39 -  1.6
  +++ XMLDBGenerator.java   4 Jun 2002 09:42:01 -   1.7
  @@ -59,9 +59,9 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
  -import org.apache.cocoon.caching.CacheValidity;
  -import org.apache.cocoon.caching.Cacheable;
  +import org.apache.cocoon.caching.CacheableProcessingComponent;
   import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.SourceValidity;
   import org.xml.sax.SAXException;
   
   import org.xmldb.api.DatabaseManager;
  @@ -95,12 +95,12 @@
* slash in the base tag is important!
*
* @author mailto:[EMAIL PROTECTED]";>Gianugo Rabellino
  - * @version CVS $Id: XMLDBGenerator.java,v 1.6 2002/02/23 16:47:39 gianugo Exp $
  + * @version CVS $Id: XMLDBGenerator.java,v 1.7 2002/06/04 09:42:01 cziegeler Exp $
* @deprecated Use the XML:DB pseudo protocol instead.
*/
   
public class XMLDBGenerator extends ComposerGenerator
  -   implements Cacheable, Configurable,Initializable {
  +   implements CacheableProcessingComponent, Configurable,Initializable {
   
   protected String driver;
   protected String base;
  @@ -195,22 +195,22 @@
   /**
* The component isn't cached (yet)
*/
  -public CacheValidity getValidity() {
  +public SourceValidity getValidity() {
 return null;
   }
   
   /**
* The component isn't cached (yet)
*/
  -public CacheValidity generateValidity() {
  +public SourceValidity generateValidity() {
 return null;
   }
   
   /**
* The component isn't cached (yet)