Hi Greet,
Ok, just to set things straight, my name is Geert ;-)
I've been playing around the example for RIFE/CRUD and I have some
questions about the customization:
1. The default CRUD impl does not provide dropping a table. If I
want to drop a table, I need to implement a Drop element and a
template for layout. Is this correct?
Yes, this is simply done like this:
ContentQueryManager<YourClass> manager = new
ContentQueryManager<YourClass>(datasource, YourClass.class);
manager.remove();
Ideally I'd like RIFE/Crud to be able to migrate your database
structure when your models change. I haven't found a good way to do
so yet though. If you have any ideas, please tell!
2. If I don't want the layout of the default menu. For example, if
I have a lot of tables, I don't want to show all the table names on
the top-level menu. I want to be able to select them from a drop
down box, can a customized menu element/transformer/template
acheive this?
Yes, it can do anything you like. If you want this to be totally
dynamic and automatically adapting to changes, you'll need to delving
into the internals of RIFE's site structure. However, you don't need
to do so, it can be totally static too.
3. If I don't specify template name as a property to the element,
from the src code it seems that RIFE will throw an exception. By
looking at PrintCrudTemplate, it behaves the same as PrintTemplate.
But in the example most of the elements do not specify template
name as a property. How does the framework figure out which
template to transform?
RIFE itself doesn't automatically select a template, RIFE/Crud does.
It does this by automatically generating the templates and the names
according to your bean class name and the base template name (add,
edit, browse, delete, menu). The method that does this is getTemplate
() in this file: https://svn.rifers.org/rife-crud/trunk/src/
implementations/com/uwyn/rife/crud/elements/admin/CrudElement.java
Most of the work is done in the custom template transformer, which
implicitly also caches the transformation.
Using templates in RIFE is just one way to output text content, you
can use anything else, this means that you normally always need to
instantiate a template yourself if you want to use it. You can
however inject an instance through IoC though.
4. Based on my guessing about 3, For the CRUD example, if I added a
new bean (NewTest) and I want to use my own template for add &
edit. all I need to do is to define the following:
<subsite id="NEWTEST"
file="crud:com.uwyn.rife.crud.samples.beans.NewTest" urlprefix="/
newtest">
<property name="crud_template_name-add">admin.new_add</property>
<property name="crud_template_name-edit">admin.new_edit</property>
</subsite>
Is this correct?
Yes, beware though that the creation of these templates is not
trivial, since you need to escape the actual template tags that need
to be available after the transformation. The reason for this is that
the templates you provide like this are generic blueprints that have
to contain all the elements to build the final transformed templates
according to the constraints and beans.
Geert
--
Geert Bevin Uwyn bvba
"Use what you need" Avenue de Scailmont 34
http://www.uwyn.com 7170 Manage, Belgium
gbevin[remove] at uwyn dot com Tel +32 64 84 80 03
PGP Fingerprint : 4E21 6399 CD9E A384 6619 719A C8F4 D40D 309F D6A9
Public PGP key : available at servers pgp.mit.edu, wwwkeys.pgp.net
_______________________________________________
Rife-users mailing list
[email protected]
http://www.uwyn.com/mailman/listinfo/rife-users