Results 1 to 5 of 5

Thread: Attributes

  1. #1
    Join Date
    Aug 2004
    Location
    Whitehorse, YT, Canada
    Posts
    26

    Default Attributes

    Is there a way to define attributes about your POJOs so that the views know how to display them?

    For example, we use a MessageSource when you want to associate a label to some text and that association is defined in an external “message.properties” file.

    However, where do you define maximum width, display width, etc which is necessary for editing and table views? I don't want to define that information in each view, and then need to redefine the information when we deploy the same application to a new client with a different back-end.

    Thanks,
    smv

  2. #2
    Join Date
    Aug 2004
    Posts
    203

    Default

    See PetClinicValidationRulesSource for example - it be better that this informations exist in external (xml or properties) file, too

    regards

  3. #3
    Join Date
    Aug 2004
    Location
    Whitehorse, YT, Canada
    Posts
    26

    Default

    Thanks for replying, snpe!

    I looked at the example you suggested and found the mapping in the richclient-application-context.xml file, but the mapping is never referenced anywhere. The form is created from code, but the form model does not know anything about the ruleSource. Additionally, FormModel doesn't have an accessor to RulesSource, so even if the form were defined by a bean, it still wouldn't have the mapping to the rulesSource.

    If the rulesSource were being used by the example, I still doin't see how the constraints would be applied to a view since an AbstractView doesn't have an accessor for RulesSource. In addition to knowing the maximum length for an editable field, I would like to tell or have the BeanTableModel also know the preferred width for the column for displaying in a JTable.

    I am converting code from an in-house developed framework to Spring-RCP. One of the features of this framework was to have the domain objects (ie: Community) publish it's metadata, including: label, max width, preferred width, class, table, column name, etc. The framework would map the metadata to the proper attribute in the class (ie: name, province, postalCode) through field models.

    Spring takes care of the label through MessageSource, which is fine for changing locales. For the remainder of the metadata, it would appear that I need to redefine it in views and forms instead of defining it in one location. Is this the correct implementation strategy?

    Thanks!

  4. #4
    Join Date
    Aug 2004
    Posts
    203

    Default

    RCP remember every usage bean Owner for rule - if Owner is used with spring context

    It is defined once for Owner bean

    regards

  5. #5
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Actually, ValidatingFormModel does have a member for an associated RuleSource, that can be set or retrieved via lookup (for accessing a shared instance configured in the application context, as PetClinic does). This is how form fields get attached validation policies.

    With that said, I completely agree with you: we need to support more metadata, metadata driven control selection and formatting is a big thing. We should support various means of metadata specification: e.g programatically, configuration file, jdk 1.5 attribute, etc.

    Good suggestions...I hope we can offer solutions here soon. I invite you to take a look at the existing PropertyAccessStrategy code and PropertyMetadataAccessStrategy code in the binding packages: that's likely the area we want to develop/enhance, in addition to the form framework. I'd be very interested in your ideas/contributions.
    Keith Donald
    Core Spring Development Team

Similar Threads

  1. Replies: 1
    Last Post: May 29th, 2005, 06:03 AM
  2. Replies: 17
    Last Post: May 10th, 2005, 08:30 PM
  3. Replies: 5
    Last Post: Mar 2nd, 2005, 07:11 AM
  4. Replies: 8
    Last Post: Dec 7th, 2004, 06:13 PM
  5. Replies: 9
    Last Post: Oct 23rd, 2004, 12:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •