You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Udo Schnurpfeil <ud...@atanion.com> on 2005/10/07 10:43:09 UTC
Combining components
I've found a way to combine components to new tags.
There was already some discussion on a similar topic:
http://www.mail-archive.com/users@myfaces.apache.org/msg06438.html
http://www.mail-archive.com/users@myfaces.apache.org/msg06369.html
My first approach was to write a tag file (JSP 2.0) like
(this is a non-working short-sample):
file: inWithLabel.tag
<%@ attribute name="label" %>
<%@ attribute name="value" %>
<%@ attribute name="binding" %>
<t:panel>
<t:label value="${label}">
<t:in value="${value}" binding="${binding}">
</t:panel>
The first tests with "label" and "value" run well.
But I found a big problem: If I want more advanced features like
"binding" I have a problem: If the binding is not set the container will
call setBinding("") with an empty string, which is not allowed.
So I write the Tag by hand:
int doStartTag() {
PanelTag panel = new PanelTag();
panel.setPageContext(pageContext);
panel.doStartTag();
...
}
You can see a real sample here:
http://www.atanion.net/repos/asf/tobago/trunk/core/src/main/org/apache/myfaces/tobago/taglib/extension/InExtensionTag.java
advantage of tag as java class:
* Works with JSP 1.2
* not need rtexpression (JSP EL) inside of JSF tags, which is in
common not allowed.
* setter only will be called, if the value != null
advantage of tag file:
* the tag file looks much more tidy
Regards,
Udo
Re: Combining components
Posted by Martin Marinschek <ma...@gmail.com>.
Cool!
looks good ;)
regards,
Martin
On 10/7/05, Udo Schnurpfeil <ud...@atanion.com> wrote:
> I've found a way to combine components to new tags.
>
> There was already some discussion on a similar topic:
> http://www.mail-archive.com/users@myfaces.apache.org/msg06438.html
> http://www.mail-archive.com/users@myfaces.apache.org/msg06369.html
>
> My first approach was to write a tag file (JSP 2.0) like
> (this is a non-working short-sample):
>
> file: inWithLabel.tag
>
> <%@ attribute name="label" %>
> <%@ attribute name="value" %>
> <%@ attribute name="binding" %>
>
> <t:panel>
> <t:label value="${label}">
> <t:in value="${value}" binding="${binding}">
> </t:panel>
>
> The first tests with "label" and "value" run well.
> But I found a big problem: If I want more advanced features like
> "binding" I have a problem: If the binding is not set the container will
> call setBinding("") with an empty string, which is not allowed.
>
> So I write the Tag by hand:
> int doStartTag() {
> PanelTag panel = new PanelTag();
> panel.setPageContext(pageContext);
> panel.doStartTag();
> ...
> }
> You can see a real sample here:
> http://www.atanion.net/repos/asf/tobago/trunk/core/src/main/org/apache/myfaces/tobago/taglib/extension/InExtensionTag.java
>
> advantage of tag as java class:
> * Works with JSP 1.2
> * not need rtexpression (JSP EL) inside of JSF tags, which is in
> common not allowed.
> * setter only will be called, if the value != null
>
> advantage of tag file:
> * the tag file looks much more tidy
>
> Regards,
>
> Udo
>
--
http://www.irian.at
Your JSF powerhouse -
JSF Trainings in English and German