Hi! This problem is probably due to missing connection properties in the properties file. When using ERAttachments you must put at least these properties there:
# Connection dictionary for ERAttachments and migrations. dbConnectURLGLOBAL=jdbc:FrontBase://localhost/yourdb/ dbConnectUserGLOBAL=your_user dbConnectPasswordGLOBAL=your_password You can do this in either the common library along with the model, or in the applications properties file, which BTW probable caused this error! /Fredrik Lindgren 6 aug 2012 kl. 19:18 skrev Sr. Ângelo Andrade Cirino <[email protected]>: > Hi, > > I managed to get ERAttachment and D2W to work, but with some issues. First, > the libraries order in the build path is very important. I did not understand > which specific order is the right one, but the screen capture below shows the > order that worked for me: > > <LibrariesOrderForERAttachment.png> > > Second, despite being able to use ERMD2WEditAttachment to upload the image, > there is no preview. I assumed that both ERMD2WEditAttachment and > ERD2WDisplayAttachment would display the image. Both ERMD2WEditAttachment and > ERD2WDisplayAttachment display a small icon representing the image alongside > with its name. ERD2WDisplayAttachment displays the name as a link and when > this link is clicked the image is show in a new page. I would prefer a > thumbnail of the image being shown. > > Trying to show the image, I changed the rule to use > ERD2WDisplayImageAttachment instead of ERD2WDisplayAttachment, and then I got > the following error: > > WODynamicElementCreationException: > <er.extensions.components._private.ERXSwitchComponent> : cannot find > component or dynamic element named ERD2WDisplayImageAttachment > at > er.extensions.components._private.ERXSwitchComponent._realComponentWithName(ERXSwitchComponent.java:86) > > The D2W application I am developing is the back end application, while there > will be a front end application, the publicly visible website that customers > will access. Since I managed to work with ERAttachment and D2W, I decided to > test the basic design of the front end application with ERAttachment. I used > the tutorial > (http://wiki.wocommunity.org/display/documentation/ERAttachment+Framework#) > as a basis to build my own app, the only difference being MySQL instead of > Frontbase. > > To make it work I had to follow the advice in this post: > > http://lists.apple.com/archives/webobjects-dev/2011/Apr/msg00004.html > > setting the relationship directly to ERDatabaseAttachment instead of > ERAttachment. > > Now that I solved the problems I can go ahead with my application. I only > hope to be able to show the images in D2W instead of the icon and link, but > this is not critical. > > Cheers, > > Angelo > > Em 04/08/2012, às 17:29, David Holt escreveu: > >> >> On 2012-08-04, at 12:46 PM, "Sr. Ângelo Andrade Cirino" <[email protected]> >> wrote: >> >>> Hi David, >>> >>> Thank you for your help. I managed to find the problem. Due to the mess >>> with the migrations and then deleting and rebuilding the tables, I noticed >>> that the inherited relationships in ERDatabaseAttachment, ERFileAttachment >>> and ERS3Attachment weren't deleted, so after deleting them and creating >>> just one entity for an attachment, I was able to solve that problem. >>> >>> I simplified the model to use just one image and the ERMD2WEditAttachment >>> component worked properly. But then another problem arose. Maybe it is due >>> to the relationship I set up in EOModeler. Unfortunately the screen capture >>> of your example arrived unreadable (half of the image in black) and I >>> couldn't use it as a model for my own relationship. This is the screen >>> capture of the relationship I created: >>> >>> <Captura de Tela 2012-08-04 às 16.42.36.png> >> >> You can't create a foreign key in the ERAttachment tables. It just creates >> problems. >> >> David >> >>> >>> The error I am getting now is this: >>> >>> EOGeneralAdaptorException: EvaluateExpression failed: >>> <com.webobjects.jdbcadaptor._MySQLPlugIn$MySQLExpression: "INSERT INTO >>> ERAttachment(size, width, height, attachmentDataID, available, thumbnail, >>> creationDate, ownerID, configurationName, smallData, mimeType, >>> originalFileName, webPath, id, proxied, storageType) VALUES (?, NULL, NULL, >>> ?, ?, NULL, ?, NULL, NULL, NULL, ?, ?, ?, ?, ?, ?)" withBindings: >>> 1:18160(size), 2:3(attachmentDataID), 3:true(available), 4:2012-08-04 >>> 16:13:54(creationDate), 5:"image/jpeg"(mimeType), >>> 6:"miniatura.jpg"(originalFileName), 7:"/8.jpg"(webPath), 8:8(id), >>> 9:true(proxied), 10:"db"(storageType)>: >>> Next exception:SQL State:23000 -- error code: 1452 -- msg: Cannot add >>> or update a child row: a foreign key constraint fails >>> (`visiontur`.`erattachment`, CONSTRAINT >>> `ERAttachment_attachmentDataID_id_FK` FOREIGN KEY (`attachmentDataID`) >>> REFERENCES `ERAttachmentData` (`id`)) >>> at >>> com.webobjects.eoaccess.EODatabaseContext._exceptionWithDatabaseContextInformationAdded(EODatabaseContext.java:4504) >>> >>> It seems to be a problem with the ERAttachmentData. I guess that after >>> solving this issue I will be able to use the ERAttachment. >>> >>> I indeed considered using one single image with the remaining two being >>> created on the fly with ImageMagik, but since the three images not only >>> have three different dimensions, but also three different aspect ratios >>> that demand user intervention, I decided to leave the creation of the three >>> images to the user. Otherwise I will have to use a JavaScript interface to >>> determine the sizes and a custom component. This JavaScript option with a >>> custom component is the best and most elegant solution, but I am in a hurry >>> and decided to leave it as a delayed requirement. >>> >>> Best regards, >>> >>> Angelo >>> >>> Em 04/08/2012, às 00:31, David Holt escreveu: >>> >>>> >>>> On 2012-08-03, at 8:12 AM, Sr. Ângelo Andrade Cirino <[email protected]> >>>> wrote: >>>> >>>>> Hi David, >>>>> >>>>> At first sight the relationships look correct. I have an entity that can >>>>> hold three different pictures, so I decided to use three attributes, one >>>>> for each picture. >>>> >>>>> The pictures are optional. >>>> >>>> Double check that is correct in your model. >>>> >>>>> The database is being updated to a certain level, since I can see that >>>>> the private keys are being automatically incremented. As can be seen in >>>>> the picture, there are three images and the component will complain that >>>>> one of two is missing, either "Small Picture" or "Big Picture". It >>>>> doesn't matter if I try to insert just the thumbnail, leaving the other >>>>> two attachments empty, the component will always complain that >>>>> ERDatabaseAttachment >>>> >>>> You could try putting the Attachment component on separate tabs. Check if >>>> there is a problem with three of them in the same page. I've only ever >>>> used one. Have you considered processing the images on the fly with >>>> something like ImageMagik so that you upload once and then the other sizes >>>> are created for you on the fly and added to the attachments? >>>> >>>> Did you turn off creating the key in the ERAttachment side of your >>>> relationships when you created them? >>>> >>>> <Screen Shot 2012-08-03 at 8.24.44 PM.png> >>>> >>>>> must have one image, either one of the two mentioned. >>>>> >>>>> I used EOModeler to create the relationships, in my database table I just >>>>> provided the columns to store the private keys for the images in >>>>> ERAttachment. >>>> >>>> The code below looks perfect. >>>> >>>>> The relationship is modeled as optional one-to-one, for instance >>>>> Pacote.imagemGrandeID => ERAttachment.id. This is the code generated by >>>>> EOGenerate: >>>>> >>>>> public er.attachment.model.ERAttachment imagemGrande() { >>>>> return >>>>> (er.attachment.model.ERAttachment)storedValueForKey(_Pacote.IMAGEM_GRANDE_KEY); >>>>> } >>>>> >>>>> public void setImagemGrande(er.attachment.model.ERAttachment value) { >>>>> takeStoredValueForKey(value, _Pacote.IMAGEM_GRANDE_KEY); >>>>> } >>>>> >>>>> public void >>>>> setImagemGrandeRelationship(er.attachment.model.ERAttachment value) { >>>>> if (_Pacote.LOG.isDebugEnabled()) { >>>>> _Pacote.LOG.debug("updating imagemGrande from " + imagemGrande() + >>>>> " to " + value); >>>>> } >>>>> if >>>>> (er.extensions.eof.ERXGenericRecord.InverseRelationshipUpdater.updateInverseRelationships()) >>>>> { >>>>> setImagemGrande(value); >>>>> } >>>>> else if (value == null) { >>>>> er.attachment.model.ERAttachment oldValue = imagemGrande(); >>>>> if (oldValue != null) { >>>>> >>>>> removeObjectFromBothSidesOfRelationshipWithKey(oldValue, >>>>> _Pacote.IMAGEM_GRANDE_KEY); >>>>> } >>>>> } else { >>>>> addObjectToBothSidesOfRelationshipWithKey(value, >>>>> _Pacote.IMAGEM_GRANDE_KEY); >>>>> } >>>>> } >>>>> >>>>> Thanks for the help, >>>>> >>>>> Angelo >>>>> >>>>> Em 03/08/2012, às 11:06, David Holt escreveu: >>>>> >>>>>> What does your model for ERAttachment to your entity look like? >>>>>> >>>>>> What have you created the relationship(s) on? >>>>>> >>>>>> d >>>>>> >>>>>> On 2012-08-03, at 4:52 AM, Sr. Ângelo Andrade Cirino >>>>>> <[email protected]> wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> By disabling the properties for migrations in my application's >>>>>>> properties file I was able to launch the app, but I am getting an error >>>>>>> trying to use ERAttachment with D2W and three properties bound to >>>>>>> ERD2WDisplayAttachment for editing. The D2W interface presents the >>>>>>> error shown in the following screen capture: >>>>>>> >>>>>>> <Captura de Tela 2012-08-02 às 22.12.48.png> >>>>>>> >>>>>>> and the console reports this (among similar messages): >>>>>>> >>>>>>> Ago 02 22:03:20 Visiontur[60741] DEBUG NSLog Page: >>>>>>> er.modern.look.pages.ERMODTabInspectPage - Configuration: EditPacote - >>>>>>> Updating primary key value for ERAttachment in PK table named: >>>>>>> EO_PK_TABLE to seed value: 21 >>>>>>> Ago 02 22:03:20 Visiontur[60741] DEBUG NSLog Page: >>>>>>> er.modern.look.pages.ERMODTabInspectPage - Configuration: EditPacote - >>>>>>> evaluateExpression: >>>>>>> <com.webobjects.jdbcadaptor.MySQLPlugIn$MySQLExpression: "UPDATE >>>>>>> EO_PK_TABLE SET PK = 21 WHERE NAME = 'ERAttachment' AND PK = 20" >>>>>>> withBindings: > >>>>>>> Ago 02 22:03:20 Visiontur[60741] DEBUG NSLog Page: >>>>>>> er.modern.look.pages.ERMODTabInspectPage - Configuration: EditPacote - >>>>>>> === Commit Internal Transaction >>>>>>> >>>>>>> Strangely, the bindings are missing. I am not sure what this means, but >>>>>>> maybe the ERD2WDisplayAttachment component needs some tweaking through >>>>>>> rules that I am missing. The specific rule I am using is this: >>>>>>> >>>>>>> 100 : ((task = 'edit' or task = 'create') and (propertyKey = >>>>>>> 'miniatura' or propertyKey = 'imagemPequena' or propertyKey = >>>>>>> 'imagemGrande')) => componentName = "ERMD2WEditAttachment" >>>>>>> [com.webobjects.directtoweb.Assignment] >>>>>>> >>>>>>> Thanks, >>>>>>> >>>>>>> Angelo >>>>>>> _______________________________________________ >>>>>>> Do not post admin requests to the list. They will be ignored. >>>>>>> Webobjects-dev mailing list ([email protected]) >>>>>>> Help/Unsubscribe/Update your Subscription: >>>>>>> https://lists.apple.com/mailman/options/webobjects-dev/programmingosx%40mac.com >>>>>>> >>>>>>> This email sent to [email protected] >>>>>> >>>>> >>>> >>> >> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list ([email protected]) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/webobjects-dev/aacirino%40gmail.com >> >> This email sent to [email protected] > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list ([email protected]) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/frelin%40timeoff.se > > This email sent to [email protected]
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
