FIX: Cannot Add Items to a Page from Server-Bound DhDocument

ID: Q195174


The information in this article applies to:


SYMPTOMS

A server-side implementation of code behind HTML may be unable to add items to the page it is bound to. If there are no calls to the add() method before a call to setBoundElements(), all subsequent calls to add() will not work.


RESOLUTION

Place a call to add(new DhText("")) in initForm() before calling setBoundElements().


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

Q194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

Q194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed


MORE INFORMATION

Steps to Reproduce Behavior

  1. Compile following Java file, Class1.java:
    
    import com.ms.wfc.html.*;
    import com.ms.wfc.core.*;
    import com.ms.wfc.ui.*;
    
    public class Class1 extends DhDocument
    {
    
       private DhTable table;
    
       public Class1()
       {
          this.initForm();
       }
       public DhElement onElementServerBound(DhElement e)
       {
          this.add(new DhText("Work-around enabled!"));
          return super.onElementServerBound(e);
       }
       protected void initForm()
       {
          // bind to the table
          table = new DhTable();
          table.setBindID("tableData");
    
          // Set its background to red
          table.setBackColor(Color.RED);
          //--> the following line is the workaround
          //this.add(new DhText(""));
          this.setBoundElements(new DhElement[]{table});
       }
    } 


  2. Place the resulting class file in %windir%\Java\Lib or anywhere on the classpath of Internet Information Server or Personal Web Server.


  3. Place the following HTML and Active Server Pages (ASP) files on the Web server:

    Page1.htm
    
    <HTML>
       <HEAD>
       <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
       <TITLE></TITLE>
       </HEAD>
       <BODY>
    
       <P>
       The table below should have a red background and some text below it that
       is coming from Java code.</P>
    
       <P>
       <TABLE border=1 cellPadding=1 cellSpacing=1 id=tableData width=75%>
    
           <TR>
               <TD>text1</TD>
               <TD>text2</TD>
               <TD>text3</TD></TR>
           <TR>
               <TD>text4</TD>
               <TD>text5</TD>
               <TD>text6</TD></TR>
           <TR>
               <TD>text7</TD>
               <TD>text8</TD>
               <TD>text9</TD></TR></TABLE></P>
    
       </BODY>
       </HTML> 
    Page2.asp
    
    <%
       Set Module = Server.CreateObject("DhModule")
       Module.setCodeClass("Class1")
       Module.setHTMLDocument("Page1.htm")
    %> 


  4. View the Active Server Pages (ASP) page with Internet Explorer.


RESULT: The Java DhText (saying "Work-around enabled!") will not appear.

Steps to Work Around Behavior

  1. Uncomment //this.add(new DhText("")); in initForm().


  2. Recompile the Java file.


  3. Replace the class file on class path.


  4. Run ResetIIS.bat from the command line:

    ResetIIS.bat
    
    net stop w3svc /y
    net stop iisadmin /y
    net stop msdtc
    mtxstop
    net start w3svc 


  5. View the Active Server Pages (ASP) page.



REFERENCES

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

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

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

© Microsoft Corporation 1998, All Rights Reserved.
Contributions by Robert LaCasse, Microsoft Corporation

Additional query words: WFC HTML DhTable Java data Table null


Keywords          : kbservicepack kbASP kbVJ600bug kbVS600sp2 kbVS600SP1 kbVS600sp3fix 
Version           : WINDOWS:3.1,6.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: May 19, 1999