Well, I sorta solved the problem. It's as good as I can do at the moment. Basically I just created a delegate class that I called ShaleUpdateActionListenerWrapper that implements setProperty(String) and setValue(Object) and creates the proper value bindings from them to setup the actual UpdateActionListener action listener. I've attached it. I define it in my clay-config.xml with

<component jsfid="t:updateActionListener" componentType="com.contentconnections.mpl.common.jsf.ShaleUpdateActionListenerWrapper">
   <attributes>
     <set name="property" bindingType="None" />
     <set name="value" bindingType="VB" />
     <set name="converter" bindingType="VB" />
   </attributes>
 </component>

and use it like

   <element renderId="0" jsfid="commandLink">
     <attributes>
       <set name="action" value="[EMAIL PROTECTED]" />
     </attributes>
     <actionListener jsfid="t:updateActionListener">
       <attributes>
<set name="property" value="[EMAIL PROTECTED]" />
         <set name="value" value="#{page.pageNumber}" />
       </attributes>
     </actionListener>
     <element renderId="0" jsfid="outputText">
       <attributes>
         <set name="value" value="#{page.title}" />
       </attributes>
     </element>
   </element>

If there is a better way of accomplishing this I'd sure like to know what it is.

Thanks again,
Rich

Richard Wallace wrote:
Hello again,

I'm trying to figure out how to use the Tomahawk updateActionListener in Clay. The idea being that you can attach an action listener to a commandLink and when that specific link is clicked a value will be set on a given property of a backing bean. In JSP it would look something like:

<h:commandLink action="go_country">
 <h:outputText value="#{country.name}" />
<t:updateActionListener property="#{selectCountryBackingBean.country}" value="#{country.id}" />
</h:commandLink>

I'm trying to do something like this in Clay. I was trying to use the Tomahawk component but it seems there is actually alot being done in the JSP tag code to take the property and value and creating value bindings from them and setting them on the underlying component, rather than having the component itself figure that stuff out. So it's not easily reused in Clay.

So, my question is has anyone tried this before and if so what, if anything, did you figure out? Should I just create my own component based on the one in tomahawk but with the necessary code moved into the component rather than the tag class (and then give the code back to MyFaces, of course)?

Any other suggestions?

Thanks,
Rich

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


package com.contentconnections.mpl.common.jsf;

import javax.faces.component.StateHolder;
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;

import org.apache.myfaces.custom.updateactionlistener.UpdateActionListener;

public class ShaleUpdateActionListenerWrapper
        implements ActionListener, ValueHolder, StateHolder {

    private UpdateActionListener m_delegate = new UpdateActionListener ();
    
    public void setProperty (String property) {
        m_delegate.setPropertyBinding (FacesContext.getCurrentInstance ().getApplication ().createValueBinding (property));
    }
    
    public void setValue (Object value) {
        m_delegate.setValueBinding (FacesContext.getCurrentInstance ().getApplication ().createValueBinding (value.toString ()));
    }

    public boolean equals (Object obj) {
        return m_delegate.equals (obj);
    }

    public Converter getConverter () {
        return m_delegate.getConverter ();
    }

    public Object getLocalValue () {
        return m_delegate.getLocalValue ();
    }

    public Object getValue () {
        return m_delegate.getValue ();
    }

    public int hashCode () {
        return m_delegate.hashCode ();
    }

    public boolean isTransient () {
        return m_delegate.isTransient ();
    }

    public void processAction (ActionEvent arg0)
            throws AbortProcessingException {
        m_delegate.processAction (arg0);
    }

    public void restoreState (FacesContext arg0, Object arg1) {
        m_delegate.restoreState (arg0, arg1);
    }

    public Object saveState (FacesContext arg0) {
        return m_delegate.saveState (arg0);
    }

    public void setConverter (Converter arg0) {
        m_delegate.setConverter (arg0);
    }

    public void setTransient (boolean arg0) {
        m_delegate.setTransient (arg0);
    }

    public String toString () {
        return m_delegate.toString ();
    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to