Inserting blockquote tags into a HTMLDocument

G'Day,
I'm having a bit of trouble inserting <blockquote> tags into a HTMLDocument.
Basically I want the blockquote tags to implement an indent feature. ie, you click a button and all the text in the current paragraph gets surrunded by blockquote tags, which when rendered makes it indent.
The code I'm using is:
Element current = doc.getParagraphElement(pos);
try
doc.insertBeforeStart(current, "<blockquote>");
doc.insertAfterEnd(current, "</blockquote>");
catch (Exception e)
lets say we have html like this:
<p>
hello
</p>
when this code runs, i get:
<blockquote>
</blockquote>
<p>
hello
</p>
I think that when I do the insertBeforeStart and insert the opening tag, after that completes the document is rendered and the end tag is put in there automatically???
So, can anyone help me out here and suggest a better way?
Cheers,
Leighton.

I've been trying to get <blockquote> insert working in an editor but it seems to be a quite difficult task even if it's only about inserting a couple of tags into the right slot! This is the closest I got:
HTMLDocument doc = (HTMLDocument)editor.getDocument();
int start = editor.getCaretPosition()
int paraStart = doc.getParagraphElement(start).getStartOffset();
int paraEnd = doc.getParagraphElement(start).getEndOffset();
String insideBlockQuotes = doc.getText(paraStart, paraEnd - paraStart);
doc.setOuterHTML(doc.getParagraphElement(start),"<blockquote><p>"+insideBlockQuotes+"</p></blockquote>");
This is how it works: Get the current paragraphs start and end positions, read the text between the start and end into a string, replace the paragrapElement with <blockquote><p>..the text from string..</p></blockquote>.
This works 'in about' but it's far from perfect.. it has the following problems:
1. It looses all formatting from the quoted paragraph (bold etc. tags from the quoted part)
2. It assumes that the paragraphElement was a <p> (could have been another element too!)
3. It's ugly
Anybody come up with a better way to use blockquote?

