struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guojun Zhu" <>
Subject How to handle complicated map in the property
Date Mon, 08 Sep 2008 20:01:31 GMT

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;
....// 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("finished constract RiskSet, length="+riskValue.size());
      }  // filled the riskvalue map with all the keys and initial value

      public Risk getRiskValue(String 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){
        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>

I keeps getting error

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.

Zhu, Guojun

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message