You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/04/01 11:36:56 UTC
cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation CopletTransformer.java HTMLEventLinkTransformer.java
cziegeler 2004/04/01 01:36:56
Modified: src/blocks/portal/java/org/apache/cocoon/portal/transformation
CopletTransformer.java
HTMLEventLinkTransformer.java
Log:
Support enctype attribute in forms (hopefully)
Revision Changes Path
1.18 +30 -1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
Index: CopletTransformer.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- CopletTransformer.java 16 Mar 2004 09:16:59 -0000 1.17
+++ CopletTransformer.java 1 Apr 2004 09:36:55 -0000 1.18
@@ -17,15 +17,18 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.wrapper.RequestParameters;
import org.apache.cocoon.portal.LinkService;
import org.apache.cocoon.portal.coplet.CopletInstanceData;
import org.apache.cocoon.portal.event.impl.ChangeCopletInstanceAspectDataEvent;
import org.apache.cocoon.portal.event.impl.CopletJXPathEvent;
import org.apache.cocoon.portal.event.impl.JXPathEvent;
import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.XMLUtils;
import org.apache.commons.jxpath.JXPathContext;
import org.apache.excalibur.xml.sax.XMLizable;
import org.xml.sax.Attributes;
@@ -249,9 +252,35 @@
this.stack.push("a");
} else if ( "html-form".equals(format) ) {
+ boolean addParametersAsHiddenFields = false;
+ String parameters = null;
+ if ( newAttrs.getValue("enctype") != null ) {
+ final int pos = uri.indexOf('?');
+ if ( pos != -1 ) {
+ parameters = uri.substring(pos+1);
+ uri = uri.substring(0, pos);
+ addParametersAsHiddenFields = true;
+ }
+ }
newAttrs.addCDATAAttribute("action", uri);
this.sendStartElementEvent("form", newAttrs);
this.stack.push("form");
+ if ( addParametersAsHiddenFields ) {
+ // create hidden input fields
+ RequestParameters pars = new RequestParameters(parameters);
+ Enumeration enum = pars.getParameterNames();
+ while ( enum.hasMoreElements() ) {
+ String pName = (String)enum.nextElement();
+ String pValue = pars.getParameter(pName);
+ AttributesImpl hiddenAttrs = new AttributesImpl();
+ hiddenAttrs.addCDATAAttribute("type", "hidden");
+ hiddenAttrs.addCDATAAttribute("name", pName);
+ hiddenAttrs.addCDATAAttribute("value", pValue);
+ this.startElement("", "input", "input", hiddenAttrs);
+ this.endElement("", "input", "input");
+ }
+
+ }
} else if ( "text".equals(format) ) {
this.sendTextEvent(uri);
this.stack.push("");
1.7 +5 -1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/HTMLEventLinkTransformer.java
Index: HTMLEventLinkTransformer.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/HTMLEventLinkTransformer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- HTMLEventLinkTransformer.java 31 Mar 2004 20:32:45 -0000 1.6
+++ HTMLEventLinkTransformer.java 1 Apr 2004 09:36:56 -0000 1.7
@@ -140,6 +140,10 @@
newAttributes.addCDATAAttribute("coplet", cid.getId());
newAttributes.addCDATAAttribute("format", "html-form");
newAttributes.addCDATAAttribute("method", "POST");
+ final String encType = attributes.getValue("enctype");
+ if ( encType != null ) {
+ newAttributes.addCDATAAttribute("enctype", encType);
+ }
this.xmlConsumer.startPrefixMapping("coplet", CopletTransformer.NAMESPACE_URI);
this.xmlConsumer.startElement(CopletTransformer.NAMESPACE_URI,
CopletTransformer.LINK_ELEM,