For beans to be persisted to session variable, it needs to implement the BeanConverterInterface.
So typically, like in the dynamic SMS menu that extends the AbstractDynamicMenu, a helper bean that implements the BeanConverterInterface is created. The bean (i.e., domain bean) is transformed to the helper bean and then serialize.
When domain bean is simple, containing fields of String type only, this helper GenericBean can be used instead of creating a custom bean. This bean contains a unique ID field, and 10 (0..9) properties.
Simple example of how to store list of GenericBean into session variable:
List beanList = new ArrayList<GenericBean>(); for (DomainObject dObj: domainObjList) { // Convert domain object to HashMap HashMap<String, String> objMap = convertDomainObjToMap(dObj); beanList.add(GenericBean.parse(objMap)); } // Store the list into session variable SessionVariableAttribute SessionVariableAttribute session = new SessionVariableAttribute("SESSION_LIST", ""); session.setList(beanList);
To retrieve the list from session variable and convert back to GenericBean:
List beanList = new ArrayList<GenericBean>(); // Session variable defined earlier beanList = session.getList(new GenericBean());