Fellow users:

I have been using struts now for a short time and I am impressed, however I
am wondering
if I am making a mountain out of a mole hill here and was wanting a bit of
assistance.  

My particular issue is that I have a third order normalized table
using integers as the ids for the primary keys: 

  target                   cdtp_list                  cdtp
--------------------       ------------------            --------------
 pk  target_id        pk cdtp_id               cdtp_id
 -------------------       pk target_id             ---------------
       attrib1           ------------------            cdtp_name
       attrib2            primary                description
       attrib3
--------------------

The way I am representing this in the bean layers is I have
a target_form which extends the actionform bean and includes a reference to
a targetBean 
as per the nested extension (Jan 19th nightly build)

The targetBean includes an ArrayList variable called CDTPs which is exposed
as an Object[] 
(struts limitation??? I believe based on the nested extension authors
example)  
  public Object [] getCDTPs();
 <see footnote 1>

Additionally I have application scoped collections (beans) which contains
the full list of
cdtps (and other lookup lists) used for select options etc.

Now in my page which displays the target for editing shows the text fields
for 
the standard attributes and the select options lists for the fields which
are foreign keys to things
like status.  no problem with this (as per following example)

      <nested:select property="target_source_id" size="1" >
      <html:options collection="sources" property="target_source_id"
labelProperty="target_source" />
      </nested:select>

However with this cdtp listing I am listing all possibilities as radio
buttons, but I only know what
the ID is from the nested target.  I would like to lookup the CDTP_name (and
description if necessary) 
based off the id I have at the time.  My current method of doing this is a
bit messy but works.

  <bean:define id="CDTPArray" name="cdtps" type="java.util.ArrayList"/>
  <nested:iterate property="CDTPs" indexId="i" >
    <tr>
      <td width="33%">
      <bean:define id="current" name="i" type="java.lang.Integer"/>
      <%= ((application.data.CDTP)
            CDTPArray.get(current.intValue())).getCdtp() %>
      </td>
      <td width="33%"><nested:radio property="primary" value="Y" /></td>
      <td width="33%"><nested:radio property="primary" value="N" /></td>
    </tr>
  </nested:iterate>

Now this seams bit complicated for what I want to do which is something
like <bean:write name="cdtps[i]" property="cdtp" />   
   which would write the following
((application.data.CDTP)cdtps.get(i)).getCdtp()

now is there a simple way of doing this or do we need a new tag which
would do the following    
<bean:collectionLookup collection="cdtp" type="application.data.CDTP"
property="cdtp" />

<footnote 1>  I am also exposing the ArrayList itself as a different
property name for use in
a factory method when a new target is created.  This method iterates though
the list of cdtps and
creates a new relation object which is added to the ArrayList holding the
relations nested within the target

Thanks

Christopher Falling
Software Engineer Consultant, Discovery IS
____________________________________
AstraZeneca, R&D Boston
Discovery Information Systems

AstraZeneca R&D Boston - Waltham
35 Gatehouse Drive
Waltham, MA  02451
Local x4730
Tel: +01 781 839 4730
[EMAIL PROTECTED]


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

Reply via email to