Hi,
I have a fairly complicated data structure in form bean and try to use that
in my pages. (struts 1.2. in tomcat 5.5.26) Here is the structure
public class Risk {
int size, probability;
....//constructor
....// setter and getter for both fields
}
===================================
public class RiskSet {
..//other fields
Map<String,Risk> riskValue;
public RiskSet(){
log.trace("start to construct RiskSet");
riskValue=new HashMap<String,Risk>();
for (NameSet name:getName()){
riskValue.put(name.getFormPropertyName(),new Risk(1,1));
log.trace(name.getFormPropertyName()+riskValue.get(name.getFormPropertyName()));
}
log.trace("finished constract RiskSet, length="+riskValue.size());
} // filled the riskvalue map with all the keys and initial value
public Risk getRiskValue(String key){
log.trace(key);
return riskValue.get(key);
}
}
=================================
public class testBean extends ActionForm{
.....//other fields
private RiskSet risks=new RiskSet();
public RiskSet getRisks() {
return risks;
}
public void setRisks(RiskSet risks) {
this.risks = risks;
}
public Risk getRisks(String key){
log.trace("getRisks("+key+")");
return risks.getRiskValue(key);
}
}
======================================
Now in the page ("Avail" is a key in the map) Later I will use some iterated
variable to replace Avail.
<html:select property="risks(Avail).probability">
<html:option value="1">Very Low</html:option>
...
</html:select></td>
I keeps getting error
01:45:11
[/inform].[action][ERROR](StandardWrapperValve.java:invoke:253)Servlet.service()
for servlet action threw exception
java.lang.IllegalArgumentException: Null property value for 'risks(Avail)'
The books and web pages I found are mostly about the simple types of the
property, not as complicated as mine. Any suggestion is appreciated.
Sincerely
Zhu, Guojun