Re: BImage ?
Franck Routier <[email protected]> Tue, 12 Dec 2006 17:21:25 +0100
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format...
------------=_1165940485-18037-118
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Jacob Kjome a =E9crit :
> I haven't looked at the stuff in a while, but I'll give a little backgrou=
nd on
> why I added the marker interface. There had been some users that wanted =
to
> write custom components that failed to render. They failed because the
> rendering code didn't have a generic way of reacting to complex components
> generically. I took at look at the existing code and found that BList, B=
Table,
> and BTemplate were specifically called out as exceptions to certain rende=
ring
> logic. So, I decided to create the BCompundComponent interface as a way =
for
> the rendering code to recognize custom compound components in the same wa=
y it
> does the core compound component exceptions. So, I didn't change the ren=
dering
> logic. I only made it so it wasn't so unforgiving to custom components.
>=20=20=20
Well, I have now a working example of composed, or nested, components.=20
Hurrah ! :-)
So I can basically do somethig like this in a BTemplateModel :
if (key.equals("Recurs")){
AInput bi =3D new AInput(BInput.TEXT,"Nested_AInput","Value=
");
BImage img =3D new BImage("Nested=20
image","images/stade.png","15","15");
bi.addChild(img);
return new BLabel("Nested label : ",bi); // this=20
constructor adds bi as a child to BLabel
and it will happily render as :
<LABEL for=3D"Nested_AInput">Nested label : <INPUT type=3D"text"=20
value=3D"Value"><IMG alt=3D"Nested image" height=3D"15" src=3D"images/stade=
.png"=20
title=3D"Nested image" width=3D"15"></LABEL>
Great.
Now, what did I do to obtain that ?..
1) I had to implement BCompoundComponent on every nested component (and=20
on the parent component as well).
This is especially unconvinient as you can't tell in advance if a=20
BComponent will be nested or not (and it can be sometimes, and not some=20
other times).
That is why you can see a AInput above : it is a BInput implementing=20
BCompoundComponent.
So there would be a first modification of BContainer and=20
AbstractBCompnent, allowing to dynacally setCompound(true) when nesting=20
a component.
2) I had to implement createDefaultNode in the renderers of the=20
components I used, and to recursively call createDefaultNode on every child.
As I only have a single node at first (the one with the=20
Dir::Get_Data.Tests.Recurs directive), I need to create children nodes=20
of the right types. And I need to give each child, and each child of the=20
children, a chance to get in.
There could be another evolution here : either create another interface=20
(NestableComponent) to make sure every nested component implements this=20
behaviour, and implement it on some components or make this the default=20
for every BComponent.
Not sure for the 2nd point...
> The solution may have been naive on my part because I can't say that I re=
ally
> dug in to understand the reasons why said core components were exceptions=
in
> rendering; I only genericized their treatment. Why the rendering code is=
the
> way it is, is something to research and/or bring up with Christian or oth=
er
> original writers of that code. As you found, the code is very complex, a=
nd
> simplification may be the order of the day.
>=20=20=20
As I understand it, the problem is that these components iteratively add=20
child nodes, andTemplateHelper also tries to do this to catch any=20
embedded directive in the nodes returned by its model. Doing both seems=20
to lead to StackOverflow... Humm... This is still a bit unclear to me,=20
but I'm positive on the StackOverflow ! :)
> BTW, if you decide to really start digging into Barracuda, I would certai=
nly
> consider proposing a vote for committer status. Barracuda could use some=
more
> active development. Let me know if you are interested, for starters.
>=20=20=20
I will certainly dig into Barracuda, as it will be part of a major=20
project to us here at work. So I will have time to do this, and would be=20
willing to help.
So yes, I would be interested.
Regards,
Franck
------------=_1165940485-18037-118
Content-Type: text/plain; name="message-footer.txt"
Content-Disposition: inline; filename="message-footer.txt"
Content-Transfer-Encoding: 8bit
--
Barracuda mailing list
[email protected]
http://www.objectweb.org/wws/lists/projects/barracuda
------------=_1165940485-18037-118--