Hello,
sorry for my english first. It is not the best.
Now to my question. At the moment im learning qooxdoo and i am using it
to rewrite some Javascript based "media browser" in an private CMS-System.
A generall overview. It works like a file explorer. A tree with folders
is shown. A user can select a folder and then he see all files/images in
this folder. So far i encountered less problems. But i am now at the file
show/handling and i now have some questions. I don't knew if what i created
is "correct" or how i go further.
So first what i want. I want to show all my files in a Flow Layout. I
created a custom widget for it. I also created a controller that now
updates the view automatically. Whenever i add something to the model or
change an item the view gets automatically updated.
But i don't have the "selection feature". And overall i don't knew if my use
of the controller is correct. So a short discreption of my mini example
what i have done so far.
A model Class "layout.model.File". This is a basic qx.core.Object. It just
contained two properties. A title and a name. A second class
"layout.model.Model". This class is just an simple example of the Store.
At the moment it just creates a bunch of layout.model.File Objects in memory
in a qx.data.Array and stores them in the propertie "files".
I created a view layout.view.File that is just the view for an
layout.model.File object. Just keep in mind it is just a minimal example.
I readed the TweetView Tutorial and build the View with help from that
Tutorial.
Now to my greatest problems. The controller. Because i want automatic
creating/deleting and changing when i do it to the model. I also want that
the user can select some image i thought i can use a qx.data.controller.List
for it.
So what i have written is this
// flow layout
var flow = new qx.ui.layout.Flow();
var container = new qx.ui.container.Composite(flow);
doc.add(container);
// my model
var model = new layout.model.Model();
// Setup Controller
var controller = new qx.data.controller.List(null, container);
controller.setDelegate({
createItem: function(){
return new layout.view.File();
},
bindItem: function(controller, item, id){
controller.bindProperty("title", "title", null, item, id);
controller.bindProperty("image", "image", null, item, id);
}
});
model.bind("files", controller, "model");
I create the Flow layout with a Composite container. Later i used this
container in the controller. Now this is what i am unsure if this is okay.
The example is working. But i don't knew if just using a container is
correct. In all examples that i can find all uses a qx.ui.form.List. But
in my example i don't want the layout of an qx.ui.form.List Widget.
If i add code that adds an image and change a title, well it is working.
// 5 seconds timeout to add an image
qx.event.Timer.once(function(){
var image =
qx.util.ResourceManager.getInstance().toUri("layout/sample.jpg");
model.getFiles().push(new layout.model.File({title: "Neues Item",
image: image}));
}, this, 5000);
// 10 seconds timeout to change title name
qx.event.Timer.once(function(){
var file = model.getFiles().toArray()[0];
file.setTitle("Foo renamed");
}, this, 10000);
It works. An image gets added after 5 seconds of the application startup
and later the first title of the first image gets renamed. That's working
so far.
But when i try to catch the selection
// debug selections
controller.getSelection().addListener("change", function(e){
console.info(e);
}, this);
I never get something on my console. Either way my code for selection is
wrong. Or i just need to expand my example to add selection.
So here my question. Is it correct to just use a container with a Flow
layout in a qx.data.controller.List? If yes, what do i need to add to get
a selection of items?
At the moment i think qx.data.controller.List is just really for a
qx.ui.form.List widget. Or in the documentation it is mentioned that target
only could be one of "qx.ui.form.List", "qx.ui.form.SelectBox" or
"qx.ui.form.ComboBox".
If the later is the case is there anywhere some documentation/tutorial that
explains how to
create a controller?
What i need is a controller just like the List Controller. I need
a controller that synchronize my model with the view. And i also need
selection of my items and filtering/sorting.
But i can't find any informationen about it how to create something like
that in Qooxdoo. I already read everything under
http://manual.qooxdoo.org/current/pages/data_binding.html but that doesn't
help me at all. I already use everything that is mentioned there. And
the documentation is more a general explanation what a controller is.
Can somebody just point me to the direction how i can create a controller
that does what i want?
I also can share some more code if wanted/needed.
--
View this message in context:
http://qooxdoo.678.n2.nabble.com/Creating-Using-a-controller-in-a-custom-widget-tp7583088.html
Sent from the qooxdoo mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel