trsvax / tapestry-bootstrap

Tapestry module for Twitter Bootstrap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Design considerations

felixscheffer opened this issue · comments

Hi Barry,

thanks for creating this project. Helps a lot.

I looked at the code and it's a little bit complicated.
Instead of having one mixin (FW) that will be assinged to EVERY component, wouldnt it be much easier to write a mixin for every BootstrapProvider.

We could then contribute a list of assignments of these mixins to components to a ComponentClassTransformWorker2.

public static void contributeMixinAssignments(MappedConfiguration<String, MixinAssignmnt> conf) {

conf.add("bootstrap-grid", new MixinAssignment(Grid.class, TableProviderMixin.class);
conf.add("bootstrap-beaneditform", new MixinAssignment(BeanEditForm.class, FormProviderMixin.class);
...
}

So mixins would only be assigned where needed.

The MappedConfiguration is necessary so the user can remove an assignment and stick with the Tapestry styling. He/she could still add one of these mixins as needed, so mixing Bootstrap and Tapestry styling would be possible.

Assuming the "bootstrap-grid" assignment would have been removed:

<!-- Tapestry styling as usual -->
<t:grid ...></t:grid>

<!-- Bootstrap styling with table border -->
<t:grid t:mixins="TableProviderMixin" class="table table-bordered" ...></t:grid>

This is just some brainstorming, but if you like, I could implement it too (maybe version 2.1 or something).

Anyway, there are one minor things:

  • BeanEditor (aka BeanEditForm without the form) should be supported.

Felix Scheffer

I think having multiple mixins would make some parts easier and some parts harder. Part of the goal was to support things other than Bootstrap. With the current code you can plug in other providers behind the FW mixin and support anything you like. That said it is more complicated than I would like and I think it could be cleanup up a bit.

The current implementation supports Tapestry and Bootstrap styling at the same time. With the default configuration

<t:grid>/t:grid

will result in a Tapestry styled table while

<t:grid t:fwtype="table">/t:grid

will style the table with Bootstrap. It's possible to override this and make the default style be Bootstrap.

I'll add BeanEditor support.

Thanks for the BeanEditor support.

Can you go into detail about what would be harder? Or the advantage in general of having a single/central (framework) mixin?

Because as far as i understand it looks like you're recreating a mechanism that's already existing in Tapestry5.
Mixins already allow you to do anything you trying to achieve here.

Anyway, if you could clean up the code, that would be much appreciated.
Then i could reuse some of your code for a mixin-approach.

Thx
Felix Scheffer

I wanted everything to happen automatically so it appears Tapestry supports Bootstrap out of the box. I did not want to add the mixins in the tml file like

<t:grid t:mixins="TableProviderMixin"

You could create a bunch of mixins and add them with a worker but then you need some kind of configuration to know which mixin goes with which component.

There is also a render phase in the current implementation not supported by mixins. There is a method that's called after the page is completely rendered.

The current implementation is a chain of command which means multiple providers can do work on a single component.

When I prototyped the code I did just write mixins but I switched to this way because in part because it seemed easier and partly because i needed to run some code after the page was completely rendered.

Thanks! That's helpful!