Thanks to both.
I have not tried yet how to display the erattachment (i'll do it this evening or tomorrow), but...
I managed to model "correctly" (maybe..) many photos:
Product < -- >> ProductPhoto < -- > ERAttachment
This are my rules:
"100 : pageConfiguration = 'ListProduct' => displayPropertyKeys = (name,price,category,thumb) [com.webobjects.directtoweb.Assignment]",
"100 : (pageConfiguration = 'ListProduct' and propertyKey = 'thumb') => componentName = ERD2WDisplayAttachment [com.webobjects.directtoweb.Assignment]",
"100 : ((pageConfiguration = 'CreateEmbeddedProductPhoto' or pageConfiguration = 'EditEmbeddedProductPhoto') and propertyKey = 'attachment') => componentName = ERMD2WEditAttachment [com.webobjects.directtoweb.Assignment]",
"100 : ((pageConfiguration = 'CreateEmbeddedProductPhoto' or pageConfiguration = 'EditEmbeddedProductPhoto') and propertyKey = 'attachment') => attachmentConfigurationName = Product.photo [com.webobjects.directtoweb.Assignment]"
So, now I don't get exception when I try to add or edit a photo.
But... there is a problem: if I try to add more than one picture for a product at the same time I get an exception (and the output in eclipse is cut.. I don't know why).
This happens also in the edit mode. If I add a picture, save the product, edit the product again, add another picture, etc, works.
NullPointerException
at er.attachment.components.ERAttachmentFlexibleEditor.uploadSucceededAction(ERAttachmentFlexibleEditor.java:174)
... skipped 13 stack elements
at er.attachment.components.ERAttachmentUpload.uploadSucceeded(ERAttachmentUpload.java:191)
... skipped 13 stack elements
at er.ajax.AjaxFileUpload.uploadSucceeded(AjaxFileUpload.java:373)
at er.ajax.AjaxFlexibleFileUpload.uploadSucceeded(AjaxFlexibleFileUpload.java:500)
at er.ajax.AjaxFlexibleFileUpload.containerRefreshed(AjaxFlexibleFileUpload.java:436)
... skipped 14 stack elements
at er.ajax.AjaxUpdateContainer.handleRequest(AjaxUpdateContainer.java:256)
... skipped 229 stack elements
at er.ajax.AjaxRequestHandler.handleRequest(AjaxRequestHandler.java:17)
... skipped 6 stack elements
About thumbnailing.
What's wrong? I mean... if I read correctly ERAttachment framework should be able to find ImageMagick (I'll try later), but I don't know the "deployment environment", so I'd like to have my code to stay more.. general...
Last thing about thumbs..
If I don't set
er.attachment.file.filesystemPath = /tmp
I get an exception, because the processor cannot find the filesystemPath property... this happens also if I create the processor passing a configurationName..It just not save it..
I was wondering.. is this the right behaviour?
Using pending attachment works...
@Override
public void setAttachment(ERAttachment value) {
// TODO Auto-generated method stub
super.setAttachment(value);
if (value != null) {
try {
File inputFile = new File(((ERFileAttachment) attachment()).filesystemPath());
File outputFile = File.createTempFile("erattachment-thumb-", attachment().originalFileName());
ERImageProcessor.imageProcessor().thumbnail(50, 50, inputFile, outputFile);
ERPendingAttachment pendingAttachement = new ERPendingAttachment(outputFile, outputFile.getName(), null, "Product.photo", null);
ERAttachment attachment = ERAttachmentProcessor.processorForType(attachment().storageType()).process(attachment().editingContext(), pendingAttachement);
attachment().addToChildrenAttachments(attachment);
}
catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden