3 Replies Latest reply on Sep 21, 2006 11:39 AM by texan

    @Label thoughts?

    texan

      I'm wondering if it would be useful to have an @Label tag on a bean attribute, that could be used (with a new JSF component) to display the label of a component. An attempt at applying DRY to an area that has always bugged me. Feel free to tell me that somebody did this ages ago and I should just use that.

       @Label(value="Full Name")
       private String name;
      
       @Label(key="org.whatever.lastName")
       private String lastName;
      
       <my:attrLabel value="#{user.name}" />


      Maybe the "value=" wouldn't work on the UI component - I haven't written a component before, so I'm not sure how you'd do this, but the intent is that the component would recognize that the "user.name" attribute had a @Label annotation and would use either the key (from a bundle) or the value from the annotation. If there was no annotation, maybe it would use the attribute name itself, possibly converting the first character to a capital.

      Ideally, the h:outputLabel component would support this, so that it could use the "for" attribute and tie in with messages. Maybe there's a way to tie into the "for" mechanism in a custom component...

      Anyway, just thinking out loud, really. If I get a little breathing room, I need to create a custom component to learn how things work under the covers, so maybe this is something I'll try.

      I'm only posting it here because it sort of fits with Seam's "seamless" approach to things.

      FYI, this line of thought came about when I was considering writing an "exportLink" component that would handle exporting a collection (or DataModel) to CSV, Excel, etc. It occurred to me that there's not a clean way (IMHO) to do this because I don't have headings for the results. With the @Label annotation, that would be a freebie. [I've seen the MyFaces example where they're parsing the HTML for an export, but that feels really fragile. Besides, I want to export the entire data set, not just the 10 rows I displayed on the UI.]

      Anyway, my "exportLink" tag would probably work with an @Exported annotation on the bean, to indicate which attributes should be exported. I started thinking I'd add a (label = "Full Name") to the @Exported annotation, which led me to think that a full @Label tag would itself be quite useful.

      So here I am, circles within circles, babbling away.



        • 1. Re: @Label thoughts?
          christian.bauer

          Something like this would in one form or another be required anyway if we want to make CRUD _really_ simple.

          • 2. Re: @Label thoughts?
            gavin.king

            I have already done some thinking and design work around this stuff. But i won't implement it 'til I have finished with the rest of the CRUD framework that is sitting on my box.

            • 3. Re: @Label thoughts?
              texan

              Well, if you two have been thinking about this, it's already in good hands. I may still play with it if I get impatient, but I'm having trouble finding time to tie my shoes right now, so it won't be soon.