cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <>
Subject CForms v2 and bizData strange handling
Date Tue, 06 Apr 2004 10:30:03 GMT

I've been looking at the v2 version of cforms and AFAIU there is no way to
pass additional bizData to the showForm method. The only way is to do:

form["bizData"] = bizData;
form.showForm( viewUri );

I find it very awkward. Let me give you the example. I have a page that
contains a CForms form. This is the definition:

<?xml version="1.0" encoding="utf-8"?>
<fd:form    xmlns:fd=""
        <!-- filtering widgets -->
        <fd:field id="companyName" required="false">
            <fd:datatype base="string"/>
        <fd:submit id="search" action-command="search" validate="true">
        <!-- rowset ordering -->
        <fd:field id="orderBy" required="true">
            <fd:datatype base="string"/>
        <fd:field id="direction" required="true">
            <fd:datatype base="string"/>

        <!-- rowset navigation -->
        <fd:submit id="next" action-command="next" validate="true">
        <fd:submit id="prev" action-command="prev" validate="true">
        <fd:submit id="first" action-command="next" validate="true">
        <fd:submit id="last" action-command="prev" validate="true">

So I use the form only to provide the displayed rowset with the ability to
filter it, order the rows, navigate through the multiple paged result.

The data that is passed to the view is:

- global application context
- currently logged in user info (name, last login etc.)
- user context ( ie. user can make bookmarks to tasks in the application )
- the rowset displayed
- current page context ( i.e. if the rowset is the list of projects, the
  page header contains the info on the contractor that these projects were
  created for)  

none of these is strictly connected to the form (the only one is the rowset
displayed as the form controls invoke actions that change this part of view).

In v2 I have to do something like this:

form = new Form( definition );

form[ "globalAppContext" ] = getGlobalAppContext();
form[ "user" ] = getLoggedInUser();
form[ "userContext" ] = getContextForUser( getLoggedInUser() );
form[ "items" ] = rowset;
form [ "pageContext" ] = contractor;

everything is doable so far but if I were to give somebody my code he would
surely ask me: why is the form top level object in your page model?

It looks like the form is the most important part of the model here while it
is completely not true. Moreover if I wanted to turn over the rowset
capabilities it would also affect other page parts (I would have to rewrite
the whole view to use new variable paths)

         | /  \ |        Leszek Gawron            //  \\
        \_\\  //_/           _\\()//_
         .'/()\'.     Phone: +48(501)720812     / //  \\ \
          \\  //  recursive: adj; see recursive  | \__/ |

View raw message