cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Ochs <dan.o...@gmail.com>
Subject Re: [CFORM] how to repopulate repeater with Bean[] in on-value-change event?
Date Tue, 13 Sep 2005 20:56:30 GMT
I have it working now.  My misunderstanding was that I had to rebuild
the entire repeater row myself.  But it looks like all I needed to do
was clear the repeater, then add a row.  The addition of the row gave
me back an empty RepeaterRow with all of objects according to the XML
definition.   The working code looks something like the following:

(Repeater)event.getSourceWidget().getForm().lookupWidget("accountList");
accounts.clear();
Repeater.RepeaterRow rr = accounts.addRow();
Group accountGroup = (Group)rr.getChild("account");
Widget accountNameField = accountGroup.getChild("displayPath");
accountNameField.setValue("accountval");


On 9/13/05, Dan Ochs <dan.ochs@gmail.com> wrote:
> hi everyone, I'm trying to get some forms help/best practices.
> I have a form that shows a table; each row in the table is generated
> from a bean via the form definition/binding at the bottom of this
> post.  I want to re-populate the table with new beans when an
> on-value-changed event is fired.  Is there a way to regenerate the
> repeater rows from new beans in java?
> I am able to get the new beans in an array(same as the initial form
> load), but don't know how I can re-populate them in the repeater.
> 
> I have tried things like the following, and I'm getting some output,
> but I don't see where I can do thiings like set the id of the Field
> object so the form reads it in correctly and puts it into the correct
> columns in the table.  And the output looks like an array of Nodes:
> [Lorg/w3c/dom.Node;@1e64a3b.
> Is there a way I can generate the repeater object from the same xml I
> use to define the binding?  Am I even going about this the right way?
> 
> thanks!
> dan
> 
> Code I've tried without success:
> Repeater accounts =
> (Repeater)event.getSourceWidget().getForm().lookupWidget("accountList");
> accounts.clear();
> Repeater.RepeaterRow rr = accounts.addRow();
> FieldDefinition fd = new FieldDefinition();
> Field accountNameField = new Field();
> accountNameField.setValue("accountval");
> rr.addChild(accountNameField);
> 
> 
> Working Form Binding:
> <fb:class id="accountList-class">
>          <fb:simple-repeater id="accountList" parent-path="."
> row-path="accountList" delete-parent-if-empty="true">
>      <fb:new id="account-class"/>
>          </fb:simple-repeater>
>  </fb:class>
> 
>  <fb:class id="account-class">
>    <fb:group id="account" path=".">
>      <fb:value id="displayPath" path="displayPath"/>
>      <fb:value id="objectClass" path="objectClass"/>
>      <fb:value id="key" path="key"/>
>    </fb:group>
>  </fb:class>
> 
>  <fb:new id="accountList-class"/>
> 
> 
> 
> Working Form Definition:
>     <!-- account list -->
>    <fd:class id="accountList-class">
>      <fd:widgets>
>        <fd:repeater id="accountList">
>          <fd:widgets>
>            <!-- inline widget definitions from accountlist-class -->
>            <fd:new id="account-class"/>
>          </fd:widgets>
>        </fd:repeater>
>      </fd:widgets>
>    </fd:class>
> 
>    <!-- an account -->
>    <fd:class id="account-class">
>      <fd:widgets>
>      <!-- FIXME: doesn't work if there's not an enclosing group -->
>        <fd:group id="account">
>          <fd:widgets>
>            <fd:output id="displayPath">
>              <fd:datatype base="string"/>
>            </fd:output>
>            <fd:output id="objectClass">
>              <fd:datatype base="string"/>
>            </fd:output>
>            <fd:output id="key">
>              <fd:datatype base="string"/>
>            </fd:output>
>          </fd:widgets>
>        </fd:group>
>      </fd:widgets>
>    </fd:class>
> 
>    <!-- a list of acount lists -->
>    <fd:class id="accountLists-class">
>      <fd:widgets>
>      <!-- FIXME: doesn't work if there's not an enclosing group -->
>        <fd:group id="accountLists">
>          <fd:widgets>
>                          <fd:repeater id="accountLists">
>                                  <fd:widgets>
>                                          <fd:new id="accountList-class"/>
>                                  </fd:widgets>
>                          </fd:repeater>
>          </fd:widgets>
>        </fd:group>
>      </fd:widgets>
>    </fd:class>
> 
>    <!-- the top-level tasks -->
>    <fd:new id="accountList-class"/>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message