oracle.jheadstart.view.struts
Class DynaBeanReadOnly

java.lang.Object
  extended byorg.apache.struts.action.ActionForm
      extended byorg.apache.struts.action.DynaActionForm
          extended byorg.apache.struts.validator.DynaValidatorForm
              extended byoracle.jheadstart.view.struts.JhsDynaActionForm
                  extended byoracle.jheadstart.view.struts.DynaBeanReadOnly
All Implemented Interfaces:
java.lang.Cloneable, org.apache.commons.beanutils.DynaBean, java.util.Iterator, java.io.Serializable

public class DynaBeanReadOnly
extends JhsDynaActionForm
implements java.util.Iterator

This class extends JhsDynaActionForm and allows you to easily obtain data from the model layer, and display them in your JSP pages using, for example, the <bean:write> tag.

The main advantage of this class is that you do not have to specify the bean and its form properties in the form-beans section in the Struts configuration file. This form-bean configuration information is required when you want to use the Struts facility to populate the bean from the Http Request. Since it is a readOnly bean, we do not need this functionality.

Because of the absence of form-bean configuration information, this class can be instantiated within a JSP page using the old Struts 1.0 way: by calling the default constructor. However, you typically want to enable a DynaBeanReadOnly instance to read data from the model layer, which it can then serve to the JSP page. This can be done by using one of the JHeadstart actions to read data from the model layer, and setting the "readOnlyBean" action mapping property for such an action. The action will then create the DynaBeanReadOnly instance and set the DataObject or DataObjectSet retrieved as a member of the instance. See action classes GetDataObject, GetDataObjectSet, GetSelectedObject and FindDataObjectSet in package oracle.jheadstart.controller.struts.action for more information.

For additional developer convenience, this class implements the Iterator interface, so you can use <logic:iterate> directly on the bean to loop over the contents of the DataObjectSet encapsulated by the bean. Each DataObject instance returned within the <logic:iterate> is in turn wrapped as a new DynaBeanReadOnly instance so you can use <bean:write> within the loop to display the attribute values of each DataObject in the set.

Example usage in JSP Page:

  ..
  <logic:iterate id="departmentBean" name="DepartmentSetBean" indexId="index" 
      type="oracle.jheadstart.view.struts.DynaBeanReadOnly">

    <tr>     
      <td>
         <bean:write name="departmentBean" property='Deptno'/>
      </td>
      <td> 
        <bean:write name="departmentBean" property='Dname'/>
      </td> 
     </tr> 
 
  </logic:iterate>
 ..
 

See Also:
Serialized Form

Field Summary
protected  java.lang.String mName
           
 
Fields inherited from class oracle.jheadstart.view.struts.JhsDynaActionForm
actionAttributes, iteratorRowIndex, mDataObject, mDataObjectSet, mInitialized, mMaxIndex, mPropertyConfigs, mSessionData, mValidationMode, tempRowIndex
 
Fields inherited from class org.apache.struts.validator.DynaValidatorForm
page, validatorResults
 
Fields inherited from class org.apache.struts.action.DynaActionForm
dynaClass, dynaValues
 
Fields inherited from class org.apache.struts.action.ActionForm
multipartRequestHandler, servlet
 
Constructor Summary
DynaBeanReadOnly()
          Default constructor.
 
