There are 29 lookup tables in my db. The selectOneMenu tags of the site are populated via objects that have been mapped to each table using Hibernate.  I want "one converter to rule them all".

getAsString() is done (determine the identifier/pk property of the bean at runtime by querying the OR meta data, call it w/ reflection, return the value as a string).  getAsObject() however is difficult - it needs some way to know which class it must create.

Is there a way to determine this by walking the UIcomponent passed to getAsObject() ?  I can cast it to a HtmlSelectOneMenu but that's as far as I get.

One idea was to extend the tag handler, add a className attribute and pass the value of this attribute to the dynamic converter in an over ridden createConverter().  Despite the fact that this means the class's full java name appears directly in the JSP, I still did this only to find that it only works for the first conversion.  The dynamic converter is recreated for each request, and the createConverter() of the tag class only fires for the first request.

I'm open to the possibility this smart converter is not a smart idea.  Someone throw me a bright idea before I go with the following:

Write 29 classes, each implements getAsObject() - each class inherits getAsString() from 30th class.

Dennis Byrne

Reply via email to