Hi David,
what basically happens is that the activateMetaData method is called
before you have values for these bean properties. This is done the
first time something needs to access the constraints, after that,
this method is never called explicitly anymore. One solution might be
to call it yourself right after you populate the bean properties and
before you store the bean in the CMF. I haven't seen your code and
there are a lot of possible scenarios, but I think this should help
you find a solution.
Take care,
Geert
On 23 Aug 2007, at 14:07, David Herbert wrote:
>
> Hello,
>
> I posted back at the end of July about my RIFE/CRUD application which
> maintains a database of photographs, watermarking the images as
> they are
> entered. Until yesterday I thought this was working as expected,
> but I
> now find a problem with new images (i.e. ones that are not already in
> the CMF table in their unwatermarked form, with all their attendant
> text
> data also in CMF). The images ARE watermarked, but not with the
> text I
> expect. I want the watermark to contain the name of the photographer
> and the year the image was taken, both of which are bean properties
> entered elsewhere in RIFE/CRUD's add data form. The relevant
> constraint
> in my bean is:
>
> addConstraint(new ConstrainedProperty("image")
> .notNull(true)
> .file(true)
> .listed(false)
> .mimeType(MimeType.IMAGE_JPEG)
> .contentAttribute("watermark", this.getPhotographer() +
> " "
> + DateTimeUtils.datePart(this.getDate(), Calendar.YEAR))
> .transformer(WATERMARKER));
>
> where getPhotographer() and getDate() are getters in the current bean.
> Unfortunately, the first time I enter an image, the watermark ends up
> as:
>
> (c) null 2007
>
> which is because the bean properties aren't accessible or set at the
> point when the transform is applied to the image. If I then edit that
> record and re-upload the image, it is watermarked correctly, clearly
> because the bean has been loaded with existing data from the CMF.
> Within my "transform" method in the WatermarkImageTransformer, I see
> that the "attr" map does indeed contain a key "watermark" but that
> it is
> has been populated with a null value and default year.
>
> Am I wrong to expect this code to work? Or is there something else I
> have to do to ensure the transform is done at a different point in the
> data entry process? Or some extra thing I have to do in the
> "transform"
> method to ensure the data is loaded?
>
> Thanks for any help,
>
> David Herbert
> British Antarctic Survey.
>
> --
> This message (and any attachments) is for the recipient only. NERC
> is subject
> to the Freedom of Information Act 2000 and the contents of this
> email and any
> reply you make may be disclosed by NERC unless it is exempt from
> release under
> the Act. Any material supplied to NERC may be stored in an electronic
> records management system.
>
>
> >
--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rife-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---