Method Summary
 boolean contains(java.lang.String p0, java.lang.String p1)
          throws UnsupportedOperationException
 java.lang.Object get(java.lang.String attribute)
          If a DataObject has been set on the bean (using setDataObject()), this method returns the value of an attribute of this DataObject by the name passed into this method.
 java.lang.Object get(java.lang.String attribute, int index)
          If a DataObjectSet has been set on the bean (using setDataObjectSet()), this method returns the value of the specified attribute name for the DataObject at the specified index within the set.
 org.apache.commons.beanutils.DynaClass getDynaClass()
          Method required by DynaBean interface.
 boolean hasNext()
          returns true if we are not yet at the last DataObject in the DataObjectSet.
 java.lang.Object next()
          Get the next DataObject from the DataObjectSet encapsulated by this bean and wrap it as a new instance of DynaBeanReadOnly
 void remove()
          bean is readOnly, throws UnsupportedOperationException.
 void remove(java.lang.String p0, java.lang.String p1)
          bean is readOnly, throws UnsupportedOperationException.
 void reset(org.apache.struts.action.ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
           
 void set(java.lang.String p0, int p1, java.lang.Object p2)
          bean is readOnly, throws UnsupportedOperationException
 void set(java.lang.String p0, java.lang.Object p1)
          bean is readOnly, throws UnsupportedOperationException
 void set(java.lang.String p0, java.lang.String p1, java.lang.Object p2)
          bean is readOnly, throws UnsupportedOperationException
 void setName(java.lang.String name)
          Set the name of the bean
 
Methods inherited from class oracle.jheadstart.view.struts.JhsDynaActionForm
createEmptyArrayList, createStringArray, createStringArray, get, get, getArray, getAttributeForDisplay, getAttributeForDisplay, getConvertedBeanValue, getMap, getMaxIndex, getMetaProperty, getSessionData, initProperties, initPropertyArrays, initPropertyConfigs, resetMaxIndex, setDataObject, setDataObjectSet, setIteratorRowIndex, setSessionData, setValidationMode, toString, validate
 
Methods inherited from class org.apache.struts.validator.DynaValidatorForm
getPage, getResultValueMap, getValidatorResults, log, log, setPage, setValidatorResults
 
Methods inherited from class org.apache.struts.action.DynaActionForm
get, getDynaProperty, initialize, isDynaAssignable, reset
 
Methods inherited from class org.apache.struts.action.ActionForm
getMultipartRequestHandler, getServlet, getServletWrapper, setMultipartRequestHandler, setServlet, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.commons.beanutils.DynaBean
get
 

Field Detail

mName

protected java.lang.String mName
Constructor Detail

DynaBeanReadOnly

public DynaBeanReadOnly()
Default constructor.

Method Detail

contains

public boolean contains(java.lang.String p0,
                        java.lang.String p1)
throws UnsupportedOperationException

Specified by:
contains in interface org.apache.commons.beanutils.DynaBean

get

public java.lang.Object get(java.lang.String attribute)
If a DataObject has been set on the bean (using setDataObject()), this method returns the value of an attribute of this DataObject by the name passed into this method. The attribute value is formatted for display by calling method getAttributeForDisplay.

If a DataObjectSet has been set on the bean (using setDataObjectSet()), this method returns a string array of attribute values, one array entry for each DataObject in the set.

Specified by:
get in interface org.apache.commons.beanutils.DynaBean
Overrides:
get in class JhsDynaActionForm

get

public java.lang.Object get(java.lang.String attribute,
                            int index)
If a DataObjectSet has been set on the bean (using setDataObjectSet()), this method returns the value of the specified attribute name for the DataObject at the specified index within the set.

Specified by:
get in interface org.apache.commons.beanutils.DynaBean
Overrides:
get in class JhsDynaActionForm

getDynaClass

public org.apache.commons.beanutils.DynaClass getDynaClass()
Method required by DynaBean interface. Returns the dummy DynaClassStub class.

Specified by:
getDynaClass in interface org.apache.commons.beanutils.DynaBean

remove

public void remove(java.lang.String p0,
                   java.lang.String p1)
bean is readOnly, throws UnsupportedOperationException.

Specified by:
remove in interface org.apache.commons.beanutils.DynaBean

set

public void set(java.lang.String p0,
                java.lang.Object p1)
bean is readOnly, throws UnsupportedOperationException

Specified by:
set in interface org.apache.commons.beanutils.DynaBean
Overrides:
set in class JhsDynaActionForm

set

public void set(java.lang.String p0,
                int p1,
                java.lang.Object p2)
bean is readOnly, throws UnsupportedOperationException

Specified by:
set in interface org.apache.commons.beanutils.DynaBean
Overrides:
set in class JhsDynaActionForm

set

public void set(java.lang.String p0,
                java.lang.String p1,
                java.lang.Object p2)
bean is readOnly, throws UnsupportedOperationException

Specified by:
set in interface org.apache.commons.beanutils.DynaBean

setName

public void setName(java.lang.String name)
Set the name of the bean


hasNext

public boolean hasNext()
returns true if we are not yet at the last DataObject in the DataObjectSet.

Specified by:
hasNext in interface java.util.Iterator
Overrides:
hasNext in class JhsDynaActionForm

next

public java.lang.Object next()
Get the next DataObject from the DataObjectSet encapsulated by this bean and wrap it as a new instance of DynaBeanReadOnly

Specified by:
next in interface java.util.Iterator
Overrides:
next in class JhsDynaActionForm

remove

public void remove()
bean is readOnly, throws UnsupportedOperationException.

Specified by:
remove in interface java.util.Iterator
Overrides:
remove in class JhsDynaActionForm

reset

public void reset(org.apache.struts.action.ActionMapping mapping,
                  javax.servlet.http.HttpServletRequest request)
Overrides:
reset in class JhsDynaActionForm