FIX: Cannot add items to a page from server-bound DhDocument (195174)



The information in this article applies to:

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

This article was previously published under Q195174

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 that this is a bug in the Microsoft products that are 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:

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

194295 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 support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbBug kbfix kbVS600sp3fix KB195174