Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiple language support data from db
    primarykey
    data
    text
    <p>My application has entities with nameEn and nameDe for english and german. But only english being used now. Since there are so many entities available, I wanted to have a generic class which can return the selected language entries,but for multiple entries my approach didn't work.</p> <pre><code> @Entity @Table(name="employee") public class Employee implements java.io.Serializable { // Fields private Integer id; private String nameEn; private String nameDe; //Getter, Setter Methods } @Entity @Table(name="address") public class Address implements java.io.Serializable { private String descriptionEn; private String descriptionDe; } public interface ILabelText { String getNameEn(); String getNameDe(); String getDescriptionEn(); String getDescriptionDe(); } public abstract class LabelText implements ILabelText, Serializable { private static final long serialVersionUID = 1L; protected String descriptionEn; protected String descriptionDe; private Logger log = Logger.getLogger(LabelText.class); String language = FacesContext.getCurrentInstance().getViewRoot().getLocale().getLanguage(); public String getDescription() { log.info("Language Selected is " + language); if (language.equals("De")) { return getDescriptionDe(); } else { return getDescriptionEn(); } } public String getName() { log.info("Language Selected is " + language); if (language.equals("De")) { return getNameDe(); } else { return getNameEn(); } } } //In Xhtml, based on selected locale, display value accordingly &lt;h:outputText value="#{emp.getName()}" /&gt; &lt;h:outputText value="#{add.getDescription()}" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload