You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Rafael Nami <ra...@gmail.com> on 2005/11/04 13:16:46 UTC

Trying to write my own component - AGAIN

Hi everyone, and thanks for the explanations about packing a component.
Im trying to write now a Graphics component. I already have a
GraphicFactory, that
receives a model object, and convert its attributes in coordinates. I'm
trying to
follow the approach that is described in Core JSF - chapter 12. I just want
to know one thing:
1 - How can I add something like:
<e:graphics value="#{bean.getGraphicModel}"/>, where this backingbean method
returns this
model object, filling the component with the model object in one fellow
swoop.
Did I have to do some Binding code, because it's just a output component.
Did I have to only write the encodeBegin() method in the Tag??

Thanks and Best Regards

Rafael Mauricio Nami

Re: Trying to write my own component - AGAIN

Posted by Rafael Nami <ra...@gmail.com>.
Thanks Bruno, I'm studying the source since yesterday :).
I was trying to code it in the encodeBegin, but nothing displayed. I'll try
to code in the encodeEnd() method, following the schedule like you said.

Best Regards

Rafael Mauricio Nami

2005/11/4, Bruno Aranda <br...@gmail.com>:
>
> I think that the best option to see how to implement a component is
> directly check out the sources for the tomahawk/sandbox components.
> Every component has the component, tag, and renderer implementation.
> You can check the faces-config.xml file to see how this components are
> registered and also the tld.
> About your specific questions: you don't need any binding if your
> component has everything in it (save/restore state, etc). Just pass
> the model to the value attribute (I guess it should be something like
> value="#{bean.graphicModel" (without the getter)). Take a look at the
> schedule component, as it accepts a custom model object.
> The encodeBegin is optional as long as your component does not render
> any children. When a component has children, the method encodeBegin is
> called before and the encodeEnd afterwars. In your case, I guess you
> only need the encodeEnd in your renderer object (recommended).
>
> HTH,
>
> Bruno
>
> 2005/11/4, Rafael Nami <ra...@gmail.com>:
> > Hi everyone, and thanks for the explanations about packing a component.
> > Im trying to write now a Graphics component. I already have a
> > GraphicFactory, that
> > receives a model object, and convert its attributes in coordinates. I'm
> > trying to
> > follow the approach that is described in Core JSF - chapter 12. I just
> want
> > to know one thing:
> > 1 - How can I add something like:
> > <e:graphics value="#{bean.getGraphicModel}"/>, where this backingbean
> > method returns this
> > model object, filling the component with the model object in one fellow
> > swoop.
> > Did I have to do some Binding code, because it's just a output
> component.
> > Did I have to only write the encodeBegin() method in the Tag??
> >
> > Thanks and Best Regards
> >
> > Rafael Mauricio Nami
> >
>

Re: Trying to write my own component - AGAIN

Posted by Bruno Aranda <br...@gmail.com>.
I think that the best option to see how to implement a component is
directly check out the sources for the tomahawk/sandbox components.
Every component has the component, tag, and renderer implementation.
You can check the faces-config.xml file to see how this components are
registered and also the tld.
About your specific questions: you don't need any binding if your
component has everything in it (save/restore state, etc). Just pass
the model to the value attribute (I guess it should be something like
value="#{bean.graphicModel" (without the getter)). Take a look at the
schedule component, as it accepts a custom model object.
The encodeBegin is optional as long as your component does not render
any children. When a component has children, the method encodeBegin is
called before and the encodeEnd afterwars. In your case, I guess you
only need the encodeEnd in your renderer object (recommended).

HTH,

Bruno

2005/11/4, Rafael Nami <ra...@gmail.com>:
> Hi everyone, and thanks for the explanations about packing a component.
>  Im trying to write now a Graphics component. I already have a
> GraphicFactory, that
>  receives a model object, and convert its attributes in coordinates. I'm
> trying to
>  follow the approach that is described in Core JSF - chapter 12. I just want
> to know one thing:
>  1 - How can I add something like:
>  <e:graphics value="#{bean.getGraphicModel}"/>, where this backingbean
> method returns this
>  model object, filling the component with the model object in one fellow
> swoop.
>  Did I have to do some Binding code, because it's just a output component.
>  Did I have to only write the encodeBegin() method in the Tag??
>
>  Thanks and Best Regards
>
>  Rafael Mauricio Nami
>