【问题标题】:How to display a clob data more than 66k in text field in oracle forms 12goracle forms 12g如何在文本字段中显示超过66k的clob数据
【发布时间】:2016-07-11 14:53:38
【问题描述】:

我不知道如何将超过 66k 的 clob 数据放入 Oracle Forms 中。

文本字段将采用长数据类型,并且不超过 66k。我有一个clob 数据并想显示。

【问题讨论】:

    标签: oracle size clob oracleforms


    【解决方案1】:

    显示它的最简单方法也是制作表单 bean (PJC)。 然后你可以在足够大的 JTextPane 中显示它。 然后,您可以创建一个函数,从 clob 中为您提供 32000 个字符并将它们提供给 bean。

    package be.axi.oracle.forms.jpc;
    
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import javax.swing.JScrollPane;
    import javax.swing.JTextPane;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.text.BadLocationException;
    import oracle.forms.handler.IHandler;
    import oracle.forms.properties.ID;
    import oracle.forms.ui.CustomEvent;
    import oracle.forms.ui.VBean;
    
    /**
       * A TextArea to get more than 64k texts
       * @author Francois Degrelle
       * @version 1.1
       */
    
    public class BigTextArea extends VBean implements FocusListener, KeyListener
      {
        private static final long serialVersionUID = 1L;
        public final static ID ADDTEXT      = ID.registerProperty("ADD_TEXT");  
        public final static ID VALUE        = ID.registerProperty("VALUE");    
        public final static ID SHOW         = ID.registerProperty("SHOW");        
        public final static ID CLEAR        = ID.registerProperty("CLEAR");
        public final static ID GETTEXT      = ID.registerProperty("GET_TEXT");    
        public final static ID GETLENGTH    = ID.registerProperty("GET_LENGTH");        
        public final static ID pLostFocus   = ID.registerProperty("BEAN_QUITTED");  
    
        private   IHandler  m_handler;  
        private   int iStart      = 0 ;
        private   int iChunk      = 8192 ;
        private   StringBuffer sb = new StringBuffer(); 
        protected JTextPane     jtp = new JTextPane();
    
        public BigTextArea()
        {
           super();
            try
            {
              UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              SwingUtilities.updateComponentTreeUI(this);
            }
            catch (Exception ex)
            {
              ex.printStackTrace();
            }        
           JScrollPane ps = new JScrollPane(jtp);
           ps.setBorder(null);
           add(ps);
           ps.setVisible(true);
        }
    
    
        public void init(IHandler handler)
        {
          m_handler = handler;
          super.init(handler);
          addFocusListener(this);
          jtp.addFocusListener(this);
          jtp.addKeyListener(this);
        }      
    
    
        public boolean setProperty(ID property, Object value)
        {
          // 
          // add text to the TextArea
          //
          if (property == ADDTEXT)
          {
            sb.append(value.toString()) ;
            printMemory();
            return true;
          }
          //
          // display the whole text
          //
          else if(property == SHOW)
          { 
            jtp.setText(sb.toString());
            jtp.setCaretPosition(0);
            sb = new StringBuffer(); 
            System.gc();
            printMemory();
            return true ;
          }
          //
          // clear the TextArea
          //
          else if(property == CLEAR) {
            jtp.setText("");
            return true ;
          }
          else
          {
            return super.setProperty(property, value);
          }
        }
    
        /*-----------------------------------*
         * Get the result string from Forms  *
         *-----------------------------------*/
        public Object getProperty(ID pId)
        {
          //
          // returns the text length
          //
          if (pId == GETLENGTH)
          {
            return "" + jtp.getText().length();
          }
          //
          // returns the chunks
          //
          else if (pId == GETTEXT) {
              String s = "" ;
              int iLen = jtp.getText().length() ;
              while (iStart < iLen)
              {
                try{
                  if(iStart+iChunk <= iLen) s = jtp.getText(iStart,iChunk);
                  else s = jtp.getText(iStart,iLen-iStart);
                  iStart += iChunk ;
                  return s ;
                }
                catch (BadLocationException ble) { ble.printStackTrace(); return ""; }
              }
              iStart = 0 ;
              return "" ;
          }
          else
          {
            return super.getProperty(pId);
          }
        } // getProperty()
    
    
         /*--------------------------*
          * handle the focus events  *
          *--------------------------*/
         public void focusGained(FocusEvent e)
          {
              if (e.getComponent() == this)
              {
                  // put the focus on the component
                  jtp.requestFocus();
              }
    
              try
              {
                  m_handler.setProperty(FOCUS_EVENT, e);
              }
              catch ( Exception ex )
              {
                ;
              }
          }
    
         public void focusLost(FocusEvent e)
          {     
            CustomEvent ce = new CustomEvent(m_handler, pLostFocus);
            dispatchCustomEvent(ce);        
          }
    
         /*--------------------------*
          * Handle the Key listener  *
          *--------------------------*/
         public void keyPressed(KeyEvent e)
         {
             /*
             ** Allows TAB key to exit the item
             ** and continue the standard Forms navigation
             */
             if ( (e.getKeyCode() == KeyEvent.VK_TAB) )
             {
                 try
                 {
                     m_handler.setProperty(KEY_EVENT, e);
                 }
                 catch ( Exception ex )
                 {
                 }
             }
         }
    
    
         public void keyTyped(KeyEvent e)
         {
         }
    
         public void keyReleased(KeyEvent e)
         {
         }
    
    
        // utility to output the memory available
        private void printMemory() {
            System.out.println("Java memory in use = " 
            + (Runtime.getRuntime().totalMemory() 
            - Runtime.getRuntime().freeMemory()));
        }
    
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-23
      • 1970-01-01
      相关资源
      最近更新 更多