Wendy, 

You have been very helpful.  This is my first STRUTS app and I seem to
stumble the most on getting these tags to work.  I have not found any real
documentation examples to help me.  At any rate, I tried to use the options
collection tag and I had no success.  It was one error after another.  I
finally got the lists to display as a drop down using the JSTL tag forEach. 


This is what my code looked like when I was trying to use the options
collection tag: 


 <html-el:select name="reviewRecordForm" property="csci.options"> 
     <html-el:options collection="${reviewRecordForm.map.csci}"
property="optionId" labelProperty="optionLabel"/> 
  </html-el:select> 


After reading what you wrote, I think I should try the following to get it
to work: 


 <html-el:select name="reviewRecordForm" property="csci"> 
     <html-el:options
collection="${reviewRecordForm.map.csci.options}"property="optionId"
labelProperty="optionLabel"/> 
  </html-el:select> 


csci is another property in my form bean which is the same type as
baseline.....  In the properties field of the select tag I used the
collection instead of the actual form bean property.  I think maybe this was
my problem.  I am going to try it and see what happens. 


Do you think I am on the right track?? 


Thanks for your help, 


Natalie 


Wendy Smoak wrote: 


Natalie wrote: 
> In my Action's execute method, I do a beanutils.copyProperties to copy the



> dto (data from DB) into my form.  So, my form bean property is already set



> to the list. This list is used to build the select list drop down box in 
my jsp. 


The entire contents of the drop down is a different thing than the single 
item from that list that the user has selected.  I don't store the lists of 
items in my Form bean, but YMMV. 


You don't have to do the iteration with c:forEach, the select tag will do it

for you. 


Here's one of mine: 
<html-el:select property="purpose"> 
 <html-el:options collection="reminderPurposes" property="key" 
labelProperty="value"/> 
</html-el:select> 


Where 'reminderPurposes' is a Collection sitting in Application scope. 


If I wanted to "pre-select" a certain item, I might (in the Action's execute

method) do: 
( (DynaActionForm) form ).set( "purpose", "GI" ); 


Instead, I just do this: 
   BeanUtils.copyProperties( dvForm, contact ); 
and since the DTO and the form both have a 'purpose' property, the value 
gets copied from the DTO (contact in this case) to the form. 


You ask what you're supposed to set 'baseline' to.  I thought you were 
originally asking how to pre-select a certain value before the form is 
displayed for the first time.  If you don't have a value in mind, then don't

set it to anything. 


However, most of the problem seems to be that you're working too hard... 
Struts handles most of this, the iteration over a Collection, pre-selecting 
the right item, magically behind the scenes, and you don't have to do 
anything. 


-- 
Wendy Smoak 
Applications Systems Analyst, Sr. 
Public Affairs, Information Resources Management 
Arizona State University, Tempe AZ



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

Reply via email to