Hi Richard,

Firstly thanks for the extraordinary effort you have gone to help me with
this issue.

One of the insights is that when doing a form rewind Tapestry seems to
ignore the html components completely(i.e @if's that determine which
elements are being rendered) ,and utilise only the component and page
definitions to find all the necessary state information it thinks it needs.
I thought that only the elements that would be rendered would be utilised
and therefore expected only one collection to be 'active' at any one time.
The displayed one. Silly me  :-)

The current tab component utilises Directlinks for the inactive tabs and
only sets the active tab name which is then rendered.i.e no submit in
between.  I assume this means that any checkbox selection state is lost when
switching tabs.  I am quite happy with this behaviour at the moment i.e
working with one collection at a time, so I suppose this will simplify the
code you provided quite a bit ?
If I need the extended behaviour I suppose I would change the tab
DirectLinks to LinkSubmit's or something similar ?

Again many thanks for the information.  It is much appreciated.

Kind Regards
Tony

> -----Original Message-----
> From: Richard Clark [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, 1 November 2005 17:31
> To: Tapestry users
> Subject: Re: Checking if component is in a Form inside the components code
>
>
> Oops, missed a detail (I was cutting and pasting from existing code
> and editing madly.) Here's new code:
>
> public abstract class CollectionEditPage extends BasePage implements
> PageRenderListener {
>
>    public abstract ListEditMap getMap();
>    public abstract void setMap(ListEditMap map);
>
>    public abstract List getCollections(); // I'm going to assume each
> collection can be iterated like a list
>
>    // Builds the master list
>    public void pageBeginRender(PageEvent event) {
>          super.pageBeginRender(event);
>          ListEditMap map = new ListEditMap();
>          List collections = getCollections();
>          int counter = 0;
>          for (Iterator iter = collections.iterator(); iter.hasNext();) {
>              Collection collection = (Collection) iter.next();
>              for (Iterator itemIter = collection.iterator();
> itemIter.hasNext();) {
>                ItemWrapper wrapper = new ItemWrapper(collection,
> itemIter.next());
>                map.add(new Integer(counter++), wrapper); // key by a
> sequential count
>          }
>          setMap(map);
>      }
>
>      // Use currentItem.item and currentItem.toBeDeleted on your page
>      public abstract void setCurrentItem(ItemWrapper info);
>
>      public void synchronize(IRequestCycle cycle) {
>          ItemWrapper info = (ItemWrapper) getMap().getValue();
>          setCurrentItem(info); // You should handle the case where
> info == null; often by throwing an exception
>      }
>
>      public void doFormSubmission(IRequestCycle cycle) {
>          for (Iterator iter = map.getAllValues().iterator();
> iter.hasNext();) {
>              ItemWrapper wrapper = (ItemWrapper) iter.next();
>              if (wrapper.isToBeDeleted())
>                  wrapper.getCollection().remove(wrapper.getItem());
>          }
>      }
> }
>
> public class ItemWrapper {
>    private Collection collection;
>    private Object item;
>    private boolean toBeDeleted;
>
>    public ItemWrapper(Collection c, Object i) {
>      collection = c;
>      item = i;
>      toBeDeleted = false;
>    }
>
>    public Collection getCollection() { return collection; }
>    public Object getItem() { return item; }
>    public boolean isToBeDeleted() { return toBeDeleted; }
>    public void setToBeDeleted(boolean delete) { toBeDeleted = delete; }
> }
>
>
>
> ---------------------------------------------------------------------
> 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/152 - Release Date: 31/10/2005
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.7/154 - Release Date: 01/11/2005


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

Reply via email to