Stephen Ramsay wrote:
I've spent the last couple of weeks beating my head against the wall
trying to get file uploading to work in Cocoon 2.1.  I've read the
"File Uploads with Flow" howto on the Wiki (as well as the other
upload howtos, the docs, the update guide, and the list archives),
but I'm still confused about a few points.  Any help would be greatly
appreciated.

Yikes. Hopefully most of this time is getting used to Cocoon internals, not just uploads. They're quite easy really. Unfortunately, the docs are as you've found still pretty poor.

1. The javascript example sets the following variable

var role = Packages.org.mystuff.UploadManager.ROLE;

and then passes it in like so:

var uploader = cocoon.componentManager.getComponent(role);

What is the ROLE attribute and how (or where) do I call it?  I
gather that I need to call some class that implements some kind of
component interface, but I can't figure out which one.

The reality is that to just get this working, you wouldn't even need
to mess with a component lookup. If you have an upload handler you've written you should just be able to get an instance of your class, call your methods passing in whatever you need from the flow to save your file elsewhere, or do whatever you want. If you try this and get stuck, write back with what went wrong. Actually, to just get this working quickly, you could reference java.io classes directly from flow and
probably implement this in a few lines of flowscript.


But,

Brief interlude on avalon components because you asked and it's great
knowledge for working with Cocoon beyond the surface level and can help make up for missing docs in places.
----------------


The ROLE is a standard Avalon construct. If you haven't already,
you should read up on the wiki, in the cocoon docs, and possibly
at the avalon.apache.org site (see especially the "Developing with Avalon" paper). At least glance over those things if not really read deeply.


The short answer to your question:
The base Component is very simple -- you implement org.apache.avalon.framework.Component (maybe not exact) where you define
some ROLE -- a string which by convention would be the fully qualified class name of whatever class or interface defines this component. In the simplest case, you would have something like:


package org.mystuff

public class UploadManager implements org.apache.avalon.framework.Component {

String ROLE = Generator.class.getName();

// Whatever other classes you implement are up to you.

}

In order for ComponentManager to find this role, you'd need to define it
in cocoon.xconf with a <component> tag (you used to have to define the role in cocoon.roles first, but that's no longer necessary). There should be some other components defined this way you can see for examples.
------------------------------------


2. It also says you can "Alternatively . . . write the following
Java code in your sitemap components." What does it mean to write
Java code "in the sitemap components." Does that mean use it as an
Action?

Yes, but not limited to Actions. You can use that section to modify the portions of the upload action wiki page and be up and running sooner.


> I tried to do that and couldn't get it to work, but the
language here makes me think I'm supposed to do something different.
I'd actually rather do this without javascript, but at this point,
I'll settle for anything that works.

Let us know exactly what you tried, and what went wrong.


3.  The Wiki howto shows you to how call a flow script from the
sitemap (and the Cocoon docs show you how to set up the scripting
environment for flows, and so forth), but I'm not sure what I'm
supposed to do in the sitemap if I want to do a file upload with an
action.  Most of the explanations out there seem deprecated.

The only things that have changed since the action related items were
written are:
- The FilePart, FilePartFile, and FilePartArray classes have moved packages and changed names to Part, PartOnDisk, and PartInMemory as
mentioned on the wiki.
- An alternative to actions exists now that flow is released.


Nothing else has changed. Actions still work the same way and in this case may be easier to get up and running with since you're struggling under the learning curve right now.

I'm sorry if these questions seem really dense.

The material is dense, not the questions. Besides, UGA did my home team a favor with Champ Bailey, so I owe you one!


Geoff


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to