cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asif_zzz <aashik_...@hotmail.com>
Subject Re: MultiPart upload action
Date Sat, 18 Oct 2008 06:01:09 GMT

Hi,

I've done like this, and its working .I've used Cocoon 2.1.10 CForms 

Cforms Binding File:
<fb:value id="uploadFieldName" path="documentPart" direction="save"/>

Repeater:

<fb:on-insert-row>
			<fb:insert-bean classname="BeanClassName" addmethod="addNewAttachment"/>
//specify the beanClassName in the classname ATTRIBUTE
		</fb:on-insert-row>

Backend Logic:

public class Sample {
private org.apache.cocoon.servlet.multipart.Part documentPart; //add
gettters & setters for this field

..
..
}

Binding bean:

public void addNewAttachment(Sample sample){
		if(sample.getDocumentPart()!=null){
			sample.setFileName(sample.getDocumentPart().getFileName());
			try {
				InputStream inputStream  = sample.getDocumentPart().getInputStream();
				byte[] theBytes = new byte[inputStream.available()];
				inputStream.read(theBytes);
				sample.setDocument(theBytes); //specfiy the database field which you are
going to set
//perform the logic for adding the record to database

			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}


Regards,
Mohammed
-- 
View this message in context: http://www.nabble.com/MultiPart-upload-action-tp20034622p20044401.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Mime
View raw message