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



The information in this article applies to:

  • Microsoft Visual J++ 6.0
  • Microsoft SDK for Java 3.1

This article was previously published under Q197568

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:
    1. From the File menu, click New Project.
    2. Click the New tab in the New Project dialog box.
    3. Click Web Pages from Visual J++ Projects.
    4. Click Code-Behind HTML.
    5. 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>&#xa0;*</TD><TD>&#xa0;</TD><TD>&#xa0;</TD></TR>
      <TR><TD>&#xa0;</TD><TD>&#xa0;</TD><TD>&#xa0;</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: (c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Derek Jamison, Microsoft Corporation.

Modification Type:MinorLast Reviewed:8/25/2005
Keywords:kbInetDev kbJava kbprb KB197568