cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Howard <coc...@leverageweb.com>
Subject Re: insert request parameter from action
Date Thu, 04 Sep 2003 14:04:40 GMT
Jorg Heymans wrote:
> I like to reply to myself :)
> 
> Could someone explain me then the difference between
> 
>   	<map:match pattern="upload">
>   		<map:act type="upload-files"/>
>   		<map:generate type="request"/>
>   		<map:serialize type="xml"/>
>   	</map:match>
> 
> and 
>   	<map:match pattern="upload">
>   		<map:act type="upload-files">
>   			<map:generate type="request"/>
> 		</map:act>
>   		<map:serialize type="xml"/>
>   	</map:match>

Actions control which sitemap fragments get assembled before generation 
starts.  They do this by enclosing elements -- the enclosed elements are 
only executed if the action succeeds.  So your first example will 
execute the full pipeline no matter what happens in your action, which 
may be masking some other problem.  In the second case, if the action 
fails, you are left with an incomplete pipeline definition which will 
cause Cocoon to fail.  I'd say that's exactly what's happening to you.

Geoff

> I see the latter version mentioned in the docs a lot, it's however not
> working for me.. (it's not matching the upload pattern anymore somehow)
> 
> Is there a scope notion maybe? For variables set in the action to be picked
> up by the other components they need to be added in the enclosing xml
> element?
> 
> First time I'm using actions, so I'm probably still on the learning curve,
> would be glad however if some could enlighten me (:
> 
> Tnx
> Jorg
> -----Original Message-----
> From: Jorg Heymans [mailto:Jorg.Heymans@12snap.com] 
> Sent: Donnerstag, 4. September 2003 11:18
> To: 'users@cocoon.apache.org'
> Subject: RE: insert request parameter from action
> 
> i am using cocoon 2.04 for this, in case it makes a difference.
> I tried to do plugin a custom transformer between the action and the
> serializer to no avail..
> 
> Looking at the Request request = ObjectModelHelper.getRequest(objectModel)
> call a bit closer, it doesn't seem that there are much setter functions on
> the request object.. equivalent to request.getParameter I expected a
> request.setParameter which isn't there .. mmm strange
> 
> 
> Here is what I want to accomplish:
> - users can upload any type of file using any parameter they like
> - strip out the upload from the request, save it under a unique filename and
> replace the filename stored in the request object with that unique filename
> so the rest of the pipeline can pick it up..
> 
> 
> maybe I need to rethink my strategy on how to accomplish this?
> 
> 
> -----Original Message-----
> From: Jorg Heymans [mailto:Jorg.Heymans@12snap.com] 
> Sent: Donnerstag, 4. September 2003 10:29
> To: 'users@cocoon.apache.org'
> Subject: insert request parameter from action
> 
> I have an action to deal with fileuploads
> ...
> getLogger().debug("attached file found -> " + parameterName);
> FilePart filePart = (FilePart) request.get(parameterName);
> File file = ((FilePartFile) filePart).getFile();
> DiskStore ds = new DiskStore();
> String id = ds.store(file);
> request.setAttribute("newfilename", id);
> getLogger().debug("saved as reference " + id);
> ...
>  
> sitemap is 
> <map:match pattern="upload">
> <map:act type="upload-files"/>
> <map:generate type="request"/>
> <map:serialize type="xml"/>
> </map:match>
>  
> why is the requestattribute parameter "newfilename" set in the action not
> visible in the output? Is the requestgenerator not picking up the changed
> request object then? Or maybe there is another way to change to request
> object before the generator picks it up
>  


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


Mime
View raw message