Microsoft KB Archive/195174

= FIX: Cannot add items to a page from server-bound DhDocument =

Article ID: 195174

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition
 * Microsoft Software Development Kit 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



Steps to Reproduce Behavior
  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}); } }                        Place the resulting class file in %windir%\Java\Lib or anywhere on the classpath of Internet Information Server or Personal Web Server.  Place the following HTML and Active Server Pages (ASP) files on the Web server:

'Page1.htm'     </HEAD> <BODY>

<P> The table below should have a red background and some text below it that is coming from Java code.</P>

<P> </P>

</BODY> </HTML> 'Page2.asp' <%  Set Module = Server.CreateObject("DhModule") Module.setCodeClass("Class1") Module.setHTMLDocument("Page1.htm") %>                       </li> View the Active Server Pages (ASP) page with Internet Explorer.</li></ol>

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

Steps to Work Around Behavior
<ol> Uncomment //this.add(new DhText("")); in initForm.</li> Recompile the Java file.</li> Replace the class file on class path.</li>  Run ResetIIS.bat from the command line:

'ResetIIS.bat' net stop w3svc /y net stop iisadmin /y net stop msdtc mtxstop net start w3svc </li> View the Active Server Pages (ASP) page.</li></ol>

<div class="references_section">