We are using a converter to fetch the values from lookup tables in a generic way.
POJOs are implementing an interface like,
 

public ILookupObject {

            public Object getThis();

            public Long getId();

            public String getName();

}

 
and a converter is defined in faces-config.xml for all the classes implementing this interface.
While rendering selectable items, each lookup object -fetched calling getThis(), in which lookup objects return themselves- is given into Converter.getAsString(...)  method. This method returns getClass().getName() + '_' + getId() as identifier value.

 

And we're using it from jsf pages like,

 

<h:selectOneMenu id="cmbCountries" value="#{personelPageCode.personel.country }">

            <f:selectItems value="#{selectitems.personelPageCode.countries.name.this.toArray}" />

</h:selectOneMenu>

 
Only bu specifying an el, we can fill a combo box with values from dbase.
You can find detailed information at my teammate's blogpost.
 
 
Regards,
 
Mert

 
On 5/12/06, Julian Ray <[EMAIL PROTECTED] > wrote:

Hi Matt,

we use a similar system to look up values for business object by primary key
from the database which is highly de-normalized. We use Hibernate and have
developed a base-class which we can either extend for unusual cases or use
passed table/pk name via tag attributes.

It works well and as Hibernate caches everything there is little impact on
the database :). One trick is to return different values from the PK lookup
such as names/addresses etc.. which are in user-configurable through our
GUI. To do this we have default "long" "short" and "medium" formats
available in the base class which can be interpreted based on the table
being accessed.

We did find that a generic lookup-converter is less useful (from a GUI
developer perspective) as it tends to break the MVC model and lead to code
changes in the JSP when the underlying data model changes so we now have
created sub-classed converters for each table which is preferable.


--
View this message in context: http://www.nabble.com/Use-of-Converters-t1608471.html#a4360735
Sent from the MyFaces - Users forum at Nabble.com .


Reply via email to