/*
 * @(#)OrdContentTypeBoundValue.java
 *
 * Copyright 2001-2002 by Oracle Corporation,
 * 500 Oracle Parkway, Redwood Shores, California, 94065, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Oracle Corporation.
 */

package oracle.jbo.html.jsp.blaf;

import javax.servlet.jsp.PageContext;
import oracle.cabo.ui.RenderingContext;
import oracle.cabo.ui.data.DataObject;
import oracle.cabo.ui.data.BoundValue;
import oracle.jbo.html.DataSource;
import oracle.jbo.Row;
import oracle.ord.common.PropertyConstants;
import oracle.ord.im.OrdDomainIOInterface;

public class OrdContentTypeBoundValue implements BoundValue
{
  private String m_attrName;
  private String m_dsName;  //DataSource name
  private PageContext m_pageContext;

  public OrdContentTypeBoundValue(String attrName, 
                                  String dsName,
                                  PageContext pageContext
                                  )
  {
    this.m_attrName = attrName;
    this.m_dsName = dsName;
    this.m_pageContext = pageContext;
  }
  
  public Object getValue(RenderingContext context)
  {
    DataObject source = 
      (DataObject) m_pageContext.getAttribute(m_dsName + "uix");

    Row row = (Row)source.selectValue(context, 
                                      PropertyConstants.ORD_UIX_JSP_SELECT_ROW);
    Object domain = row.getAttribute(m_attrName);

    String contentType = null;
    try
    {
      contentType = ((OrdDomainIOInterface)domain).getMimeType();
    }catch(Exception e) 
    {
      contentType = null;
    }

    return contentType;
  }
}
