In .NET, they have an idea called a "code-behind" page. This is a superclass for the 
page that you can use to obtain values from a database and bind them to controls. The 
server page then extends the code-behind page. When the ASP.NET framework calls a page 
load method, the controls are populated by the superclass. Looking at the server page, 
it seems like the controls are populated by magic.

In Struts, we have an idea called an "Action". The best practice is to treat the 
Action as if it were a superclass for a page. Control passes through the Action first 
and then to the page. Any values we need are acquired by the Action, so that they can 
be displayed by the page. But since the Action is not a superclass to the page, it 
cannot populate the controls directly. Instead, we set attributes in the Request where 
the page can find them. So, the Action and page must agree on a name for each 
attribute.

In the given case, the Action would acquire the collection (usually by consulting a 
database through some type of facade), and set it to the Request under the attribute 
name "collectionName". So, within the Action, you might have code that looks something 
like this:

Collection myCollection = myFacade.myCollectionMethod();
request.setAttribute("collectionName",myCollection);

Once the Controller forwards to the page, the tag will be able to find 
"collectionName" in the request, so that it can populate the control.

-Ted.

On Wed, 09 Jun 2004 12:55:34 +0200 (CEST), (Name Withheld) wrote:
> Dear Mr Ted Husted,
> first of all, sorry me for my bvad english and for this mail . I
> suppose that several people write you for more important questions
> than this. I tried a lot to find something around the web on jguru
> and mailing list, but without success: maybe, it's just my poor
> english.:(
> I have the following problem. I should fill a select box with
> values which come from a database. Using another framework (Torque)
> i have built the classes that allow me to obtain a list of Objects,
> each object with a get method that return me the value to insert
> into the select. I have seen that there are some optional tag that
> allow to automatic fill a select with values of a particular
> property of a list of object. Some like that: <html:select
> property="selectPropertyName"> <html:options
> collection="collectionName" property="propertyOfTheObject"
> labelProperty="whatUserSee" /> </html:select>
>
> now, i have understood this tag but i dont where and how build the
> collection called collectionName (the list, in my case). I have to
> do that in the jsp, just before the select? i should do it anywhere
> and save the collection in the session?
>
> If u can, help me in some way. Besides, thanks a lot for all of
> your messages and posts, which are always very useful. Lorenzo





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

Reply via email to