Developer

GenericBean class

For beans to be persisted to session variable, it needs to implement the BeanConverterInterface.

Package

com.sybase365.mobiliser.brand.plugins.smapp.beans
Syntax
Syntax
public class GenericBean

Members

All members of GenericBean, including inherited members.

Variables
Modifier and Type Variable Description
public static final String GB_ID Key for the Unique ID Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB0 Key for field 1 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB1 Key for field 2 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB2 Key for field 3 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB3 Key for field 4 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB4 Key for field 5 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB5 Key for field 6 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB6 Key for field 7 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB7 Key for field 8 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB8 Key for field 9 Used for the HashMap input parameter for the parse(HashMap) method.
public static final String GB_ATTRIB9 Key for field 10 Used for the HashMap input parameter for the parse(HashMap) method.
Methods
Modifier and Type Method Description
public int compareTo(GenericBean) Sortable by the unique Id, or GB_ID.
public GenericBean convert(String) Called to transform the session variable value back into this bean.
public String convert(GenericBean) Called to transform the bean into string for persistence to session variable.
public boolean equals(Object)  
public String getAttrib0()  
public String getAttrib1()  
public String getAttrib2()  
public String getAttrib3()  
public String getAttrib4()  
public String getAttrib5()  
public String getAttrib6()  
public String getAttrib7()  
public String getAttrib8()  
public String getAttrib9()  
public String getId()  
public int hashCode()  
public static GenericBean parse(HashMap< String, String >) Domain bean needs to be converted to HashMap, and use this method to transform into this GenericBean.
public void setAttrib0(String)  
public void setAttrib1(String)  
public void setAttrib2(String)  
public void setAttrib3(String)  
public void setAttrib4(String)  
public void setAttrib5(String)  
public void setAttrib6(String)  
public void setAttrib7(String)  
public void setAttrib8(String)  
public void setAttrib9(String)  
public void setId(String)  

Usage

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());