cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From coc...@erwinhermans.eu
Subject [SOLVED] Actions and XSP: reusing classes from actions in XSP does not work
Date Thu, 09 Apr 2009 06:36:27 GMT
> Hello all,
>
> this is my first post after being a few (6 or 7) years from the list, with
> a new problem. ;-)
>
> I am writing a web application for which I must be able to upload a text
> file to the server; process this file (extract some data) en insert this
> data into a database.
>
> I am using Tomcat 6.0, Cocoon 2.1.10 and Java 1.6 on Win XP Professional
> (dutch).
>
> The way I want to work:
> 1) upload the file
> 2) process the file with a custom written action
> 3) do all the sql-stuff with an xsp page
>
> Processing/Reading the transformed data in step 3 fails.
>
> Uploading the file works.
>
> Processing the file with the custom action also works. To this goal I have
> written a few Java-classes:
> Upload - the action used to handle the upload data
> Frequentie - a container for my data - used in Upload
> Diagram - a container for data used in the class Frequentie
>
> I have not made a package for these classes (not needed for this app).
>
> I have placed these classes in the directory
> %TOMCAT_HOME%/webapps/cocoon/WEB-INF/classes
>

This seems to be a problem. I have placed my classes in a specific package
(under the %TOMCAT_HOME%/webapps/cocoon/WEB-INF/classes directory),
included the right import in my xsp page and it worked.

So problem solved, but I still find it strange that the Action works
without the custom classes being in a package and that the XSP doesn't
work.


> In my sitemap I have added this action
> <map:action name="upload" src="Upload"/>
>
> The pipeline where I am using this action is defined as follows:
> <map:match pattern="add-upload.xml">
>
> <map:act type="upload">
> 	<map:generate type="serverpages" src="add/add-upload.xsp">
> 		<map:parameter name="use-request-parameters" value="true"/>
> 	</map:generate>
> </map:act>
> <map:serialize type="xml"/>
> </map:match>
>
> The pipeline works.
> I can process this data in my class Upload.
>
> In this class Upload I generate a vector with instances of the class
> 'Frequentie' which I want to pass in the following way to my xsp-page:
> (found this method on
> http://www.theserverside.com/tt/articles/article.tss?l=Cocoon )
>
> (in the act method)
> <code_snippet>
> Vector frequenties = new Vector();
> Frequentie newF = extractData(datasheet);
> frequenties.add(newF);
> // there are in fact a series of 'Frequentie' instances that are added
> request.setAttribute("frequenties", frequenties);
> </code_snippet>
>
> In my XSP-page I try to access this in the following way:
>
> Vector frequenties = (Vector) <xsp-request:get-attribute
> name="frequenties"/>;
> Iterator it = frequenties.iterator();
>
> // test
> while (it.hasNext())
> {
> 	Frequentie f = (Frequentie) it.next();
> 	<tr>
> 		<td><xsp:expr>f.getNaam()</xsp:expr></td>
> 	</tr>
> }
>
> But the strange thing (in my eyes) is that the class Frequentie is not
> known in the context of the XSP-page. I don't know what to do to aid this.
>
> I have already put (a copy of) my classes in the cocoon/WEB-INF/lib
> directory; and in the %TOMCAT_HOME%/lib directory. Made a jar of my
> classes and put them in those directories; added the jar to the general
> classpath, but to no avail.
>
> This is the error-message I got:
>
> org.apache.cocoon.components.language.LanguageException: Error compiling
> add_upload_xsp:
> ERROR 1 (org\apache\cocoon\www\chirplus\add\add_upload_xsp.java):
> ...
> }
>
> while (it.hasNext())
> {
>
> // start error (lines 364-364) "Frequentie cannot be resolved or is not a
> type"
> Frequentie f = (Frequentie) it.next();
>
> // end error
>
>
> _startElem(
> "",
>
> ...
> ERROR 2 (org\apache\cocoon\www\chirplus\add\add_upload_xsp.java):
> ...
> }
>
> while (it.hasNext())
> {
>
> // start error (lines 364-364) "Frequentie cannot be resolved or is not a
> type"
> Frequentie f = (Frequentie) it.next();
>
> // end error
>
>
> _startElem(
> "",
>
> ...
> Line 364, column 0: Frequentie cannot be resolved or is not a type
> Line 364, column 0: Frequentie cannot be resolved or is not a type
>
> What am I doing wrong? What have I forgotten to configure?
>
> I need this solved asap, but I am running out of ideas (and time).
>
> Thanks in advance
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>



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


Mime
View raw message