rankin <[EMAIL PROTECTED]> writes:

>Using 2.3.1, Torque 3.1.1

>I have many tables, which for the moment are separately defined. I want 
>one template, DisplayTable.vm, to display any one of these tables. So, 
>DisplayTable.java has:

>public void doBuildTemplate(){
>   ...
>   String tablename = data.getParameters().getString("tablename",null);
>   Criteria crit = new Criteria();
>   List list = [**tablename**]Peer.doSelect(crit);
>   context.put("list", list);
>   TableMap tmap = Torque.getDatabaseMap("mydb").getTable(tablename);
>   ColumnMap[] cMap = tmap.getColumns();
>   Vector names;
>   for(int i = cMap.length -1; i >=0; i--)
>      names.add(cMap[i].getColumnName());
>   context.put("columnNames", names.toArray());
>   ...
>}

>and DisplayTable.vm has

><tr>
>#foreach ($columName in $columnNames)
>   <th>$columnName</th>
>#end
></tr>
>#foreach ($item in $itemList)
><TR>
>   #foreach ($attribute in $columnNames)
>   <TD>$!{item.$attribute}</TD>
>   #end
></TR>
>#end

>I'm sure this has been done many times far more easily and other 
>suggestions would be greatly appreciated ... However - how does one do 
>the "[tablename]Peer.doSelect(crit)" bit?

>Suggestions??

Use Reflection. The static peers suck; I'd readily agree to that. You can
look at the TorqueSecurityService for an example on how to do this.

        Regards
                Henning






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

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
[EMAIL PROTECTED]        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

What is more important to you...
   [ ] Product Security
or [ ] Quality of Sales and Marketing Support
              -- actual question from a Microsoft customer survey

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

Reply via email to