Hello
I have a problem with iterating HashSet on client side. The weird
thing is that in hosted browser everything works fine without errors,
but problems occurs in firefox and IE.
In my application I'm triyng to get a list of some properties with
their values. I have class PropertyValues, which contains information
about property and HashSet of instances of abstract AttributeValue
class (for example StringValue, IntegerValue etc). One more strange
thing is that there are problems only when property values which are
instances of StringValue class.
I make RPC call on server and recive a list of PropertyValues. Then
I'm trying to iterate HasSets in these PropertyValues on client:
for (PropertyValues pvs : pvsList) {
//Here it fails inside getTextAttributeLabels method, but
only for StringValue
addAttributeValuesGrid(pvs.getProperty().getName(),
getTextAttributeLabels(pvs));
//But these two lines always works fine, I can see added
labels on my page
AttributeValue firstValue = pvs.getValues().iterator().next
();
this.add(new Label(pvs.getProperty().getName() + " " +
firstValue.toString()));
}
private VerticalPanel getTextAttributeLabels(PropertyValues pvs) {
VerticalPanel labels = new VerticalPanel();
int i = 0;
int j = 0;
for (Iterator<AttributeValue> it = pvs.getValues().iterator();
it.hasNext();) {
try {
j = 0;
AttributeValue value = it.next();//Here it fails for
some reason ???
j = 1;
Label l = new Label("" + value);
j = 2;
labels.add(getExpandapleItem(l, value.getInfo()));
j = 3;
} catch (Throwable e) {
Window.alert(pvs.getProperty().getName());
alertException(e, i, j);
break;
}
i++;
}
return labels;
}
private void alertException(Throwable e, int i, int j) {
String s = "\n";
for (StackTraceElement stackTraceElement : e.getStackTrace())
{
s += stackTraceElement.getClassName() + "." +
stackTraceElement.getMethodName() + "." +
stackTraceElement.getLineNumber() + "\n";
}
Window.alert("i=" + i + " j=" + j + "\n" + e.getMessage() +
s);
}
That's what I see in alert in firefox:
i=0 j=1
(TypeError): can't convert n to primitive type
fileName:
http://localhost:8080/com.biosearch.Main/29776F8905BB64FB7210869C20242586.cache.html
lineNumber: 807
stack: zgb([object Object],[object Object])@http://localhost:8080/
com.biosearch.Main/29776F8905BB64FB7210869C20242586.cache.html:807
rgb([object Object],[object Object])@http://localhost:8080/
com.biosearch.Main/29776F8905BB64FB7210869C20242586.cache.html:800
ekb([object Object],"340792_43",[object Array],[object Object])@http://
localhost:8080/com.biosearch.Main/
29776F8905BB64FB7210869C20242586.cache.html:906
xhb([object Object])@http://localhost:8080/com.biosearch.Main/
29776F8905BB64FB7210869C20242586.cache.html:864
vhc([object Object],[object Object])@http://localhost:8080/
com.biosearch.Main/29776F8905BB64FB7210869C20242586.cache.html:1705
kvb([object Object],[object Object])@http://localhost:8080/
com.biosearch.Main/29776F8905BB64FB7210869C20242586.cache.html:1147
nvb([object Object])@http://localhost:8080/com.biosearch.Main/
29776F8905BB64FB7210869C20242586.cache.html:1149
([object Event])@http://localhost:8080/com.biosearch.Main/
29776F8905BB64FB7210869C20242586.cache.html:1190
Also in InternetExplorer I don't see any alerts, but all labels for
string values are blank.
Here is the code of AttributeValue and subclasses:
public abstract class AttributeValue implements Serializable {
private String datasource;
public AttributeValue() {
}
public abstract Object getValue();
public String getDatasource() {
return datasource;
}
public void setDatasource(String datasource) {
this.datasource = datasource;
}
@Override
public String toString() {
return getValue().toString();
}
public String getInfo() {
return "Attribute datasource: " + datasource;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof AttributeValue)) {
return false;
}
return ((AttributeValue) obj).getValue().equals(this.getValue
());
}
@Override
public int hashCode() {
int hash = 3;
hash = 37 * hash + (this.datasource != null ?
this.datasource.hashCode() : 0);
return hash;
}
}
----------------------------------------------------------------------------
public class StringValue extends AttributeValue{
private String value;
public StringValue() {
super();
}
public StringValue(String value, String datasource) {
setValue(value);
setDatasource(datasource);
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
Also I have DoubleValue, IntegerValue etc classes, where everything is
exactly same except type of value field.
I run out of ideas what can be wrong here. Any help will be great
appreciated. Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---