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<giofy...@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




Reply via email to