[jboss-user] [JBoss Seam] - [newbie] strategy and implementation of nested java.util.Set
bolke
do-not-reply at jboss.com
Sun Oct 28 10:31:37 EDT 2007
Hello,
Before I start out with my question I would like to tell you upfront that I am quite new to Seam/EJB3/JSF, I am certain that parts of my question will be a little offtopic with regards to the forum topic. However I did actually search the net and did not really find a solution: most of the information was outdated (old examples for JSF1) or did not describe something along the lines I wanted to do. So far for the disclaimer ;-)
Software used:
| JBoss 4.2.1
| Seam 2.0CR2
| JSF 1.2
|
|
| I am trying to setup an application with generates lists of allowed chemicals for inland vessels. These lists are multilingual, eg a list can be generated in several languages.
|
| The chemical entity looks like this:
|
|
| | @Entity
| | public class Chemical implements Serializable {
| | private static final long serialVersionUID = -81501463360195381L;
| |
| | private int id;
| | private int un;
| |
| | private int maxFillRate;
| | private boolean allowPumpRoom;
| | private TemperatureClass temperatureClass;
| | private boolean explosionProtection;
| | private double density;
| | private String classification;
| | private int relievePressure;
| |
| | private Date updated;
| | private User updatedby;
| |
| | private String classificationCode;
| | private String packageGroup;
| |
| | private int bluelights;
| |
| | transient private boolean removed;
| | transient private Vector<String> removedBy = new Vector<String>();
| |
| | private Set<ChemicalNote> notes;
| | private Set<Compatibility> compatibility;
| | private Set<Danger> dangers;
| | private Set<Equipment> equipment;
| |
| | private SamplingDevice samplingDevice;
| |
| | private Set<Translation> translations;
| |
| | // getters and setters
| | }
| |
|
| I will focus on the translations part, which is the part I am having trouble with.
|
|
| | @Entity
| | public class Translation implements Serializable {
| |
| | private static final long serialVersionUID = 3885895866444687204L;
| |
| | private int id;
| |
| | private Chemical chemical;
| | private String name;
| | private String language;
| |
| | private User updatedby;
| | private Date updated;
| |
| | }
| |
|
|
| On the page showing the list of chemicals I would like to show the translation for the name of the chemical. There is a very basic backingbean:
|
|
| | @Name("chemical")
| | @Scope(CONVERSATION)
| | @Stateful
| | public class ChemicalAction implements Serializable, ChemicalInterface {
| | private static final long serialVersionUID = -5723276978457496053L;
| |
| | @PersistenceContext
| | EntityManager em;
| |
| | @Logger
| | Log log;
| |
| | @In
| | FacesContext facesContext;
| |
| | public java.util.List<Chemical> getChemicals() {
| |
| | java.util.List<Chemical> chemicals =
| | em.createQuery("select c from Chemical c order by c.un").getResultList();
| |
| | return chemicals;
| | }
| |
| | ...
| | }
| |
|
| and a little snippet of the xhtml page:
|
|
| | <ui:repeat value="#{chemical.chemicals}" var="c">
| | #{c.id} - #{c.un} - <ui:repeat value="#{c.translations}" var="t">#{t.name}</ui:repeat> <br />
| | </ui:repeat>
| |
|
| As you can see I try to loop through all the chemicals (which works) and also through all the translations (which does not work - it generates "Property 'name' not found on type org.hibernate.collection.PersistentSet").
|
| Well the question boils down to: How can I select just one item from a java.util.Set based on the current locale?
|
| Additional questions could be:
|
| | Does this need a custom component?
| | If so, can I add java.util.Set to a tld?
| | How to work around this error?
| |
|
| If additional information is needed, I will be happy to provide it. Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4099669#4099669
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4099669
More information about the jboss-user
mailing list