Tuesday, March 26, 2013

Re: CellTree, adding data to a child node and refresh

Hi Umit,

I am having a hard time to refresh the Cell tree I have the tree working but when I create new folder(I am using a menubar then on right click) I am making an RPC call to create a nee folder. But the child gets updated only when I reload the whole page. Is there any way to refresh only the parent folder. Also I am using an AsyncDataProvider.

On Thursday, November 4, 2010 2:09:27 PM UTC+5:30, Ümit Seren wrote:
Thanks John,
I was thinking in the same thing.
One last question. If I update the ListDataProvier of the Child
Objects will the nodes that were open stay open or will they be
automatically be closed?

cheers
Uemit


On Nov 3, 7:38 pm, John LaBanca <jlaba...@google.com> wrote:
> You are correct that refreshing the ListDataProvider<ObjectA> will only
> update that level of the tree.  You need to keep a reference to
> ListDataProvider<ObjectB> in order to refresh that section of the tree.
>  That probably means creating a parallel tree structure of
> ListDataProviders, or at least having a map for ObjectA to the
> ListDataProvider<ObjectB> that represents its children.
>
> One workaround is to close/reopen the TreeNode, which will cause it to
> request a new DefaultNodeInfo from the TreeViewModel.
>
> Thanks,
> John LaBanca
> jlaba...@google.com
>
>
>
>
>
>
>
> On Wed, Nov 3, 2010 at 1:13 PM, Ümit <uemit.se...@gmail.com> wrote:
> > Hi all,
>
> > I have an issue with the CellTree and adding new items to a child
> > node. I am not exactly sure if my approach is flawed or maybe there is
> > an issue with the CellTree but maybe somebody can help with that
> > problem.
> > So basically I followed the CellTree example from the showace.
>
> > I have a CellTree which consists of 3 nodes which correspond to three
> > different DTO's (let's say: ObjectA, ObjectB and ObjectC)
> > Each ObjectA instance contains a list of ObjectBs and each ObjectB has
> > a list of ObjectCs.
>
> > ObjectA should be displayed in the root node, ObejctB in the second
> > node and ObjectC in the third node (= leaf node).
>
> > I created a CustomTreeModel with a custom constructor which takes a
> > List of ObjectA instances as a parameter. In the constructor I create
> > a ListDataProvider which is stored as a member variable in the
> > CustomTreeModel.
>
> > Then I define the necessary Cells for each node level and implement
> > the  public <T> NodeInfo<?> getNodeInfo(T value)  function.
>
> > This looks something like this:
> > public <T> NodeInfo<?> getNodeInfo(T value) {
> >                if (value == null)
> >                {
> >                        return new DefaultNodeInfo<ObjectA>
> >                                (listDataProvider,new TextCell());
> >                }
> >                else if (value instanceof ObjectA)
> >                {
> >                        ObjectA object  = (ObjectA)value;
> >                        return new DefaultNodeInfo<ObjectB>(new
> > ListDataProvider<ObjectB>(object.getObjectBList()),new TextCell());
> >                }
> >                else if (value instanceof ObjectB)
> >                {
> >                        ObjectB object  = (ObjectB)value;
> >                        return new DefaultNodeInfo<ObjectC>(new
> > ListDataProvider<ObjectC>(object.getObjectCList()),new TextCell());
> >                }
> >                String type = value.getClass().getName();
> >                throw new IllegalArgumentException("Unsupported object type:
> > "+
> > type);
> >        }
>
> > getObjectBList(),getObjectCList() return the List of the child
> > Objects.
>
> > I pass this model to the CellTree and the CellTree is displayed
> > correctly.
>
> > Now I try to add a new ObjectB instance to the list of ObjectBs in the
> > one of the ObjectA instances. In order to update the CellTree I have
> > to update the DataProvider. I define a updateData function in the
> > CustomTreeModel:
>
> > public void updateData(List<ObjectA> objects){
> >                listDataProvider.setList(objects);  //listDataProvider of
> > the root
> > node level is stored in the CustomTreeModel
> >                listDataProvider.refresh(); //probably not necessary as
> > setList
> > already takes care of refreshing the Tree.
> > }
>
> > Now when I call this method and pass the List of ObjectA instances
> > (one of them has modified List of ObjectB instances). the CellTree
> > doesn't get updated/refreshed.
>
> > My assumption is that listDataProvider.setList() only checks the List
> > of ObjectAs and as I haven't changed anything in the root list but in
> > one of its client lists, the CellTree doesn't get updated. One
> > workaround is that I call listDataProvider.setList(new
> > ArrayList<ObjectA>()) (empty list) before calling setList with the
> > actual list. However this causes the CellTree Nodes to get collapsed,
> > which I want to avoid.
>
> > Another approach would be to store the DataProviders for the ObjectB
> > and ObjectC instances (which I now only create as a local variable and
> > pass it to new DefaultNodeInfo) in the CustomTreeModel and also call
> > setList() on them. But IMHO that's not a really nice way of solving
> > it.
>
> > So basically there are two questions:
>
> > 1.)  When does setList() on the DataAdapter cause the Display to
> > refresh it contents? ( I assume that setList() will only call refresh
> > if the amount of elements is changed -> that's the reason why using
> > the workaround with a new empty ArrayList worked). What happens, if I
> > only change one of the properties? How can I force the DataAdapter to
> > update the Display if the amount of elements doesn't change ?
>
> > 2.) How can I map an object graph (parent -> client objects) to a
> > CellTree or CellBrowser, so that any change to one of the client
> > objects causes a refresh of the Display (CellTree).
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-we...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-toolkit+unsubscribe@googlegroups.com<google-web-toolkit%2Bunsubs cr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment