/**********************************************************************************
* $URL$
* $Id$
***********************************************************************************
*
* Copyright (c) 2004-2005 The Regents of the University of Michigan, Trustees of Indiana University,
*                  Board of Trustees of the Leland Stanford, Jr., University, and The MIT Corporation
*
* Licensed under the Educational Community License Version 1.0 (the "License");
* By obtaining, using and/or copying this Original Work, you agree that you have read,
* understand, and will comply with the terms and conditions of the Educational Community License.
* You may obtain a copy of the License at:
*
*      http://cvs.sakaiproject.org/licenses/license_1_0.html
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**********************************************************************************/

package org.sakaiproject.tool.assessment.ui.listener.delivery;

import java.util.HashMap;
import java.util.Iterator;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.sakaiproject.tool.assessment.facade.AgentFacade;
import org.sakaiproject.tool.assessment.facade.PublishedAssessmentFacade;
import org.sakaiproject.tool.assessment.services.GradingService;
import org.sakaiproject.tool.assessment.services.assessment.PublishedAssessmentService;
import org.sakaiproject.tool.assessment.ui.bean.delivery.DeliveryBean;
import org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean;
import org.sakaiproject.tool.assessment.ui.bean.delivery.SectionContentsBean;
import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil;

/**
 * <p>Title: Samigo</p>
 * <p>Purpose:  When student makes a recording for an audio question type
 * the audio recorder applet makes a copy of the local recording and posts it
 * to a special servlet,
 * @see org.sakaiproject.tool.assessment.ui.servlet.delivery.UploadAudioMediaServlet,
 *  that copies it to a designated file on the server.
 * When that student then posts the answer by pressing the Update button, the
 * actual grading record is made.
 * </p>
 * <p>Description: Sakai Assessment Manager</p>
 * <p>Copyright: Copyright (c) 2004 Sakai Project</p>
 * <p>Organization: Sakai Project</p>
 * @author Ed Smiley
 * @version $Id$
 */

public class AudioUploadActionListener implements ActionListener
{
  private static Log log = LogFactory.getLog(AudioUploadActionListener.class);
  private static ContextUtil cu;

  /**
   * ACTION.
   * @param ae
   * @throws AbortProcessingException
   */
  public void processAction(ActionEvent ae) throws
    AbortProcessingException
  {
    log.info("AudioUploadActionListener.processAction() ");

    try {
      // get managed bean
      DeliveryBean delivery = (DeliveryBean) cu.lookupBean("delivery");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

}

@@ -1399,15 +1399,12 @@
 til.
-HashMap
+List
 ;%0Aim
@@ -1416,22 +1416,37 @@
 java
-.util.Iterator
+x.faces.component.UIComponent
 ;%0Aim
@@ -1704,473 +1704,33 @@
 ent.
-facade.AgentFacade;%0Aimport org.sakaiproject.tool.assessment.facade.PublishedAssessmentFacade;%0Aimport org.sakaiproject.tool.assessment.services.GradingService;%0Aimport org.sakaiproject.tool.assessment.services.assessment.PublishedAssessmentService;%0Aimport org.sakaiproject.tool.assessment.ui.bean.delivery.DeliveryBean;%0Aimport org.sakaiproject.tool.assessment.ui.bean.delivery.ItemContentsBean;%0Aimport org.sakaiproject.tool.assessment.ui.bean.delivery.SectionContents
+ui.bean.delivery.Delivery
 Bean
@@ -1800,16 +1800,55 @@
 extUtil;
+%0Aimport javax.faces.component.UIOutput;
 %0A%0A/**%0A *
@@ -2703,16 +2703,69 @@
 param ae
+ the action event triggering the processAction method
 %0A   * @t
@@ -3053,16 +3053,933 @@
 ivery%22);
+%0A%0A      // now find what component fired the event%0A      UIComponent component = ae.getComponent();%0A      // get the subview containing the audio question%0A      UIComponent parent = component.getParent();%0A%0A      // get the its peer components from the parent%0A      List peers = parent.getChildren();%0A%0A      // we're looking for the correct file upload%0A      // we are using debugging code for now.%0A      for (int i = 0; i %3C peers.size(); i++)%0A      %7B%0A        UIComponent peer = (UIComponent) peers.get(i);%0A        log.info(%22Component i: %22 + i);%0A        log.info(%22peer.getId(): %22 + peer.getId());%0A        log.info(%22peer.getFamily(): %22 + peer.getFamily());%0A        log.info(%22peer.getClass().getName(): %22 + peer.getClass().getName());%0A        if (peer instanceof UIOutput)%0A        %7B%0A          String value = %22%22 + ((UIOutput) peer).getValue();%0A          log.info(%22peer is UIOutput: value = %22 + value);%0A        %7D%0A      %7D%0A%0A
 %0A    %7D c

add logic to traverse firing component's component tree