HiJoe,

Thanks for your replies.  They shed some light on the problem.

The post was my first stab at resolving the problem I subsequently  posted
to th emailing list.  I have attached it below for your reference.  I
believe I may not fully understand the render, submit, rewind process and
the relationship between these states and the current state of page
properties and component parameters.  This is something I will need to come
to terms with as I climb that learning curve ...

Maybe the post below may shed some more light on my problem and you may
provide a possible solution ...

Kind Regards
Tony De Keizer
=================================
Dear users,

Sorry this is going to be convoluted post to explain my problem.

I am new to Tapestry and I have been experimenting with existing components
and component development in order to move up the learning curve as fast as
possible.  I am using Tapestry 4. beta 10.

One component I need in my application is a component that is passed a
collection, renders the collection in a table with a checkbox next to each
row, and provides a delete button that when pressed checks the selected rows
and deletes these from the collection.

I have managed to create the base component utilising the foreach component
, checkbox component, and a submit component plus some java code to build
the list of selected row etc.  The component has one required parameter, the
collection.  The remove button has a action listener which gets the selected
list to delete and the current collection and removes the appropriate
entries.

If  I include a single one of these components in a form it works very well.

I then wanted to utilise this component in a form that would include one or
more tabs with each tab incorporating this component with it's own
collection.  The TabPanel is very simple in that it renders the tab names
and then only renders the body of the active tab.  So at any one time only
one tab and it's collection editor content is rendered.
i.e.

<table>
  <tr>
    <span jwcid="@Foreach" source="ognl:tabNames" value="ognl:tabName">
              <td width="5"></td>
              <span jwcid="@If" condition="ognl:currentTabActive">
                <td class="activetab">
                          <span jwcid="@Insert" value="ognl:tabName"></span>
                        </td>
                </span>
              <span jwcid="@If" condition="ognl:!currentTabActive">
                        <td>
                                <span jwcid="@DirectLink" 
listener="ognl:listeners.onTabClicked"
parameters="ognl:descriptor.displayName">
                                <span jwcid="@Insert" 
value="ognl:tabName"></span>
                                </span>
                        </td>
              </span>
    </span>
  </tr>
</table>

<div jwcid="@Foreach" source="ognl:tabList" value="ognl:tabName">
        <span jwcid="@If" condition="ognl:currentTabActive">
        <table>
                <tr>
                        <td width="100%">
                                <span jwcid="collectionEditor" />
                        </td>
                </tr>
        </table>
        </span>
</div>

I tested this utilising two tabs and two independent collections.  Now if
the first tab is active and I select the first row for deletion and click
the delete button the first element in the collection bound to the second
tab is removed.  On utilising the Eclipse debugger I found that the
getCollection() call in the listener returned would always return the last
tabs collection not the one that was currently active and the only one being
rendered.

I then modified the remove submit component to bind the listener parameter
not the action parameter to the same listener.  On debugging this I found
the collection that was returned from the getCollection() call was the
correct one for the displayed tab but the selected list updated by the
checkboxes had not been updated due to the submit button not having yet done
a form submit before the listener was invoked.

Can someone please lead me in the right direction to solve this issue or
suggest an alternative, more Tapestry logical, strategy ?
=================================================


> -----Original Message-----
> From: Joe Trewin [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 1 November 2005 05:28
> To: Tapestry users
> Subject: RE: Checking if component is in a Form inside the components code
>
>
> Sorry - just read the end of the question! Not sure how you could
> trigger a submit, as by the time your component code is run it'll be
> half-way through a rewind. Nothing to stop you getting hold of the
> containing form's listener (if it had one) I guess, and triggering it
> using the invokeListener method, but you'd want to be careful to check
> that that wasn't how your component came to be rewinding in the first
> place.
>
> -----Original Message-----
> From: Joe Trewin [mailto:[EMAIL PROTECTED]
> Sent: 31 October 2005 18:24
> To: Tapestry users
> Subject: RE: Checking if component is in a Form inside the components
> code
>
> Yes it is (assuming Tap 4.0 here, but probably a similar method for
> 3.0). I use something along the lines of:
>
>     IForm form = (IForm)
> cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE);
>     boolean inForm = (form != null);
>
>     if (inForm) {
>         // ... do something
>     } else {
>         // ... do something else
>     }
>
> If you need mor elaboration, or have trouble, try checking out the
> source code for the For component
> (/framework/src/java/org/apache/tapestry/components/ForBean.java) in the
> Tapestry distribution.
>
> Cheers,
> Joe
>
> -----Original Message-----
> From: Tony De Keizer [mailto:[EMAIL PROTECTED]
> Sent: 29 October 2005 03:16
> To: Tapestry users
> Subject: Checking if component is in a Form inside the components code
>
> Is it possible for component java code to check if it is imbedded inside
> a form component and if so trigger a form submit ?
>
> Regards
> ========================================
> Tony De Keizer
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.362 / Virus Database: 267.12.6/151 - Release Date:
> 28/10/2005
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.362 / Virus Database: 267.12.6/151 - Release Date: 28/10/2005
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.6/152 - Release Date: 31/10/2005


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

Reply via email to