-
1. Re: dynamic messages
vladimir.kovalyuk Sep 3, 2008 11:13 AM (in response to tszpinda)The following should work:
<h:dataTable var="item" value="#{orderList.resultList}"> <h:column> <h:outputText value="#{messages[item.status]}" /> </h:column> </h:dataTable>
-
2. Re: dynamic messages
tszpinda Sep 3, 2008 11:29 AM (in response to tszpinda)For me it renders nothing just empty column. Even if there is no entry in the messages*.properties file.
-
3. Re: dynamic messages
jamesjmp Sep 3, 2008 1:12 PM (in response to tszpinda)hi,
what Vladimir said is the proper syntax. I use it in plenty of places of mu application and it works.
Check if you have an entry for the value of item.status in your messages properties file.
And remember that an entry calleditem.status
in the properties file will not work.
Try to display item.status value this way<h:column> <h:outputText value="#{messages[item.status]}" /> </h:column> <h:column> #{item.status} </h:column>
Check if both columns are empty. If the second is empty of course the first would be empty as well.In that case debug or check the database to find out why is that value empty. If empty.status has a value, for instance
btw
you should have an entry in the properties. For examplebtw=By the way
Hope this has helps you!
-
4. Re: dynamic messages
tszpinda Sep 3, 2008 1:36 PM (in response to tszpinda)It's done exactly as you both say.
I think I know what is the problem, item.status is defined as enum, cos I tried with other types like String and it's fine.
-
5. Re: dynamic messages
tszpinda Sep 4, 2008 9:05 AM (in response to tszpinda)Does it work for anyone with enums? I think it would be quite useful if it does.
I got something like:
@Entity public class Order{ public String code; public Status status; public enum Status{ NEW_ORDER(1), ALLOCATED(2); private intValue; private Status(int value){ this.intValue = value; } } }
and then
<h:dataTable var="item" value="#{orderList.resultList}"> <h:column> <h:outputText value="#{messages[item.status]}" /> <h:outputText value="#{item.status}" /> <!-- this works fine --> </h:column> </h:dataTable>
anyone? please :)
-
6. Re: dynamic messages
vladimir.kovalyuk Sep 4, 2008 8:41 PM (in response to tszpinda)try item.status.name() and place properties NEW_ORDER and ALLOCATED into your messages.properties
-
7. Re: dynamic messages
tszpinda Sep 4, 2008 10:13 PM (in response to tszpinda)Only the way I could get around the problem was adding the method getName() to enum. After that everything works fine.
Thanks guys for help!
Tomek