[jboss-user] [JBoss Seam] - :selectItems and extended EL?
NeillR
do-not-reply at jboss.com
Wed May 30 19:01:26 EDT 2007
OK,
Here is what I wanna do:
I have a drop down list in my page. Inside my <h:selectOneMenu> tag I have a <s:selectItems> to iterate over a collection of instances of class Book. The varaible I have defined in the s:selectItems to do this is called "book"
Now I want each selectItem in the list to have a label set to a description of the current book in the iteration. I also want the description to be configurable from a message in a bundle.
One way I have tried is to set the label attribute to '#{messages.book_description} and have book_description=#{book.author}-#{book.title} in the messages.properties file. But this just quotes me "#{book.author}-#{book.title}" I.e does not do the value replacement for the book.
Another thing I have tried is to have a seam component with a function defined on it "calculateBookDescription(Book book)" and then set the label attribute to "#component.calculateBookDescription(book)".
Actually, this would be my preferred route I think because it means the book description can be constructed with a function that has acces to data from a wider context than just stuff available on a Book instance. For example I could have a a description like: "Author {0} - Title {1} - BundlePrice {2}", where BundlePrice depends upon a shopping cart total value or something like that.
Anyway, this doesn't work either. I get a ParseException saying:
Caused by: com.sun.el.parser.ParseException: Encountered "(" at line 1, column 34.
Was expecting one of:
"}" ...
"." ...
"[" ...
">" ...
My guess is this is because the <s:selectItems> label attribute does not support Method expressions, only Value expressions and the Seam EL only works for Value expressions.
Any ideas about how I could achieve the desired functionality (getting a dynamic description on the label attribute) would be much appreciated!!
Cheers
Neill
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4049943#4049943
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4049943
More information about the jboss-user
mailing list