The point of MVC is to pre-populate the bean in Action.

You should unit test the bean in the model layer, once it works, put it in Struts. (MVC layered aproach allows for unit testing of a layer)
So if you say something like:
MyBean b = new MyBean();
b.populate();
Collection c = b.getOptions();
out.println(b);
-what do you get?
.V


A bean that does not work outside of Struts, will not work once you put it in Struts.


Daniel H. F. e Silva wrote:
Hi Bob,
 I think you could try <bean:define/> or, better, JSTL tag <c:set/>.
I'm not a JSTL expert but i know you can determine scope to be used by <c:set/>.
And i'm not sure, but i think you can do that also with <bean:define/>.
 Hope it helped you.

Regards,
 Daniel.

--- Bob Langford <[EMAIL PROTECTED]> wrote:

Hi,  I can't seem to understand how to declare things correctly to do
what I want to do.  Can anyone tell me where I am going wrong?

I'm trying to use a simple Java method as the source of the choices
in a html:select box in a form. The method returns a java.util.List,
where each item is a org.apache.struts.util.ValueLabelBean object, just
what I need for this. Here's one way I tried to use it:
=============
<%@ page import="foo.bar.MyUtils" %>
<jsp:useBean id="months" type="java.util.List" />
<% months = MyUtils.getMonthsList(); %>
...
<html:select ... >
<html:options collection="months" property="value" labelProperty="label" />
</html:select>
=============
The problem is that "useBean" looks up the attribute "months" in the page
context, and since it can't find it, throws an exception. But without
the "useBean" tag, the "html:options" tag can't find the data it needs.
I've read the docs until my eyes hurt, and I can't find any technique to
tell "useBean" to merely create a new bean, not fetch an existing one.
This seems so easy, I can't believe I haven't done it before, but I can't
find an example in any of my previous code.


What am I missing? Thanks in advance...

--
Bob Langford
Silicon Masters Consulting, Inc. 8207 Stone River Court, Richmond, VA 23235
phone: 804-674-1253 fax: 804-745-6650 http://www.silicon-masters.com/




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




__________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com

-- Victor Cekvenich, Struts Instructor (215) 312-9146

Advanced Struts Training
<http://basebeans.com/do/cmsPg?content=TRAINING> Server Side Java
training with Rich UI, mentoring, designs, samples and project recovery
in North East.
Simple best practice basic Portal, a Struts CMS, Membership, Forums,
Shopping and Credit processing, <http://basicportal.com> software, ready
to develop/customize; requires a db to run.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to