After much googling and head-scratching, I finally have an html:options tag working on 
a jsp.  The problem is that I don't know why one component of the solution is needed, 
and I was hoping someone can explain it to me.
 
My ActionForm subclass, EditDeForm, has a pair of methods to provide the option list 
as part of the form bean:

                public Collection getNumFmtOptions() {
                  ArrayList list = new ArrayList();
                  list.add(new LabelValueBean("None", "0"));
                  list.add(new LabelValueBean("Comma separated", "1"));
                  list.add(new LabelValueBean("Currency", "2"));
                  return list;
                }
                 
                public void setNumFmtOptions(Collection options) {
                  // No op, here to satisfy bean-ness.
                }

The jsp page contains an html:form section linked via action mapping to the EditDeForm 
type.  In it, there is a select/options section that looks like this:

                <html:select property="numFmt">
                  <html:options collection="numFmtOptions" 
                        property="value"
                        labelProperty="label"/>
                </html:select> 

I had thought that this would be enough to make it work.  The html:options is in the 
context of an html:form that knows about the current form bean, and the form bean has 
a property numFmtOptions that contains what is needed to populate the options list.  
But when I tried just this, I got a "cannot find bean" error on numFmtOptions.
 
The googling mentioned above finally revealed that I had to add this at the top of my 
jsp:

                <bean:define id="numFmtOptions"
                        name="editDeForm" 
                        property="numFmtOptions"
                        type="java.util.Collection"/>

My question is:  Why?  What is this additional definition for?  What information does 
it supply that isn't already available to html:options inside the html:form context?
 
I'm happy that I have my code working, but I'd be even happier if I knew why it's 
working. :)
 
-- 
Craig Berry
Principal Architect
PortBlue Corp.
 
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to