return actionMapping.findForwardsuccess; Oracle Fusion Middleware Online Documentation Library

Using Oracle Templates and JSP Tags 7-11 ■ form-jsp.jsp , the name of a JSP that you create to render the table. See Section 7.4.2, Create a Form JSP. 4. Create an org.apache.struts.action.Action class that populates the row beans and table bean. See Example 7–3 . To populate the beans, implement the following method: Action.executeActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse Your implementation should: a. Gather application data from underlying data sources, such as instances of an MBean. b. Create instances of your row bean and populate them by invoking their setters for each property in the bean. c. Assign all of your row bean instances to an ArrayList. d. Cast the empty ActionForm bean table bean as a DynaActionForm bean. e. Set the table beans content property to contain the ArrayList of row beans: DynaActionForm table = DynaActionForm actionForm; table.setcontents,rowBeanArray; f. Put the table bean into the request object that was also passed to the class: httpServletRequest.setAttributetable-bean-name, table; where table-bean-name is the name that you configured for the table bean in the Struts configuration file see Example 7–2 . g. Return success in the ActionMapping.findForward method for the ActionMapping object that was passed to the Action class:

h. return actionMapping.findForwardsuccess;

5. Compile the Action class and save it in a package structure that begins in the root-dirWEB-INFclasses directory. Example 7–3 Example: Action Class that Populates a Row Bean and a Table Bean import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Set; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.MalformedObjectNameException; import javax.naming.InitialContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.DynaActionForm; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; public class RetrieveCustomMBeansAction extends Action { 7-12 Oracle Fusion Middleware Extending the Administration Console for Oracle WebLogic Server public ActionForward executeActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse throws Exception { try { Establish a local connection to the Runtime MBean Server InitialContext ctx = new InitialContext; MBeanServer server = MBeanServer ctx.lookupjava:compenvjmxruntime; Create a name pattern for all MedRec EJB MBeans ObjectName namepattern = new ObjectNamecom.bea.medrec:Type=com.bea.medrec.controller. RecordSessionEJBMBean,; Get all MedRec EJB MBeans for all applications Set objects = server.queryNamesnamepattern, null; Walk through each of these MBeans and get the object name and the value of its TotalRX attribute Iterator i = objects.iterator; while i.hasNext { ObjectName anMBean = ObjectName i.next; String identifier = anMBean.toString; Integer totalRxfromMBean = Integer server.getAttributeanMBean, TotalRx; Instantiate a row bean. MedRecMBeanTableBean row = new MedRecMBeanTableBeananMBean; Set the properties of the row bean row.setCanonicalNameanMBean.getCanonicalName; row.setTotalRxinTableBeantotalRxfromMBean; Add each row bean to an ArrayList result.addrow; } } catch Exception ex { ex.printStackTrace; } Instantiate the table bean DynaActionForm form = DynaActionForm actionForm; Set the array of row beans as the value of the table beans contents property form.setcontents,result; Set the table bean in request. The name of the table bean must match the form-bean name in your Struts configuration file httpServletRequest.setAttributegenericTableForm, form; return actionMapping.findForwardsuccess; } }

7.4 Create JSPs that Use Oracle Templates and JSP Tags