-
1. Re: resource-bundle question
mikepkp17 Jan 16, 2007 5:53 AM (in response to yoav200)try
<f:selectItems value="#{messages[some.key]}"/>
where some.key is
some.key = some strange text
in your countries.properties -
2. Re: resource-bundle question
yoav200 Jan 16, 2007 7:07 AM (in response to yoav200)but i want to go over all countries not only one
-
3. Re: resource-bundle question
yoav200 Jan 16, 2007 7:10 AM (in response to yoav200)and another question
how can I get a message value dynamically?
for instance:
String msgValue = 'someValue';
#{messages[ msgValue ] }
is possible? -
4. Re: resource-bundle question
pmuir Jan 16, 2007 7:19 AM (in response to yoav200)You can't use a message bundle like that - it's for internationalisation of messages, not iteration. You'll need to use a Collection of some sort in a backing bean or specify them in the view descriptor itself (use f:selectItem).
If, by your second question, you're asking how you get a message in a backing bean (seam component):... @In(create=true) private Map messages; .... public void foo() { ... String message = (String) messages.get("foo"); ... } ...
-
5. Re: resource-bundle question
yoav200 Jan 16, 2007 8:04 AM (in response to yoav200)OK that work great,
i used a bundleLoader that loads the messages
but how can i print out useing <h:outputText>
a specific country
public void foo(String value) {
...
String message = (String) messages.get( value );
...
}
and for my first question, how can i load more resourses ?
is it enough to put the property file in the WEB-INF/classes ? -
6. Re: resource-bundle question
pmuir Jan 16, 2007 8:08 AM (in response to yoav200)I'm not really following you here but, here goes
<h:outputText value="#{messages.china}" />
would work if you had a key called china in your message bundle (by default messages.properties).
I'm not sure what you mean by 'load more resources', but, if you mean to split your message bundles into multiple files, then yes, put the xxx.properties on the classpath and tell Seam about them in components.xml.
You probably don't want to use f:loadBundle (at least I assume thats what you mean by a 'bundleLoader') but use Seam's message bundle support instead. -
7. Re: resource-bundle question
yoav200 Jan 16, 2007 11:30 AM (in response to yoav200)when i wrote 'bundleLoader' i mean a bean that loads the resource bundle and i use resources throw the bean. that way i can sort and do all kind of mnipulation on the data before i show it.
i do not use f:loadBundle .
What i want to do is this:<t:dataTable id="myTripsTable" styleClass="data_table" var="aTrip" value="#{tripList}" rendered="#{tripList.rowCount>0}" cellpadding="2" cellspacing="0" border="0" rowOnMouseOver="this.bgColor='#DEDEDE';" rowOnMouseOut="this.bgColor='#FFFFFF';" > <t:column style="width:30%;"> <s:link view="/TripDetails.jsp" value="#{aTrip.name}" action="#{tripManager.selectFromRequest}" propagation="end"> <f:param name="id" value="#{aTrip.id}"/> </s:link> </t:column> <t:column style="width:20%;"> <h:outputText value="#{aTrip.startDate.time}"> <f:convertDateTime pattern="dd/MM/yyyy"/> </h:outputText> </t:column> <t:column style="width:20%;"> <h:outputText value="#{aTrip.country}" /> </t:column> <t:column style="width:5%;"> <a4j:commandLink action="#{tripsManager.selectTripForEdit}" oncomplete="openPopup('tripFormPopup',500,250);" reRender="editTripTable"> <h:graphicImage url="images/edit_icon.gif" alt="Edit Trip" style="border:0px;" /> </a4j:commandLink> </t:column> <t:column style="width:5%;"> <a4j:commandLink action="#{tripsManager.deleteTrip}" onclick="if (!window.confirm('Delete Trip ?')) return false;" reRender="myTripsTable"> <h:graphicImage url="images/delete.gif" alt="Delete Trip" style="border:0px;" /> </a4j:commandLink> </t:column> </t:dataTable>
look at the: aTrip.country - the country that the aTrip holds is a key in the country resource, i want to display the value.
so i need to do something like this: #{country[ aTrip.country ]}
of course this will not work, so wht will ? -
8. Re: resource-bundle question
pmuir Jan 16, 2007 11:44 AM (in response to yoav200)Assuming you are using the Seam message bundle #{messages[aTrip.country]} will retrieve a resource that has #{aTrip.country} as the key.