ivan stojic
life is a low fidelity experience

A nasty BO pitfall

May 30th, 2007, 12:41.

Suppose you are an inexperienced Clarify programmer looking to extend the functionality of a load bean. You have changed the JSP page to include some additional text field and want to output a default value from the database, using a new returned CDO from the load bean.

So you extend the worker bean to use your own load bean instead of the base one, and in your implementation of the load bean you override the retrieve method.

You do something like this in the retrieve method:

Cdo myCDO = new Cdo(”foo”);
myCDO. setValue(”this”, “that”);
setAttribute(”foo”, myCDO);

And nothing happens. Guess what? It won’t unless you create the CDO through the CDO manager, which is only available to the worker bean.

So instead of this, you need to:

  • create a property on the load bean which will hold the CDO, along with a setter
  • create the new CDO instance in the worker bean by calling m_CDOManager.getCdoByName(String) and pass it to the load bean in the setBoValues(HttpServletRequest) method
  • manipulate the CDO, and then call setAttribute in the load bean’s retrieve method

Technorati Tags: , , ,

Leave a Reply