如何解决Oracle 18c APEX中的apex.ajax.clob错误?

时间:2019-02-27 09:59:56

标签: oracle oracle-apex oracle-apex-5.1 oracle18c

我正在尝试在地图控件中显示图钉,并且在旧主题4.2中使用了以下代码,并且运行正常。但是使用新的APEX主题,我得到apex.ajax.clob不是构造函数错误

function refreshMap() 
{
  var gData;
  var clob_ob = new apex.ajax.clob
  (  
function()
{
  var rs = p.readyState  
  if(rs == 4)
  {
    gData = p.responseText;
    if(gData.length == 0)
    {
      alert("No task found.");
      return;
    }
    if(gData=='-1')
    {
      alert("Data too large to be displayed. Filter task by type or select smaller date range.");
      return;
    }
  }
  if(gData)
  {
    var actArray = gData.split("~#~");
    var bounds = new google.maps.LatLngBounds();
    for(var i=0; i < actArray.length; i++) 
    {
      acct = ""+actArray[i];
      var colArray = acct.split("~@~");
      var repStatus = colArray[5];
      var link = '<b><u><a href="'+colArray[7]+'">'+colArray[2]+'</a></u></b>';
      var html = '<table><tr><td style="font-weight: bold; font-size: 175%;">'+colArray[3]+'</td></tr></table><table><tr><td>&nbsp;</td></tr><tr><td><b>Task # : </b>&nbsp;</td><td>'+link+'</td></tr><tr><td align="left"><b>Subject : </b>&nbsp;</td><td>'+colArray[4]+'</td></tr><tr><td align="left"><b>Status :   </b>&nbsp;</td><td>'+repStatus+'</td></tr></table>';
      var newmarker = new google.maps.Marker({
          position: new google.maps.LatLng(colArray[0], colArray[1]),
          map: map,
          //title: html,
          icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|'+colArray[8]
      });

      newmarker['infowindow'] = new google.maps.InfoWindow({
              content: html
          });

      google.maps.event.addListener(newmarker, 'click', function() {
          this['infowindow'].open(map, this);
      });

      marker.push(newmarker);
                bounds.extend(new google.maps.LatLng(colArray[0], colArray[1]));
    } 
    map.fitBounds(bounds);
  }
});  
clob_ob._get();
}

2 个答案:

答案 0 :(得分:0)

apex.ajax.clob已过时,并移至legacy_18.js(至少在18.2中)。要遵循该示例,您必须包括/i/libraries/apex/legacy_18.js。可以在Javascript-> File URLs框中逐页完成此操作。

答案 1 :(得分:0)

我知道这是一篇很老的文章,但是我在遇到相同问题并寻求解决方案时发现了它。由于这是第一个在Google上为我显示的链接,因此找到解决方案后,我决定在此处共享代码以供将来参考。

您需要根据情况调整此代码,因此请以它为例,说明如何在不依赖旧版javascript的情况下解决此问题。

在此示例中,我有一个CLOB,其中包含HTML源代码(接受少量参数),并且需要在页面加载时将其显示在区域中。

首先,您创建一个AJAX回调流程(我们将此流程称为 HTML

DECLARE
  l_clob        CLOB;
  l_file        BLOB;
  l_dest_offset PLS_INTEGER := 1;
  l_src_offset  PLS_INTEGER := 1;
  l_lang_ctx    PLS_INTEGER := dbms_lob.default_lang_ctx;
  l_blob_warn   PLS_INTEGER;
BEGIN

  -- Get clob
  l_clob := functionReturningClob(i_code => :P1_CODE, i_type => :P1_TYPE);

  -- Create blob
  DBMS_LOB.CREATETEMPORARY(l_file, true);
  DBMS_LOB.CONVERTTOBLOB(l_file, l_clob, dbms_lob.lobmaxsize, l_dest_offset, l_src_offset, dbms_lob.default_csid, l_lang_ctx, l_blob_warn);

  -- Download blob
  OWA_UTIL.MIME_HEADER('text/html', false);
  HTP.P('Content-Length: ' || dbms_lob.getlength(l_file));
  HTP.P('Content-Disposition: attachment; filename="content.html"');
  OWA_UTIL.HTTP_HEADER_CLOSE();
  WPG_DOCLOAD.DOWNLOAD_FILE(l_file);

END;

通过这种方式,我可以根据需要调用此方式。出于我的目的,我进入了页面-“页面加载时执行Javascript”,其中包含以下代码。

// Start the process called HTML and add the following page items as parameter
var p = apex.server.process('HTML', {
  pageItems:['P1_CODE', 'P1_TYPE']
}, {
  dataType: 'html'
});

// When the process is done, replace the region HTML with the downloaded HTML source
// Also - the region on the page has the "region" as its static ID
p.done(function(data) {
  $('#region').html(data);
});

这应该为您提供足够的信息来进行您自己的调整并使其生效。