[Opensource] Using the html:select tag

Eddie Lewis ELewis at copyright.com.au
Tue Aug 13 19:15:23 PDT 2002


Wolf
 
this bit of code exists in the autoField method that may help you
 
setup the input
 
        Input oneField = new Input(oneFieldName);
        oneField.setMaxLength(fieldSize);
        oneField.setDisplayLength(displayFieldSize);
 
further down in the method, the values are set
 
        if (myDBObj.isMultiValued(oneFieldName)) {
 
            //writeToLog("autoInput - set multivalued field for " +
oneFieldName);
            oneField.setAttribute("multiValued", "Y");
 
            Vector values = myDBObj.getValidValues(oneFieldName);
            //Hashtable values = myDBObj.getValues(oneFieldName);
            if (values == null) {
                throw new DBException("Valid values for field "
                + oneFieldName + " from object "
                + myDBObj.getName() + " were null");
            }
 
            oneField.setValidValues(values);

so use this for your field - get the valid values from the dbobject
 
in the dbobject
  public Vector getValidValues(String fieldName) throws DBException
  {
    if (fieldName.equals("dbFieldName ")) {
      Vector v = new Vector();
      v.addElement(new ValidValue("Y", "Yes"));
      v.addElement(new ValidValue("N", "No"));
      return v;
  }
 
then in your jsp you need something like
 
<logic:iterate id="oneInput" property="inputs">
   <logic:present name="oneInput" property="@multiValued">
       <td><html:select styleClass="smallfont" name="oneInput"/></td>
  </logic:present>
</logic:iterate>
 
hope this helps.
There is more of this in the ExpressoHowTo document we created which resides
on the jcorporate site. Have a look at it for a bit more detail.
 
-----Original Message-----
From: Wolf Thompson [mailto:ewolfthompson at attbi.com]
Sent: Tuesday, 13 August 2002 12:30 PM
To: opensource at jcorporate.com
Subject: [Opensource] Using the html:select tag


There has to be a reasonably simple answer to this one - I just haven't
found it.
 
I want to create a dropdown selection via the html:select tag.  The contents
of the dropdown box will be dynamically generated from one field of a
searchAndRetrieveList - i.e., names of cities stored in a database table.
 
Even a *clue* as to how I can accomplish this would be greatly appreciated.
 
So far, every Input I've used with the html:select tag has given me a
different Controller error - either it doesn't have valid values or I'm
getting a cast exception.
 
Thanks in advance,
Wolf Thompson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20020814/e33c0c68/attachment-0002.htm


More information about the Opensource mailing list