[jboss-user] [JBoss Seam] - PojoCache and s:selectItems Value is not valid Issue

javalover75 do-not-reply at jboss.com
Fri Aug 24 13:22:40 EDT 2007

I have the following snippet in a page:

  | <s:decorate id="creditCardTypeDecoration" template="/layout/edit.xhtml">
  |           <ui:define name="label">Credit Card Type:</ui:define>
  | 				<h:selectOneMenu value="#{customerHome.instance.creditCardType}" required="true">
  | 					<s:selectItems value="#{userDAO.creditCardTypeList}" var="ccType" label="#{ccType.creditCardType}"  noSelectionLabel="Select Type"  />
  | 					<s:convertEntity />
  | 				</h:selectOneMenu>
  | 			</s:decorate>

The userDAO has the following method:

  | public List<CreditCardType> getCreditCardTypeList() throws CacheException
  |     {
  |     	List<CreditCardType> creditCardType = (ArrayList<CreditCardType>)pojoCache.get( "reference", "creditCardTypeList" );
  |     	if ( creditCardType == null )
  |     	{
  |     		creditCardType = entityManager.createQuery( "from CreditCardType creditCardType" ).getResultList();
  |     		pojoCache.put( "reference", "creditCardTypeList", creditCardType );
  |     	}
  |     	return creditCardType;
  |     }

When the data comes from the cache in the validation of the form I get a value is not valid error.

When I use the following method all is well - however, a database call is made with all of the lookups.  I have this pattern happening many times throughout the site and it is very expensive. 

  | public List<CreditCardType> getCreditCardTypeList() throws CacheException
  |     {
  |        	return entityManager.createQuery( "from CreditCardType creditCardType" ).getResultList();
  |     }

Any help will be appreciated.

As an FYI I have tried to get this to work using the EJB3EntityTreeCache with no luck.  I have the cache configured correctly with no errors, but it still goes to the database every time.  Has anyone figured out how to get caching to work with a seam managed entity manager?

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

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

More information about the jboss-user mailing list