Hi, Georg,
yes, there are some (quite ugly) solutions:
http://www.ibm.com/developerworks/java/library/j-facelets2.html
Component with the same problem/solution:
http://code.google.com/p/trinidadcomponents
Cheers,
Walter Mourão
http://waltermourao.com.br
http://arcadian.com.br
http://oriens.com.br
On Mon, Apr 12, 2010 at 8:56 AM, Georg Füchsle <gi...@googlemail.com>wrote:
> Hallo,
>
> I use JSF 1.2 with Facelets and Tomahawk.
>
> Now I would like to make a facelets custom component for a navigation
> / toolkit bar (button panel) that looks the same in every page. This
> component should exist of a number of <t:commandButtons that can be
> defined by calling this custom component.
>
> I thougt about something like this:
>
> In a file 'btnPanel.xhtml':
> <span xmlns="http://www.w3.org/1999/xhtml"
> xmlns:f="http://java.sun.com/jsf/core"
> xmlns:h="http://java.sun.com/jsf/html"
> xmlns:ui="http://java.sun.com/jsf/facelets"
> xmlns:t="http://myfaces.apache.org/tomahawk"
> xmlns:c="http://java.sun.com/jstl/core">
>
> <ui:composition>
> <ui:param name="btn1Value" value="#{btn1Value}"/>
> <ui:param name="btn1Action" value="#{btn1Action}"/>
>
> .....
>
> </span>
>
>
> I would define this as a custom tag:
>
> <tag>
> <tag-name>btnPanel</tag-name>
> <source>../pages/btnPanel.xhtml</source>
> </tag>
>
>
> Finally I want to call this control in my xhtml-pages like this:
>
> <safir:btnPanel btn1Value="save" btn1Action="#{mbBean.save}"/>
>
> But I realised that it is not possible to define a variable action for
> my custom control like this. Actually this way JSF looks for a method
> mbBean.getSave() instead of performing the action mbBean.save()
>
>
> Is there another way to do that?
>
> Thanks in advance
>
>
> Georg
>
Actually the only way in JSF 1.2 to do this really is to write a tag
handler to generate a method binding somone pointed out the links which
explain it. So no further explanation here.
But there is hope,JSF 2.0 allows to do that from Facelets itself via its
composite interface definitions, this will achieve exactly what you need.
<composite:interface>
<composite:attribute name="saveLabel"
required="false" default="Save"/>
<composite:attribute name="action" required="true"
targets="save" method-signature="java.lang.String f()"/>
</composite:interface>
<composite:implementation>
<h:commandButton id="save" value="#{cc.attrs.saveLabel}" />
</composite:implementation>
...
will result in <mc:myButton action="#{customerBean.save}" />
Just as additional note, this looks like a lot Locs per component but
have in mind, that usually you have a snippet of html instead of just
one tag in the implementation section of your composite component, so in
reality things look a little bit less like interface bloat :-)
I just wanted to add this info to the thread.
Werner
Am 12.04.10 14:59, schrieb Walter Mourão:
> Hi, Georg,
>
> yes, there are some (quite ugly) solutions:
> http://www.ibm.com/developerworks/java/library/j-facelets2.html
>
> Component with the same problem/solution:
> http://code.google.com/p/trinidadcomponents
>
> Cheers,
>
> Walter Mourão
> http://waltermourao.com.br
> http://arcadian.com.br
> http://oriens.com.br
>
>
>
> On Mon, Apr 12, 2010 at 8:56 AM, Georg Füchsle<gi...@googlemail.com>wrote:
>
>> Hallo,
>>
>> I use JSF 1.2 with Facelets and Tomahawk.
>>
>> Now I would like to make a facelets custom component for a navigation
>> / toolkit bar (button panel) that looks the same in every page. This
>> component should exist of a number of<t:commandButtons that can be
>> defined by calling this custom component.
>>
>> I thougt about something like this:
>>
>> In a file 'btnPanel.xhtml':
>> <span xmlns="http://www.w3.org/1999/xhtml"
>> xmlns:f="http://java.sun.com/jsf/core"
>> xmlns:h="http://java.sun.com/jsf/html"
>> xmlns:ui="http://java.sun.com/jsf/facelets"
>> xmlns:t="http://myfaces.apache.org/tomahawk"
>> xmlns:c="http://java.sun.com/jstl/core">
>>
>> <ui:composition>
>> <ui:param name="btn1Value" value="#{btn1Value}"/>
>> <ui:param name="btn1Action" value="#{btn1Action}"/>
>>
>> .....
>>
>> </span>
>>
>>
>> I would define this as a custom tag:
>>
>> <tag>
>> <tag-name>btnPanel</tag-name>
>> <source>../pages/btnPanel.xhtml</source>
>> </tag>
>>
>>
>> Finally I want to call this control in my xhtml-pages like this:
>>
>> <safir:btnPanel btn1Value="save" btn1Action="#{mbBean.save}"/>
>>
>> But I realised that it is not possible to define a variable action for
>> my custom control like this. Actually this way JSF looks for a method
>> mbBean.getSave() instead of performing the action mbBean.save()
>>
>>
>> Is there another way to do that?
>>
>> Thanks in advance
>>
>>
>> Georg
>>
>
Hi Walter,
thanks for the fast answer.
I tried it like that and it worked at once:
I defined a custom control in a file 'schalterpanel.xhtml'
<span xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:t="http://myfaces.apache.org/tomahawk">
<ui:composition>
<t:commandButton value="#{BtnName1}"
disabled="#{BtnDisabled1}"
rendered="#{BtnVis1}"
action="#{BackingBean1[Action1]}">
</t:commandButton>
</ui:composition>
</span>
Then I defined the custom control like this:
<tag>
<tag-name>schalterpanel</tag-name>
<source>../pages/schalterpanel.xhtml</source>
</tag>
And then I can use my custom control like this:
<safir:schalterpanel BtnName1="save"
BtnVis1="true"
BtnDisabled1="#{mbBean.btnVis}"
BackingBean1="#{mbBean}"
Action1="save"/>
Now my button is displayed and clicking the button the action
mbBean.save() is performed!
Maybe You are right, it is a bit ugly, but it is sufficient for me. It
is a pity that i don't really understand why
action="#{BackingBean1[Action1]}" is resolved into mbBean.save()...
Thanks a lot!
Cheers
Georg
2010/4/12 Walter Mourão <wa...@gmail.com>:
> Hi, Georg,
>
> yes, there are some (quite ugly) solutions:
> http://www.ibm.com/developerworks/java/library/j-facelets2.html
>
> Component with the same problem/solution:
> http://code.google.com/p/trinidadcomponents
>
> Cheers,
>
> Walter Mourão
> http://waltermourao.com.br
> http://arcadian.com.br
> http://oriens.com.br
>
>
>
> On Mon, Apr 12, 2010 at 8:56 AM, Georg Füchsle <gi...@googlemail.com>wrote:
>
>> Hallo,
>>
>> I use JSF 1.2 with Facelets and Tomahawk.
>>
>> Now I would like to make a facelets custom component for a navigation
>> / toolkit bar (button panel) that looks the same in every page. This
>> component should exist of a number of <t:commandButtons that can be
>> defined by calling this custom component.
>>
>> I thougt about something like this:
>>
>> In a file 'btnPanel.xhtml':
>> <span xmlns="http://www.w3.org/1999/xhtml"
>> xmlns:f="http://java.sun.com/jsf/core"
>> xmlns:h="http://java.sun.com/jsf/html"
>> xmlns:ui="http://java.sun.com/jsf/facelets"
>> xmlns:t="http://myfaces.apache.org/tomahawk"
>> xmlns:c="http://java.sun.com/jstl/core">
>>
>> <ui:composition>
>> <ui:param name="btn1Value" value="#{btn1Value}"/>
>> <ui:param name="btn1Action" value="#{btn1Action}"/>
>>
>> .....
>>
>> </span>
>>
>>
>> I would define this as a custom tag:
>>
>> <tag>
>> <tag-name>btnPanel</tag-name>
>> <source>../pages/btnPanel.xhtml</source>
>> </tag>
>>
>>
>> Finally I want to call this control in my xhtml-pages like this:
>>
>> <safir:btnPanel btn1Value="save" btn1Action="#{mbBean.save}"/>
>>
>> But I realised that it is not possible to define a variable action for
>> my custom control like this. Actually this way JSF looks for a method
>> mbBean.getSave() instead of performing the action mbBean.save()
>>
>>
>> Is there another way to do that?
>>
>> Thanks in advance
>>
>>
>> Georg
>>
>
Hello, can someone tell me what should be described in the section "Configuration development" of the "Developers Guide" on the Tobago homepage. http://myfaces.apache.org/trinidad/devguide/installation.html The section is cut somehow but I'm inetersted what are helpful settings for the developmemt. Regards Michael