cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mratl...@collegenet.com
Subject Re: [Announcement] XMLForm 0.81 available in Scratchpad
Date Tue, 07 May 2002 09:03:26 GMT

Ivelin,

<snip/>
>>Now I had the output I was looking for, but when I tried to
>> submit the form I kept getting errors from jxpath.

>Can you send me the stack traces.

(see below)

>BTW, the most recent version of JXPath should be able to correctly handle
>setValue( Collection or String[] ).
>Dmitri added this after we discussed its potential for request parameters
>with multiple values.

Problem is in convert function of Types.java.  This class seems to be based on
TypesUtil.java from jakarta/commons/jxpath project.  Latest version of that file
is 1.4 (11 days ago).  Only changes to convert function were these (comments are
mine):
            else if (fromType.isArray()){
          /* convert first element of array into toType */
            Object value = Array.get(object, 0);
            return convert(value, toType);
        }
      /* try to convert first element of List object into toType */
        else if (object instanceof List){
            Object value = ((List)object).get(0);
            return convert(value, toType);
        }
      /* try to convert first element of Collection object into toType */
        else if (object instanceof Collection){
            Iterator it = ((Collection)object).iterator();
            Object value = it.next();
            return convert(value, toType);
        }
        return object;
    }

None of this helps fix the problem I encountered.  It arises when the Object's
"from" type is String array (multiple-select parameter from request object).
Control falls through all this code, as well as the code that converts scalar
Strings (parameters from request object) and hits this block:

      /* Try to find a default constructor for the toType that takes the
fromType object as a parameter */
        Object[] params = new Object[] {object};
        if (hasConversionConstructor( toType, params ))
        {
          Constructor constructor = lookupConstructor( toType, params);
          try
          {
            return constructor.newInstance ( params );
          }
          catch (Exception ex)
          {
            throw new RuntimeException("Instantiation failed for Class [" +
toType +"], and constructor with parameter value [" + object + "]" + "\n" + ex);
          }
        }

Since there is no Collections constructor which takes a string array as its only
parameter, the Runtime Exception gets thrown.  The code I hacked in just makes
sure that when object instanceOf == String[] that the object is properly
converted to its "toType" (One of the Java 1.3 Collection Framework classes
implememted from Set, SortedSet, or List, although the first two of these are
probably overkill).


>> 5) Changed the convert function in Types.java to recognize String arrays
coming
>> from the request (it seems to convert only String scalars) and to convert
them
>> to ArrayList type.

>Interesting. There already was code in Form to handle request parameters
>with multiple values.
>Apparantly badly implemented:
>Can you point me to the problem ?

Again, the problem is not in setValue.  It works properly, but when property is
a collection or array it calls convertType function which calls Types.convert
function which throws exception.  From setValue():
<snip/>
    // if the property is a collection, set value as array
    if ( property instanceof Collection || property.getClass ().isArray () )
    {
      Object newValue = convertType( values, property.getClass () ); <--
INDIRECT CALL TO TYPES.CONVERT()
      pointer.setValue( newValue );
    }
</snip>

...

<snip>
>As long as there is a way to extend and override the default rendering of multi
select checkboxes,
>then your implementation should be cool. Is it an isolated template with a name
like ("selectManyCheckbox" or similar).
</snip>

xf:selectMany is (now) implemented as two templates, one matching xf:selectMany
[@selectUIType='checkboxGroup'] and the other matching xf:selectMany |
xf:selectMany[@selectUIType='listbox'].  Should be easy enough to override these
if necessary.

I will send you the three patched files compressed zip.

Cheers,
--Michael


BTW, here's the complete stack trace:

