[jboss-user] [JBoss Seam] - @Label thoughts?

texan do-not-reply at jboss.com
Thu Sep 21 11:28:16 EDT 2006


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.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973320#3973320

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973320



More information about the jboss-user mailing list