[jboss-user] [JBoss Seam] - Re: howto display the an enum object internationalized

Smurfs do-not-reply at jboss.com
Mon Jun 11 17:17:52 EDT 2007


This is an example of an approach I have used for drop-down lists. Each constant is instantiated with the key defined in the messages properties file:


  | public enum Salutation {
  | 	
  | 	MR("salutation-mr-label"),
  | 	MRS("salutation-mrs-label"),
  | 	MS("salutation-ms-label");
  | 	
  | 	private String labelKey;
  | 	
  | 	Salutation(String labelKey) {
  | 		this.labelKey = labelKey;
  | 	}
  | 
  | 	public String getLabelKey() {
  | 		return labelKey;
  | 	}
  | }
  | 

Need to create a factory to return array of enum values to view


  | @Name("factories")
  | public class Factories {
  | 	
  | 	@org.jboss.seam.annotations.Factory("salutationTypes")
  | 	public Salutation[] getSalutationTypes() {
  | 		return Salutation.values();
  | 	}
  | }
  | 



  | <f:selectOneMenu id="salutations" value="#{backingBean.salutation}">
  | 	<s:selectItems value="#{salutationTypes}" var="salutation" label="#{messages[salutation.labelKey]}"/>
  | 	<s:convertEnum />
  | </f:selectOneMenu>
  | 

I appreciate this doesn't answer your query directly but it may give you a few clues.



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

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



More information about the jboss-user mailing list