custom component problem

View: New views
3 Messages — Rating Filter:   Alert me  

custom component problem

by Fırat KÜÇÜK :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi i want to use a cutom component with action.

this is my custom button component:

-----------------------------
<?xml version='1.0' encoding='UTF-8' ?>

<ui:composition xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:commandLink styleClass="button" action="#{action}">
    <img src="/img/icons/add.png" alt="" />
    <h:outputText value="#{_.buttonNew}" escape="false" />
  </h:commandLink>
</ui:composition>
-----------------------------

and i cannot use this component like this;
<my:newButton action="#{bean.New}" />

how can i transfer action?

--
FIRAT KÜÇÜK

Re: custom component problem

by Joel Weight :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Funny, I wrote a blog entry about this just a couple weeks ago ( http://digitaljoel.wordpress.com/2009/08/25/passing-action-methods-in-facelets-using-array-notation/

The gist of it is, you can pass the action method separately from the bean.

For instance, to use your component, you would call
<my:newButton bean="#{bean}" myAction="New" />

Then, in your component, you can have
<h:commandLink styleClass="button" action="#{bean[myAction]}" />

Joel


2009/9/28 Fırat KÜÇÜK <firatkucuk@...>
Hi i want to use a cutom component with action.

this is my custom button component:

-----------------------------
<?xml version='1.0' encoding='UTF-8' ?>

<ui:composition xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:commandLink styleClass="button" action="#{action}">
    <img src="/img/icons/add.png" alt="" />
    <h:outputText value="#{_.buttonNew}" escape="false" />
  </h:commandLink>
</ui:composition>
-----------------------------

and i cannot use this component like this;
<my:newButton action="#{bean.New}" />

how can i transfer action?

--
FIRAT KÜÇÜK


Re: custom component problem

by Fırat KÜÇÜK :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

thanks a lot.
excellent blog post.

28 Eylül 2009 18:10 tarihinde Joel Weight <digitaljoel@...> yazdı:
Funny, I wrote a blog entry about this just a couple weeks ago ( http://digitaljoel.wordpress.com/2009/08/25/passing-action-methods-in-facelets-using-array-notation/

The gist of it is, you can pass the action method separately from the bean.

For instance, to use your component, you would call
<my:newButton bean="#{bean}" myAction="New" />

Then, in your component, you can have
<h:commandLink styleClass="button" action="#{bean[myAction]}" />

Joel


2009/9/28 Fırat KÜÇÜK <firatkucuk@...>

Hi i want to use a cutom component with action.

this is my custom button component:

-----------------------------
<?xml version='1.0' encoding='UTF-8' ?>

<ui:composition xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:commandLink styleClass="button" action="#{action}">
    <img src="/img/icons/add.png" alt="" />
    <h:outputText value="#{_.buttonNew}" escape="false" />
  </h:commandLink>
</ui:composition>
-----------------------------

and i cannot use this component like this;
<my:newButton action="#{bean.New}" />

how can i transfer action?

--
FIRAT KÜÇÜK




--
FIRAT KÜÇÜK