I use the following construct:

<%! String thisTable = "win_counterset"; %>
<db:dbform ... tableName="<%= thisTable %>" ... >

which is OK and should be, since the tableName attribute allows runtime values.

BUT if I then attempt to use the 'position_win_counterset' variable I get a compile error.

Is this something that can be fixed (low priority!) and should it?


please see the chapter on scripting variables -- 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")%>
...
--
Shawn

Karma is immutable, so act accordingly!



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
DbForms Mailing List


http://www.wap-force.net/dbforms

Reply via email to