ERROR   (2002-05-07) 00:41.21:244
[sitemap](/cocoon/mount/vtechform/wizard.html)
HttpProcessor[8080][4]/PipelineNode: Error while processing pipeline at
file:/Library/jakarta-tomcat-4.0.1/webapps/cocoon/mount/vtechform/sitemap.xmap:26:17
java.lang.RuntimeException: Cannot modify property: APP_TYPE,
java.lang.RuntimeException: Cannot convert value of class [Ljava.lang.String; to
type class java.util.ArrayList
      at
org.apache.commons.jxpath.ri.pointers.PropertyAccessHelper.setValue(PropertyAccessHelper.java:257)
      at
org.apache.commons.jxpath.ri.pointers.BeanPropertyPointer.setValue(BeanPropertyPointer.java:198)
      at org.apache.cocoon.xmlform.Form.setValue(Form.java:198)
      at org.apache.cocoon.xmlform.Form.populate(Form.java:382)
      at
org.apache.cocoon.acting.AbstractXMLFormAction.act(AbstractXMLFormAction.java:212)
      at
org.apache.cocoon.components.treeprocessor.sitemap.ActTypeNode.invoke(ActTypeNode.java:133)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:83)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:157)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:138)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:142)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:318)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:289)
      at
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:128)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:83)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:157)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:138)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:142)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:318)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:289)
      at org.apache.cocoon.Cocoon.process(Cocoon.java:588)
      at
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1002)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
      at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
      at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
      at java.lang.Thread.run(Thread.java:496)
ERROR   (2002-05-07) 00:41.21:257
[sitemap](/cocoon/mount/vtechform/wizard.html)
HttpProcessor[8080][4]/PipelineNode: Error while processing pipeline at
file:/Library/jakarta-tomcat-4.0.1/webapps/cocoon/sitemap.xmap:593:17
java.lang.RuntimeException: Cannot modify property: APP_TYPE,
java.lang.RuntimeException: Cannot convert value of class [Ljava.lang.String; to
type class java.util.ArrayList
      at
org.apache.commons.jxpath.ri.pointers.PropertyAccessHelper.setValue(PropertyAccessHelper.java:257)
      at
org.apache.commons.jxpath.ri.pointers.BeanPropertyPointer.setValue(BeanPropertyPointer.java:198)
      at org.apache.cocoon.xmlform.Form.setValue(Form.java:198)
      at org.apache.cocoon.xmlform.Form.populate(Form.java:382)
      at
org.apache.cocoon.acting.AbstractXMLFormAction.act(AbstractXMLFormAction.java:212)
      at
org.apache.cocoon.components.treeprocessor.sitemap.ActTypeNode.invoke(ActTypeNode.java:133)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:83)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:157)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:138)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:142)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:318)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:289)
      at
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:128)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:83)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:157)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:138)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:142)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:318)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:289)
      at org.apache.cocoon.Cocoon.process(Cocoon.java:588)
      at
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1002)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
      at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
      at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
      at java.lang.Thread.run(Thread.java:496)
ERROR   (2002-05-07) 00:41.21:269
[access](/cocoon/mount/vtechform/wizard.html)
HttpProcessor[8080][4]/CocoonServlet: Problem with servlet
java.lang.RuntimeException: Cannot modify property: APP_TYPE,
java.lang.RuntimeException: Cannot convert value of class [Ljava.lang.String; to
type class java.util.ArrayList
      at
org.apache.commons.jxpath.ri.pointers.PropertyAccessHelper.setValue(PropertyAccessHelper.java:257)
      at
org.apache.commons.jxpath.ri.pointers.BeanPropertyPointer.setValue(BeanPropertyPointer.java:198)
      at org.apache.cocoon.xmlform.Form.setValue(Form.java:198)
      at org.apache.cocoon.xmlform.Form.populate(Form.java:382)
      at
org.apache.cocoon.acting.AbstractXMLFormAction.act(AbstractXMLFormAction.java:212)
      at
org.apache.cocoon.components.treeprocessor.sitemap.ActTypeNode.invoke(ActTypeNode.java:133)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:83)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:157)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:138)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:142)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:318)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:289)
      at
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:128)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:83)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:157)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:138)
      at
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
      at
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:142)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:318)
      at
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:289)
      at org.apache.cocoon.Cocoon.process(Cocoon.java:588)
      at
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1002)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
      at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
      at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
      at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
      at java.lang.Thread.run(Thread.java:496)




---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message