PRB: bindNewElements() of DhTable Changes   to "" in Cell

ID: Q197568

The information in this article applies to:

SYMPTOMS

The non-breaking spaces ( ) in a table's cells are removed from the cells after binding to the table.

CAUSE

When a DhTable object is bound through a call to setBoundElements(), all non-breaking spaces ( ) are converted to empty strings "".

RESOLUTION

To workaround this issue, you can bind to the DhTable using findElement() instead of using setBoundElements(). For example, if you had a DhTable named "table" you could do the following:

   table = (DhTable)findElement("table");

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

1. Create a default Code-Behind HTML project in Visual J++ 6.0 as

   follows:

    a. From the File menu, click New Project.
    b. Click the New tab in the New Project dialog box.
    c. Click Web Pages from Visual J++ Projects.
    d. Click Code-Behind HTML.
    e. Click Open to create the project.

2. Modify Class1.java as follows:

      import com.ms.wfc.html.*;
      import com.ms.wfc.core.*;
      import com.ms.wfc.ui.*;
      public class Class1 extends DhDocument
      {
         public Class1()
         {
            initForm();
         }
         private void initForm()
         {
         }
         protected void onDocumentLoad(Object sender, Event e)
         {
            DhTable t;
            t = new DhTable();
            t.setBindID("table");
            this.setBoundElements(new DhElement[] { t });
      // Workaround: comment out the above 3 lines and uncomment the
      // following:
      //    t = (DhTable)findElement("table");
      //    t.setBackColor(Color.RED);
            DhCell cell=(DhCell)findElement("cell");
            addText("Contents of DhCell is '"+cell.getText()+"'");
         }
      }

3. Modify page1.html as follows:

      <HTML>
      <BODY>
      <hr>
      <OBJECT classid="java:com.ms.wfc.html.DhModule"
           height=0 width=0 ... VIEWASTEXT>
      <PARAM NAME=__CODECLASS VALUE=Class1>
      <PARAM NAME=CABBASE VALUE=Project1.CAB>
      </OBJECT>
      <!-- Insert HTML here -->
      <TABLE align=center border=1 cellPadding=1 cellSpacing=1 width=75%
       id=table>
        <TR><TD id=cell>&nbsp;*</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>
        <TR><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD></TR>
      </TABLE>
      </BODY>
      </HTML>

4. Run the project.

RESULT: The Web page contains a table with one cell containing a "*". The text "Contents of DhCell is '*'". Notice there is no space before the asterisk.

REFERENCES

For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java, see the following pages on the Microsoft Technical Support site:

   http://support.microsoft.com/support/visualj/ 

   http://support.microsoft.com/support/java/ 

(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Derek Jamison, Microsoft Corporation.

Additional query words:

Keywords          : kbJava kbVJ600 kbInetDev kbwfchtml 
Version           : WINDOWS:3.1,6.0
Platform          : WINDOWS
Issue type        : kbprb

Last Reviewed: December 19, 1998