You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Chris Wilkes <cw...@ladro.com> on 2003/05/14 04:02:32 UTC

Use of String and xf:selectOne problematic, int okay in 2.1

I'm trying to get a dropdown list of states in my xmlform Cocoon 2.1 app
with this code in my userIdentity.xml file (going off the sample app
included):

  <xf:selectOne ref="/bornState">
    <xf:itemset nodeset="allStates">
      <xf:caption ref="key" />
      <xf:value ref="key" />
    </xf:itemset>
  </xf:selectOne>

Here's the part in my UserBean.java file:

  private String bornState;
  private TreeMap allStates;
  public UserBean () {
    initStates();
  }
  public String getBornState() {
    return bornState;
  }
  public void setBornState(String value) {
    bornState = value;
  }
  public Set getAllStates() {
    return allStates.entrySet();
  }
  public void initStates() {
    String statestring = new String("WA AL AK AZ AR CA CO CT DE DC FL
       GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC
       ND OH OK OR PA RI SC SD TN TX UT VT VA WV WI WY");
    String[] states = Pattern.compile(" ").split(statestring);
    allStates = new TreeMap();
    for (int i = 0; i < states.length; i++) {
      allStates.put(states[i], states[i]);
    }
  } 

  I have similiar code for the year, month, and date and the HTML for
those is fine.  With the states, I get the 50 entries in the
dropdown box but with no values for them, just blanks:
    <option value=""></option><option value=""></option>
  So the values have been entered into a TreeMap as the length of that
list is correct.  I just can't get the values out.
  However when I change "bornState" over to an int:
    private int bornState;
  and fix the getter and setter it comes back with the correct values:
    <option value="AK">AK</option><option value="AL">AL</option>
  which is just confusing.

  Should I look into my XSL file that converts the above XML?  I can't
see anything in my slightly modified wizard2html.xsl file that would
make it work for Strings but not for ints.

Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org