Similar Messages

  • Inserting custom HTML tags into a HTMLDocument to be displayed in a JEditor

    Does anyone know how to insert custom tags into a HTMLDocument to be displayed in a JEditorPane?
    I have tried using the following code,
    kit.insertHTML( doc,
                    jep.getCaretPosition(),
                    "<testtag>FFFF</testtag>",
                    0,
                    0,
                    new HTML.UnknownTag("testtag") );When the above code is run the handleStartTag, handleEndTag and handleText methods are called on the HTMLReader but nothing is inserted into the document model? Can anyone help?
    I have created an instance of HTML.UnknownTag,
      public static HTML.Tag testTag = new HTML.UnknownTag("testtag");I have subclassed HTMLEditorKit and overridden the getParser() method,
      protected Parser getParser(){
        DTD dtd = null;
        try {
          dtd = createDTD( DTD.getDTD("html32"), "html32" );
        } catch ( Exception e ) {
          e.printStackTrace();
        dtd.getElement( "testtag" );
        Parser p = new ParserAdaptor( new DocumentParser( dtd ) );
        return p;
      }I have subclassed HTMLDocument and HTMLDocument.HTMLReader and created a TagAction for my new tag.
    The following code works fine, the custom tag is in the document model,
        String contents =    "<html>"
                           + "<body>"
                           + "<testtag>Here is some text</testtag>"
                           + "</body>"
                           + "</html>";
        ((HTMLDocument)jep.getDocument()).setPreservesUnknownTags(true);
        jep.setText( contents );

    I've been trying to get <blockquote> insert working in an editor but it seems to be a quite difficult task even if it's only about inserting a couple of tags into the right slot! This is the closest I got:
    HTMLDocument doc = (HTMLDocument)editor.getDocument();
    int start = editor.getCaretPosition()
    int paraStart = doc.getParagraphElement(start).getStartOffset();
    int paraEnd = doc.getParagraphElement(start).getEndOffset();
    String insideBlockQuotes = doc.getText(paraStart, paraEnd - paraStart);
    doc.setOuterHTML(doc.getParagraphElement(start),"<blockquote><p>"+insideBlockQuotes+"</p></blockquote>");
    This is how it works: Get the current paragraphs start and end positions, read the text between the start and end into a string, replace the paragrapElement with <blockquote><p>..the text from string..</p></blockquote>.
    This works 'in about' but it's far from perfect.. it has the following problems:
    1. It looses all formatting from the quoted paragraph (bold etc. tags from the quoted part)
    2. It assumes that the paragraphElement was a <p> (could have been another element too!)
    3. It's ugly
    Anybody come up with a better way to use blockquote?

  • Insert BASE tag into HTMLDocument problem

    Hi,
    I've made a prog that read the HTML content from an URL, and write it into a file. But before writing it, I'd like to change the content to add <BASE href="http://www.site.com"></BASE> into the head part of the HTMLDocument. In my prog, I've made a insertBeforeEnd(...) to insert the <BASE> tag, but it's not inserted. I've made another insertBeforeEnd(...) to insert "hello world" (just for test) and it's inserted into the HTMLDocument. Can someone help me ? thanks a lot.
    My prog :
    import java.io.*;
    import java.net.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    public class InsertIntoHTML {
       public static void main(String[] args) {
          URL                  url = null;
          HttpURLConnection      conn;
          HTMLEditorKit         htmlKit;
          HTMLDocument         htmlDoc;
          InputStream            in;
          Element               head;
          boolean               ignoreCharSet = true;
          htmlKit = new HTMLEditorKit();
          htmlDoc = new HTMLDocument();
          try {
             url = new URL("http://www.google.com/");
          catch (java.net.MalformedURLException e) {}
          htmlDoc.putProperty(Document.StreamDescriptionProperty, url);
          htmlDoc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
          // read www.yahoo.com into HTML document
          try {
             conn = (HttpURLConnection) url.openConnection();
             in = conn.getInputStream();
             Reader reader = new InputStreamReader(in);
             Class c = Class.forName("javax.swing.text.html.parser.ParserDelegator");
             HTMLEditorKit.Parser parser = (HTMLEditorKit.Parser) c.newInstance();
             htmlDoc.setParser(parser);
             HTMLEditorKit.ParserCallback htmlReader = htmlDoc.getReader(0);
             parser.parse(reader, htmlReader, ignoreCharSet);
             htmlReader.flush();
          catch (javax.swing.text.BadLocationException ex) {}
          catch (java.lang.ClassNotFoundException e) {}
          catch (java.lang.InstantiationException e) {}
          catch (java.lang.IllegalAccessException e) {}
          catch (java.io.IOException e) {}
          htmlDoc.setBase(url);
          // find <HEAD> tag into HTML document
          head = getHeadElement(htmlDoc);
          try {
             // insert <BASE> tag into <HEAD> element
             htmlDoc.insertBeforeEnd(head, "<BASE href=\"http://www.google.com/\"></BASE>");
             htmlDoc.insertBeforeEnd(head, "Hello world !");
          catch (javax.swing.text.BadLocationException e) {}
          catch (java.io.IOException e) {}
          // write HTML document into file named yahoo.html      
          try {
             htmlKit.write(new FileOutputStream(new File("google.html")), htmlDoc, 0, htmlDoc.getLength());
          catch (java.io.FileNotFoundException e) {}
          catch (java.io.IOException e) {}
          catch (javax.swing.text.BadLocationException e) {}
       // Find first element into HTML document equals to tag parameter
       public synchronized static final Element findElement(Element root, HTML.Tag kind) {
          if(root == null) return(null);
          if(matchElementType(root, kind)) {
             return(root);
          int count = root.getElementCount();
          if(count > 0) {
             for(int i = 0 ; i<count ; i++) {
                Element child = root.getElement(i);
                Element e = findElement(child, kind);
                if(e != null)
                   return(e);
       return(null);
       public synchronized static final boolean matchElementType(Element e, HTML.Tag kind) {
          return(e.getAttributes().getAttribute(StyleConstants.NameAttribute) == kind);
       // Find HEAD element into HTML document
       public synchronized static final Element getHeadElement(HTMLDocument doc) {
          return(findElement(doc.getRootElements()[0], HTML.Tag.HEAD));

    first, thanks dvorhra09 for your help. unfortunately, if I use &lt; and &gt; instead of '<' and '>', the <BASE> tag is no more interpreted by my browser when the file is loaded, and the <BASE> tag is displayed textually. below, is what I tested :
    htmlDoc.insertBeforeEnd(head, "&lt;BASE href=\"http://www.google.com/\"&gt;&lt;/BASE&gt;");

  • Insert Encoding tag into xml file. ?xml version="1.0"?

    I am using oracle 10g.
    I am using dbms_xmlgen.getxml function to generate xml data for oracle tables. I use utl_file to write data back into xml file.
    Oracle is generating the file in the following manner...
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <RSLT_ID>1</RSLT_ID>
    </ROW>
    </ROWSET>
    I want to change the following xml header to have encoding information in it as follows...
    <?xml version="1.0" encoding = "AL32UTF8"?>
    How do I achieve that?
    Any suggestions?

    I want to change the following xml header to have encoding informationIn 10g I think you could use a xmlroot hack:
    SQL> select xmlroot(xmlelement(e, dummy), version '1.0" encoding="AL32UTF8') xml from dual
    XML                                                    
    <?xml version="1.0" encoding="AL32UTF8"?>              
    <E>X</E>                                               
    1 row selected.

  • Do I need to insert meta tags on domain if it redirects to web.mac page?

    Hi,
    I've set up a domain (http://www.blossomsolutions.ca) with Internic.ca in Canada and filled out a very easy form to redirect to http://web.mac.com/blossomsolutions. Through this excellent forum I learned how to insert meta tags into all my pages on the web.mac site using text edit successfully.
    Now, I'm wondering, will search engines find me if I have "no code" or meta tags at www.blossomsolutions.ca? Internic is only "redirecting" my URL not hosting it. It costs more money if they "host" my domain and I wouldn't have a clue how to set up an index.html page anyway for this domain. Even if I got someone to do this can you redirect an index.html page from blossomsolutions.ca to a web.mac.com page? i.e. does the domain code need to be empty in order for it to redirect?
    Thanks to anyone who can help me with this.
    Dazed and confused,
    Kathleen
    iMAC 2.16GHz 20"   Mac OS X (10.4.10)  
    iMac   Mac OS X (10.4.10)  
    iMac   Mac OS X (10.4.10)  
    iMac   Mac OS X (10.4.10)  

    Hello Kathleen,
    Welcome to the forum. You're site looks very clean and elegant.
    The domain name you purchased (http://www.blossomsolutions.ca/) is serving as a redirecting page to your iWeb generated web page. The answer to whether or not search engines will find you is both yes and no. Search engines use programs called "spiders" that find pages through links and trace out web pages.
    Given some time, sites like Google and MSN will likely find you website (and if you put meta tags in it will display that info in the search engine). But if you are like most iWeb users (myself included) you are impatient for your site to be picked up in search engines. Which is fine, since several search engines provide the means for you to submit your URL. Read this post for more information. http://discussions.apple.com/thread.jspa?messageID=3905977&#3905977
    Looks like you may have already submitted your .mac page.
    Another handy tip for looking up what information a search engine posses on your site is to type "site:" followed by the web address you wish to look up into a search engine. If the search engine has any of the pages to your site it will display them with the meta data they posses. Your site info can be found here. http://www.google.com/search?q=site:http://web.mac.com/blossomsolutions
    I checked your .ca address and google didn't come up with anything.
    Internic.ca should provide you with the means to apply a little bit of a description to your web address. Apart from that, you can't really add any meta data to the domain name.
    Unfortunately even when you get both web addresses picked up by search engines it won't associate them together. They may come up near each other in searches. But the search engine will see them as entirely different sites.
    You could host your site at the domain name if you chose to. The process of publishing is one click like to .mac. But you "Publish to a Folder" and then upload the complete page to the domain name. Its more difficult and cost more (if you chose to retain your .mac account) but it would give you better search engine rankings for your name.
    —"It costs more money if they "host" my domain and I wouldn't have a clue how to set up an index.html page anyway for this domain. Even if I got someone to do this can you redirect an index.html page from blossomsolutions.ca to a web.mac.com page? i.e. does the domain code need to be empty in order for it to redirect?"
    It isn't really worth it have them host your domain name only to put an index.html that redirects to your .mac. Thats basically what the domain forwarding is doing (minus a little bit of info).
    My advice is to keep things how you have them. But, just make sure you get the domain submitted to search engines.
    Hope this wasn't to long or confusing.
    Kind Regards,
    —Eric
    Ash Films
    (see my profile if you want to see my site)

  • Insert HTML Page into XML CDATA Tag

    Hi Guy
    I have a very big problem.
    I create a little web site and I use XSL + XML to produce output.Now I
    want to add a part of html page into xml tag to use a custom page section.
    But i find a problme,
    see the example :
    I use this xml :
    <resources>
    <html><![CDATA[<B>Hello World</B>]]></html>
    </resources>
    trasform xml with xsl page
    and my output into html browser is (&lt);B(&gt);Hello World(&lt);/B(&gt);(please remove the bracket( ) while reading the text to understand my problem)
    my BOLD html tag is not parse by browser because xslt parser trasform
    my special tag into other tag.
    I want output like this:
    <b>Hello World</b>
    But it's coming like (&lt);B(&gt);Hello World(&lt);/B(&gt); (please remove the bracket( ) while reading the text to understand my problem)
    Can you help me ?
    this is my trasformation function :
    private Transformer getXSLTransformer (xslFile) throws
    XSLTransformerConfigurationException {
    try {
    Transformer transformer = null;
    tFactory = TransformerFactory.newInstance();
    transformer = tFactory.newTransformer(new
    StreamSource(xslFile)); // load xslFile from disk
    } catch (TransformerConfigurationException tce) {
    throw new XSLTransformerConfigurationException(tce.getMessage());
    return transformer;
    public String myTrasform(String xml,String xslFile) throws Exception {
    StringWriter outputString = new StringWriter(512);
    Transformer transformer = getXSLTransformer (xslFile);
    transformer.transform(new StreamSource(new StringReader(xml)), new
    StreamResult(outputString));
    return outputString.toString();
    Thank's in advance.
    kuruvi
    Edited by: Mc_Kuruvi on Jun 14, 2009 3:47 AM

    Read:
    Oracle® XML DB
    Developer's Guide
    10g Release 1 (10.1)
    Part No. B10790-01
    December 2003
    1. "Do I use sqlloader and what datatype?"
    Use XMLType
    2. "I have embedded graphics so do the images get stored separately or does the entire page get stored as a BLOB datatype?"
    Page 827:
    The Oracle XML DB native datatype XMLType helps store and manipulate XML. Multiple storage options (Character Large Object (CLOB) or structured XML) are available with XMLType, and administrators can choose a storage that meets their requirements. CLOB storage is an un-decomposed storage that is like an image of the original XML.

  • Tab inserting blockquote

    I just installed DW on a new laptop and I can't remember
    where I need to change the setting so that when I am in a list item
    - I can hit the tab key (or click the indent button) and the
    current list item becomes a new list under the preceding list item.
    I.E. if I have the following:
    <li><a
    href="#request.localpath#contact.cfm">CONTACT</a></li>
    <li><a
    href="#request.localpath#links.cfm">LINKS</a></li>
    <li><a
    href="#request.localpath#showSchedule.cfm">EVENTS</a></li>
    And I am on the second line item and hit the tab key - it
    used to do this...
    <li><a
    href="#request.localpath#contact.cfm">CONTACT</a>
    <ul>
    <li><a
    href="#request.localpath#links.cfm">LINKS</a></li>
    </ul>
    </li>
    <li><a
    href="#request.localpath#showSchedule.cfm">EVENTS</a></li>
    Now it does this:
    <li><a
    href="#request.localpath#contact.cfm">CONTACT</a></li>
    <li><a href="#request.localpath#links.cfm">
    <blockquote> </blockquote>
    LINKS</a></li>
    <li><a
    href="#request.localpath#showSchedule.cfm">EVENTS</a></li>
    What's up with that ? I have never seen it do that to me
    before.
    Thanks all.
    Chris

    I've been trying to get <blockquote> insert working in an editor but it seems to be a quite difficult task even if it's only about inserting a couple of tags into the right slot! This is the closest I got:
    HTMLDocument doc = (HTMLDocument)editor.getDocument();
    int start = editor.getCaretPosition()
    int paraStart = doc.getParagraphElement(start).getStartOffset();
    int paraEnd = doc.getParagraphElement(start).getEndOffset();
    String insideBlockQuotes = doc.getText(paraStart, paraEnd - paraStart);
    doc.setOuterHTML(doc.getParagraphElement(start),"<blockquote><p>"+insideBlockQuotes+"</p></blockquote>");
    This is how it works: Get the current paragraphs start and end positions, read the text between the start and end into a string, replace the paragrapElement with <blockquote><p>..the text from string..</p></blockquote>.
    This works 'in about' but it's far from perfect.. it has the following problems:
    1. It looses all formatting from the quoted paragraph (bold etc. tags from the quoted part)
    2. It assumes that the paragraphElement was a <p> (could have been another element too!)
    3. It's ugly
    Anybody come up with a better way to use blockquote?

  • How can i create and paste my own tags into source page of a html editor

    I download ekit and try to customize.
    I wrote a similar code:
    TagEditor extends HTML
    , and inner class:
    ExtendedTag extends Tag
    by following similar structure with javax.swing.text.html
    I added my own tags into tagList in HTMLUtilities class which is in com.hexidec.ekit.component. Because it is initialized three times when i run the program.
    I add a button to multitoolbar, and wrote a insertMyTag method in class EkitCore:
    private void insertMyTag() throws IOException, BadLocationException, RuntimeException {
    int caretPos = jtpMain.getCaretPosition();
    // htmlKit.insertHTML(htmlDoc, caretPos, "<VAZIFE>", 0, 0, TagEditor.ExtendedTag.VAZIFE);
    jtpMain.setText("<HTML><BODY><VAZIFE></BODY></HTML>");
    jtpSource.setText(jtpMain.getText());
    jtpMain.setText does display in the source editor but the default HTMLEditorKit creates the unkown tags and inserts them into the html view output with box-like borders. I want to keep the tags in the source but remove them from the output view so the user only sees the normal HTML output and my app sees the XML tags.
    What do I need to do in insertMyTag to turn off the strange display of
    unknown tags? Is there an easier way to do this?
    Thanks

    Or, take a ScreenHunter image of the list and email that to yourself.

  • How can I use multiple row insert or update into DB in JSP?

    Hi all,
    pls help for my question.
    "How can I use multiple rows insert or update into DB in JSP?"
    I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
    With thanks,

    That isn't true. Different SQL databases have
    different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
    I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
    and there are also a lot of different ways of talking to
    SQL databases that are possible in JSP, from using
    plain old java.sql.* in scriptlets to using the
    jstlsql taglib. I've done maintenance on both, and
    they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
    Well, sure. As long as you only want to update rows
    with the same value in column 2. I had the impression
    he wanted to update a whole table. If he only meant
    update all rows with the same value in a given column
    with the same value, that's trivial. All updates do
    that. But as far as I know there's know way to update
    more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
    Unless you're using MySQL, for instance. I only have
    experience with MySQL and M$ SQL Server, so I don't
    know what PostgreSQL, Oracle, Sybase, DB2 and all the
    rest are capable of, but I know for sure that MySQL
    can insert multiple rows while SQL Server can't (or at
    least I've never seen the syntax for doing it if it
    does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
    Don't assume that all SQL databases are the same.
    They're not, and it can really screw you up badly if
    you assume you can deploy a project you've developed
    with one database in an environment where you have to
    use a different one. Even different versions of the
    same database can have huge differences. I recommend
    you get a copy of the O'Reilly book, SQL in a
    Nutshell. It covers the most common DBMSes and does a
    good job of pointing out the differences.Yes, I understand that.
    It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
    I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
    The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing.

  • Inserting a Value into otherTable using an App. Proc. from a Date Picker

    I'm trying to call an Application Process that will insert an Attribute of a Row, into another table, after selecting a date from a Date Picker cell.
    I don't know why this shouldn't be possible. I think I've got all of my "Ducks in a Row", so to speak,
    but the Value that is being inserted into the other table is this:.. [object HTMLTableCellElement]
    (Ultimately, I'd like my Application Process to include Page element values with the insert as well, but I'm trying to handle one problem at a time)
    Here's a list of all the steps I've covered:
    1. I've Created an Application Process, (popDevices). The Process Point is "On-Demand". The Type is "PL/SQL Anonymous Block".
    The Process is defined as such:
    BEGIN
    Insert into P_DEVICES
    NAME,
    IP_ADDRESS,
    MODEL
    ) values
    'Unassigned',
    'Unassigned',
    :P153_MODEL
    COMMIT;
    END;
    2. I've Included the Javascript in the Page HTML Header.
    The Javascript is written as such: (minus the tags)
    function popDevices(PART_NO)
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=popDevices',0);
    get.add('P153_MODEL',PART_NO);
    gReturn = get.get();
    get = null;
    3. I've included the following in the "Element Attributes" field of the Date-Picker Item (Date_Delivered).
    The Region Type is "SQL Query (Updatable Report)"
    onChange="javascript:popDevices(PART_NO);"
    THE RESULTS
    A. A row does get inserted into the other (P_Devices) table,
    But the value of the Attribute from the Page Region is not valid.
    The Inserted value is this: [object HTMLTableCellElement]
    B. I have tried Every conceivable combination of characters in the "Element Attributes" field, such as:
    ...(PART_NO), (#PART_NO#), (||PART_NO||), (+PART_NO+)
    C. The Javascript in the Page HTML Header appears to be correct, since I have written it this same way for other applications without any problems.
    D. If this simply cannot be done by referencing the "onChange" Javascript from the "Element Attributes" field,
    Then can you help me to write the code into the Select statement of the region.
    Thanks for any help you can give me.
    -Gary

    This may not be the most direct approach to the solution. But, none the less, it is a solution.
    For those other novices, like myself, I hope this can be useful at some point in your development:
    MY DESIRED RESULT:
    A. To Insert into another tablle values derived from both; Page Item (i.e. P153_x) and Attributes of a Row in an Updatable Report from which I have selected the Date-Picker.
    B. I want the insert to occur automatically after the user Selects the date from the Date-Picker.
    SOLUTIONS:
    1. I usea Javascript prompt window to prompt for information and store the information in Pre-Created Page Items.
    This is the Javascript as I've entered it into the Page HTML Header region: (Minus the Tags)
    function received_javaprompt () {
    var Serial_Number = prompt("Enter the Serial Number");
    var Bldg_Id = prompt("Enter the Bldg_Id");
    var Clst_Id = prompt("Enter the Clst_Id");
    $x('P153_SERIAL_NO').value = Serial_Number;
    $x('P153_BLDG_ID').value = Bldg_Id;
    $x('P153_CLST_ID').value = Clst_Id;
    2. I needed to identify the (Manufacturer and Part_No) Column Attribute in the Row from which I selected the Date-Picker.
    A. To do this, I enumerated the Columns in the order they were listed in the Select Statement of the region (Click on the Region Definition Tab).
    B. Then (Click on the Report Attributes Tab). Count, In the numerical order which these columns are selected, ONLY the columns that are Editable.
    C. When I counted down as far as the Column I wanted to capture the value of, Then I made a mental note of that number and used it in the following (2) Javascripts (findMaker and findModel).
    3. findMaker (Minus the tags)
    function findMaker (pThis) {
    var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
    var Maker = html_GetElement('f15_'+vRow).value
    $x('P153_MAKER').value = Maker;
    4. findModel (Minus the tags)
    function findModel (pThis) {
    var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
    var Model = html_GetElement('f16_'+vRow).value
    $x('P153_MODEL').value = Model;
    5. I added one more Javascript, to the Page HTML Header, that references the Application Process which will Insert the values into the "Other" table:
    function popDevices(P153_SERIAL_NO,P153_BLDG_ID,P153_CLST_ID,P153_MAKER,P153_MODEL)
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=popDevices',0);
    get.add('P153_SERIAL_NO',P153_SERIAL_NO);
    get.add('P153_BLDG_ID',P153_BLDG_ID);
    get.add('P153_CLST_ID',P153_CLST_ID);
    get.add('P153_MAKER',P153_MAKER);
    get.add('P153_MODEL',P153_MODEL);
    gReturn = get.get();
    get = null;
    6. I added the "onChange" process to the Element Attributes field of the Table item which utilizes the Date-Picker:
    A. Click on the Report Attributes Tab of the Region.
    B. Click on the Edit icon of the column which utilized the Date-Picker
    C. I added this "onChange" reference to the Element Attributes field, which is found in the Tabular Form section.
    onChange="javascript:received_javaprompt();findModel(this);findMaker(this);popDevices((P153_SERIAL_NO).value,(P153_BLDG_ID).value,(P153_CLST_ID).value,(P153_MAKER).value,(P153_MODEL).value);"
    7. The Application Process which inserts the collected data into the table is as follows:
    (Name= popDevices: Process Point= On-Demand: Type= PL/SQL Anonymous Block)
    BEGIN
    Insert into P_DEVICES
    BLDG_ID,
    CLST_ID,
    NAME,
    IP_ADDRESS,
    SERIAL_NO,
    MAKER,
    MODEL
    ) values
    :P153_BLDG_ID,
    :P153_CLST_ID,
    'Unassigned',
    'Unassigned',
    :P153_SERIAL_NO,
    :P153_MAKER,
    :P153_MODEL
    COMMIT;
    END;
    Well, I hope this may help someone else like me.
    I usually arrive at my solutions by getting help here on the Discussion Forum and also Google. Google inevitably points me to a previous Apex Discussion Forum session.
    Edited by: garyNboston on Mar 15, 2010 10:55 AM

  • Inserting Multiple Rows into Database Table using JDBC Adapter - Efficiency

    I need to insert multiple rows into a database table using the JDBC adapter (receiver).
    I understand the traditional way of repeating the statement multiple times, each having its <access> element. However, I am just wondering whether this might be performance-inefficient, as it might insert records one by one.
    Is there a way to ensure that the records are inserted into the table as a block, rather than record-by-record?

    Hi Bhavesh/Kanwaljit,
    If we have multiple ACCESS tags then what happens is that the connection to the database is made only once. But the data is inserted row by row.
    Why i am saying this?
    If we add the following in JDBC Adapter..logSQLStatement = true. Then incase of multiple inserts we can see that there are multiple
    <i>Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','1000')
    Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','2000')</i>
    Doesnt this mean that rows are inserted one by one?
    Correct me if i am wrong.
    This does not mean that the transaction is not guaranted. Either all the rows will be inserted or rolled back.
    Regards,
    Sumit

  • Insert a Picture into the Picture/Image Content Control using Open XML SDK 2.0

    I have created a word template as follows
    Here PizzaPicture is a Picture Content Control, PizzaName is a Plain Text Content Control and PizzaDescription is a Rich Text Content Control
    I am able to assign text to PizzaName and PizzaDescription Easily but not able to even locate the PizzaPicture. Here is my code
    using (WordprocessingDocument document = WordprocessingDocument.Open(@".\test.docx", true)) {
    MainDocumentPart mainPart = document.MainDocumentPart;
    DocumentFormat.OpenXml.Wordprocessing.Text text = null;
    SdtContentBlock pizzaNameBlock = null;
    SdtContentBlock pizzaDescriptionBlock = null;
    //SdtContentBlock pizzaPictureBlock = null;
    List<SdtBlock> sdtList = mainPart.Document.Descendants<SdtBlock>().ToList();
    foreach (SdtBlock sdt in sdtList)
    Console.WriteLine(sdt.SdtProperties.GetFirstChild<Tag>().Val.Value);
    SdtBlock s1 = mainPart.Document.Body.Descendants<SdtBlock>().Where(r => r.SdtProperties.GetFirstChild<Tag>().Val == "PizzaName").Single();
    SdtBlock s2 = mainPart.Document.Body.Descendants<SdtBlock>().Where(r => r.SdtProperties.GetFirstChild<Tag>().Val == "PizzaDescription").Single();
    SdtBlock s3 = mainPart.Document.Body.Descendants<SdtBlock>().FirstOrDefault(r =>
    SdtProperties p = r.Elements<SdtProperties>().FirstOrDefault();
    if (p != null)
    Console.WriteLine("P is not null");
    // Is it a picture content control?
    SdtContentPicture pict =
    p.Elements<SdtContentPicture>().FirstOrDefault();
    if (pict != null) Console.WriteLine("Pict is not null");
    // Get the alias.
    SdtAlias a = p.Elements<SdtAlias>().FirstOrDefault();
    if (pict != null && a.Val == "PizzaPicture")
    return true;
    return false;
    if (s3 == null) {
    Console.Write(" s3 is Null");
    } else {
    Console.WriteLine("s3 not null");
    if (s1 != null) {
    pizzaNameBlock = s1.Descendants<SdtContentBlock>().FirstOrDefault();
    text = pizzaNameBlock.Descendants<DocumentFormat.OpenXml.Wordprocessing.Text>().FirstOrDefault();
    // here you can set the current time
    text.Text = "Peperoni";
    Console.WriteLine(text.Text);
    string embed = null;
    if (s3 != null)
    Drawing dr = s3.Descendants<Drawing>().FirstOrDefault();
    if (dr != null)
    Blip blip = dr.Descendants<Blip>().FirstOrDefault();
    if (blip != null)
    embed = blip.Embed;
    if (embed != null)
    IdPartPair idpp = document.MainDocumentPart.Parts
    .Where(pa => pa.RelationshipId == embed).FirstOrDefault();
    if (idpp != null)
    ImagePart ip = (ImagePart)idpp.OpenXmlPart;
    using (FileStream fileStream =
    File.Open(@"c:\temp\pepperoni.jpg", FileMode.Open))
    ip.FeedData(fileStream);
    if (s2 != null) {
    pizzaDescriptionBlock = s2.Descendants<SdtContentBlock>().FirstOrDefault();
    string altChunkId = "AltChunkId12345";
    AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.Xhtml, altChunkId);
    chunk.FeedData(File.Open(@".\html.txt", FileMode.Open));
    AltChunk altChunk = new AltChunk();
    altChunk.Id = altChunkId;
    ////Replace content control with altChunk information
    OpenXmlElement parent = pizzaDescriptionBlock.Parent;
    parent.InsertAfter(altChunk, pizzaDescriptionBlock);
    pizzaDescriptionBlock.Remove();
    mainPart.Document.Save();
    document.Close();
    Here the call mainPart.Document.Descendants<SdtBlock>().ToList(); returns me only 2 items PizzaName, PizzaDescription but
    no PizzaPicture.
    Secondly the line   SdtContentPicture pict =  p.Elements<SdtContentPicture>().FirstOrDefault();
    returns NULL. So it seems that there is no element of type SdtContentPicture.
    What am I doing wrong? I am pretty sure that I have put PizzaPicture as a Picture content control.
    My objective is to locate this control in the document and then insert an image into it programmatically.
    MSDNStudent Knows not much!

    Hi,
    I'm running some test on your code, and I'll come back as soon as I get some update. But before that, I would recommend you to bind customXMLPart with the content controls via Content Control Tool Kit,
    which enables us to bind customXMLPart with CC by dragging and dropping.
    After binding, you can change contents of the template via OpenXML SDK easily as the following code:
    private void button1_Click(object sender, EventArgs e)
    string fileName = @"C:\CCTest.docx";
    WordprocessingDocument wordDoc = WordprocessingDocument.Open(fileName, true);
    MainDocumentPart mainPart = wordDoc.MainDocumentPart;
    CustomXmlPart customPart = mainPart.CustomXmlParts.FirstOrDefault();
    //convert image into string
    string picName = @"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg";
    System.IO.FileStream fileStream = System.IO.File.Open(picName, System.IO.FileMode.Open);
    System.IO.BinaryReader br = new System.IO.BinaryReader(fileStream);
    byte[] byteArea;
    byteArea = br.ReadBytes(System.Convert.ToInt32(fileStream.Length));
    string picString = System.Convert.ToBase64String(byteArea);
    //Load the XML template
    string DataString = Properties.Resources.XMLData;
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(DataString);
    //change the value
    XmlNodeList xmlNode = xmlDoc.GetElementsByTagName("pizzaPic");
    xmlNode[0].InnerText = picString;
    xmlNode = xmlDoc.GetElementsByTagName("pizzaName");
    xmlNode[0].InnerText = "Pizza Name";
    xmlNode = xmlDoc.GetElementsByTagName("pizzaDescription");
    xmlNode[0].InnerText = "Pizza Description";
    //write the custom xml data into the customxmlpart
    System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customPart.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
    writer.WriteRaw(xmlDoc.InnerXml);
    writer.Flush();
    writer.Close();
    fileStream.Close();
    br.Close();
    mainPart.Document.Save();
    wordDoc.Close();
    and the XML template of the project would something like:
    <?xml version="1.0"?>
    <Pizza xmlns="http://Test/ContentControls/Pizzas">
    <pizzaPic></pizzaPic>
    <pizzaName></pizzaName>
    <pizzaDescription></pizzaDescription>
    </Pizza>
    I hope this helps.
    Calvin Gao[MSFT]
    MSDN Community Support | Feedback to us

  • HTMLEditorKit: Inserting Custom Tags?

    How do you insert a custom tag into a HTML document? I've tried both:
    HTMLEditorKit.InsertHTMLTextAction( "merge", "<merge name=\"date\">DATE</merge>", HTML.Tag.BODY, new HTML.UnknownTag( "merge" ) )and
    kit.insertHTML( doc, offset, "<merge name=\"date\">DATE</merge>", 0, 0, new HTML.UnknownTag( "merge" ) );Both of these methods work fine for standard HTML tags.
    -- John

    I think you have to extend HTML.Tag, the following is quoted from the API documentation:
    Typesafe enumeration for an html tag. Although the set of html tags is a closed set, we have let the set open so that people can add their own tag types to their custom parser and still communicate to the reader.
    OTHER READERS PLEASE DON'T SHY GIVING A REPLY.
    (I have got no real experiences with the HTMLEditorKit.)

  • How to insert embedded image into TextArea htmlText (and add IOErrorEvent.IO_ERROR listener).

    I unsuccessfully tried to find way to insert embedded image into TextArea via <img> tag. Can you point me out how to do this?
    Also, please, tell me how to handle IOErrorEvent from TextArea because adding IOErrorEvent.IO_ERROR listener to TextArea doesn't cause any effect when image url of img tag has not been found.
    Thanks

    i 've successfully inserted the image into the database... here is my code
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package PMS;
    import java.io.File;
    import java.io.FileInputStream;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    public class Browse_java
    static Connection con=null;
    public static void main(String args[])
    try{
    System.out.println("(browse.java) just entered in to the class");
    con = new PMS.DbConnection().getConnection();
    System.out.println("(browse.java) connection string is"+con);
    PreparedStatement ps = con.prepareStatement("INSERT INTO img_exp VALUES(?,?)");
    System.out.println("(browse.java) prepare statement object is"+ps);
    File file =new File("C:/Documents and Settings/Administrator/Desktop/Leader.jpg");
    FileInputStream fs = new FileInputStream(file);
    byte blob[]=new byte[(byte)file.length()];
    fs.read(blob);
    ps.setString(1,"C:/Documents and Settings/Administrator/Desktop/Leader.jpg");
    ps.setBytes(2, blob);
    System.out.println("(browse.java)length of picture is"+fs.available());
    int i = ps.executeUpdate();
    System.out.println("image inserted successfully"+i);
    catch(Exception e)
    e.printStackTrace();
    finally
    try {
    con.close();
    } catch (SQLException ex) {
    ex.printStackTrace();
    }

  • Inserting Multiple Images into oracle database using JDBC

    I wanted to insert multiple images into database using JDBC by reading it from the file... and i am passing photos.txt(my text file) as an input parameter... I have inserted all the values into the database except for the image part... this is my content of photos.txt file and i have copied all the images into the folder
    *" C:\\photos "*
    *1,in1.jpg,108,19,in-n-out*
    *2,in2.jpg,187,21,in-n-out*
    *3,in3.jpg,308,41,in-n-out*
    *4,in4.jpg,477,52,in-n-out*
    *5,in5.jpg,530,50,in-n-out*
    and i want to store in1.jpg,in2.jpg,in3.jpg,in4.jpg,in5.jpg into the oracle databse using JDBC.... i have tried a lot using BLOB column.... and i have created my table as
    CREATE TABLE PHOTO(
    ID NUMBER NOT NULL PRIMARY KEY ,
    Name BLOB,
    X DOUBLE PRECISION,
    Y DOUBLE PRECISION,
    Tags VARCHAR2(40)
      try {                 // for restaurant System.out.println();System.out.println();System.out.println(); System.out.print("  Creating Statement for Photo...\n");             stmt2 = con.createStatement ();                       stmt2.executeUpdate("delete from PHOTO"); stmt2.executeUpdate("commit"); PreparedStatement stmt3 = con.prepareStatement ("INSERT INTO PHOTO VALUES (?, ?, ?, ?, ?)");             System.out.print("  Create FileReader Object for file: " + inputFileName1 + "...\n");             FileReader inputFileReader2 = new FileReader(inputFileName1);             System.out.print("  Create BufferedReader Object for FileReader Object...\n");             BufferedReader inputStream2  = new BufferedReader(inputFileReader2);             String inLine2 = null;                         String[] tokens; //            String[] imageFilenames = {"c:\\photos\\in1.jpg","c:\\photos\\in2.jpg","c:\\photos\\in3.jpg","c:\\photos\\in4.jpg","c:\\photos\\in5.jpg", //  "c:\\photos\\in6.jpg","c:\\photos\\in7.jpg","c:\\photos\\in8.jpg","c:\\photos\\in9.jpg","c:\\photos\\in10.jpg","c:\\photos\\arb1.jpg","c:\\photos\\arb2.jpg", //  "c:\\photos\\arb3.jpg","c:\\photos\\arb4.jpg","c:\\photos\\arb5.jpg","c:\\photos\\den1.jpg","c:\\photos\\den2.jpg","c:\\photos\\den3.jpg", //  "c:\\photos\\den4.jpg","c:\\photos\\den5.jpg","c:\\photos\\hop1.jpg","c:\\photos\\hop2.jpg","c:\\photos\\hop3.jpg","c:\\photos\\hop4.jpg","c:\\photos\\hop5.jpg"};               File file = new File("C:\\photos\\in1.jpg");            \\ ( Just for example  )           FileInputStream fs = new FileInputStream(file);                         while ((inLine2 = inputStream2.readLine()) != null) {               tokens= inLine2.split(",");             st2 = new StringTokenizer(inLine2, DELIM);                                                             stmt3.setString(1, tokens[0]);               stmt3.setBinaryStream(2, fs, (int)(file.length()));               stmt3.setString(3, tokens[2]);               stmt3.setString(4, tokens[3]);               stmt3.setString(5, tokens[4]);               stmt3.execute(); //execute the prepared statement               stmt3.clearParameters(); 
    As i am able to enter one image file by above code in1.jpg in to the oracle database.... but i am not able to insert all the image file in to the database.....do tell me what should i do.... and can you give me the example on the basis of the above code of mine...
    do reply as soon as possible..

    jwenting wrote:
    that depends. Putting the images in BLOBs prevents the file locations stored in the database from getting out of synch with the filesystem when sysadmins decide to reorganise directory structures or "archive" "old" files that noone uses anyway.True, but it really comes down to a business decision (cost-benefit analysis). If you have the bucks, the expertise, and the time, go with the Blobs, otherwise go with the flat files.

Maybe you are looking for

  • Error while creating Vacancy requisition object (NB) after upgrading EHP4

    Hi All, We had alreay E-Rec system with EHP2 and using last 1 year. Now based on Client requirement, we have upgrdaed to EHP4. After completing EHP4 upgradation, we are getting error while creating vacancy requisition object after all level of approv

  • Need to change permissions if moving backup disk to Server?

    I have a Time Machine backup disk that's been directly connected to a client machine. There is much free space still left on that drive and we're retiring the client. I'd like to move that backup drive to our OS X Server machine and have it backup a

  • FileMaker Pro icons not displaying correctly

    After updating to Yosemite, all of my FileMaker Pro document icons are displayed as generic icons (juts the outline of a piece of paper). This occurs both in Finder and on the Dock. Other document icons seem okay. If I do a Get Info on a document, th

  • Export to CS2 after uninstallation of CS3 ?

    I uninstalled CS3 (I don't see the need to upgrade from CS2 at this point). Now, LR is telling me that it does not find any Photoshop to export to. Is there a way for me to tell LR that CS2 is still there and could be used ? Thanks !

  • Report - PROCEDURE DOESN'T EXIST

    Hello, I am creating a Report using the wizard with 5 tables and 4 join conditions. I have 6 parameters which the User can choose to customize (not Value Required). The Report executes correctly from the .show procedure when but when I use the Custom