14.2. tableName determined at runtime

If the tableName is determined at runtime, the well known dbforms variables, e.g. currentRow_tablename will not work. So there is a new variable named dbforms which is a hashtable that holds a list of all known dbforms and subforms in the page. Key of the map is the new db:dbforms attribute name. Objects of this list are of the type DbFormContext, which will give the access to all of the known fields:

 
 Public class DbFormsContext {
    public String getPosition();
    public ResultSetVector getRsv();
    public Map getSearchFieldAlgorithmNames();
    public Map getSearchFieldModeNames();
    public Map getSearchFieldNames();
    public Map getCurrentRow();
    public void setCurrentRow(Map map);
    public void setPosition(String string);
 }

Any form with a subform on it would be ok too.

See DbFormTagTEI class and the test case (in the bookstore example) testAuthorBooksSubFormWithContextVar.jsp for details!

For example:

 <db:dbform   ...
                 tableName='<%=determined_at_runtime%>'
                 name="AUTHOR"
      >
...
 <db:body>
...
    <%=((DbFormContext)dbforms.get("AUTHOR")).getCurrentRow().get("AUTHOR_ID")%>
...
   </db:dbform