PRB: DhCell.getValue() Returns 0 for DhCell w/o Integer Value
ID: Q196575
|
The information in this article applies to:
-
Microsoft Visual J++, version 6.0
SYMPTOMS
The setValue() and setText() APIs set the value of a DhCell.
If setText() is called with a non-integer value, the DhCell is assigned a
value of 0.
STATUS
This behavior is by design.
MORE INFORMATION
The value of a DhCell is set by calling either the setValue() or the
setText() method.
The following four instructions yield a value of zero because setText is
called with a non-integer value:
DhCell cell=new DhCell(); // Create a DhCell element.
cell.setValue(10); // The value of the cell is 10.
cell.setText("Hello"); // The value of the cell is now 0.
int cellValue = cell.getValue(); // cellValue=0.
The following four instructions yield a value of 123 because setText is
called with an integer value (123):
DhCell cell=new DhCell(); // Create a DhCell element.
cell.setValue(10); // The value of the cell is 10.
cell.setText("123"); // The value of the cell is now 123.
int cellValue = cell.getValue(); // cellValue=123.
Steps to Reproduce Behavior
- Create a default Code-Behind HTML project using Visual J++ 6.0. To do
this, click New Project... from the File menu. Click the New tab in the
New Project dialog box. Select Web Pages from the Visual J++ Projects
tree. Select Code-Behind HTML, and click Open to create the project.
Class1.java is created by default.
- 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 table=new DhTable();
table.setBorder(1);
add(table);
DhRow row=new DhRow();
table.add(row);
DhRow row2=new DhRow();
table.add(row2);
DhCell cell=new DhCell();
row.add(cell);
cell.setValue(5);
row2.add(new DhCell("value:"+cell.getValue())); // 5
cell=new DhCell();
row.add(cell);
cell.setValue(12);
cell.setText("HelloWorld");
row2.add(new DhCell("value:"+cell.getValue())); // 0
cell=new DhCell();
row.add(cell);
cell.setText("-10");
row2.add(new DhCell("value:"+cell.getValue())); // -10
cell=new DhCell();
row.add(cell);
cell.setText("38.3");
row2.add(new DhCell("value:"+cell.getValue())); // 0
}
}
- 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 -->
<FONT color=BLUE>
<SPAN id="coloredText">Testing...</SPAN>
</FONT>
</BODY>
</HTML>
- Run the project.
RESULT: You will get the following web page:
5 HelloWorld -10 38.3
value:5 value:0 value:-10 value:0
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 : kbVJ600 kbwfchtml
Version :
Platform :
Issue type : kbprb