org.apache.myfaces.custom.updateactionlistener
Class UpdateActionListener

java.lang.Object
  extended by org.apache.myfaces.custom.updateactionlistener.UpdateActionListener
All Implemented Interfaces:
java.util.EventListener, javax.faces.component.StateHolder, javax.faces.component.ValueHolder, javax.faces.event.ActionListener, javax.faces.event.FacesListener

public class UpdateActionListener
extends java.lang.Object
implements javax.faces.event.ActionListener, javax.faces.component.ValueHolder, javax.faces.component.StateHolder

Set an arbitrary property on a managed bean when an "action" component is selected by the user.

An instance of this listener type can be attached to any UIComponent which is an ActionSource (eg a link or button). When the associated component fires its action event, this listener will read the value specified by attribute "value" and assign it to the property specified by attribute "property". The value attribute may be a literal value or may be a value-binding; the property is always expected to be a value-binding.

An optional Converter may be associated with this listener, and if present will be invoked to convert the value to the datatype expected by the target property. When no converter is available, a default one will be retrieved from the Application object.

A common use for this listener is to attach it to an HtmlCommandLink component, storing some constant value into a managed bean property. After the navigation associated with that link is done, components in the new view can look at that property to determine which link was clicked.

Both the fetching of "value" and the updating of "property" occur in the invoke-application phase unless "immediate" is set on the ActionSource component in which case they both occur in the apply-request-values phase. The update is guaranteed to occur before the invocation of the method specified by attribute "action" on the ActionSource (because all actionListeners are executed before the action attribute).

JSF 1.2 introduces a "setPropertyActionListener" with the same functionality like this.

Version:
$Revision: 472638 $ $Date: 2006-11-08 15:54:13 -0500 (miƩ, 08 nov 2006) $
Author:
Manfred Geiler (latest modification by $Author: grantsmith $)

Constructor Summary
UpdateActionListener()
           
 
Method Summary
 javax.faces.convert.Converter getConverter()
           
 java.lang.Object getLocalValue()
           
 javax.faces.el.ValueBinding getPropertyBinding()
           
 java.lang.Object getValue()
           
 javax.faces.el.ValueBinding getValueBinding()
           
 boolean isTransient()
           
 void processAction(javax.faces.event.ActionEvent actionEvent)
           
 void restoreState(javax.faces.context.FacesContext context, java.lang.Object state)
           
 java.lang.Object saveState(javax.faces.context.FacesContext context)
           
 void setConverter(javax.faces.convert.Converter converter)
           
 void setPropertyBinding(javax.faces.el.ValueBinding propertyBinding)
           
 void setTransient(boolean newTransientValue)
           
 void setValue(java.lang.Object value)
           
 void setValueBinding(javax.faces.el.ValueBinding valueBinding)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UpdateActionListener

public UpdateActionListener()
Method Detail

setPropertyBinding

public void setPropertyBinding(javax.faces.el.ValueBinding propertyBinding)

getPropertyBinding

public javax.faces.el.ValueBinding getPropertyBinding()

setValue

public void setValue(java.lang.Object value)
Specified by:
setValue in interface javax.faces.component.ValueHolder

getValue

public java.lang.Object getValue()
Specified by:
getValue in interface javax.faces.component.ValueHolder

getLocalValue

public java.lang.Object getLocalValue()
Specified by:
getLocalValue in interface javax.faces.component.ValueHolder

getValueBinding

public javax.faces.el.ValueBinding getValueBinding()

setValueBinding

public void setValueBinding(javax.faces.el.ValueBinding valueBinding)

getConverter

public javax.faces.convert.Converter getConverter()
Specified by:
getConverter in interface javax.faces.component.ValueHolder

setConverter

public void setConverter(javax.faces.convert.Converter converter)
Specified by:
setConverter in interface javax.faces.component.ValueHolder

processAction

public void processAction(javax.faces.event.ActionEvent actionEvent)
                   throws javax.faces.event.AbortProcessingException
Specified by:
processAction in interface javax.faces.event.ActionListener
Throws:
javax.faces.event.AbortProcessingException

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext context)
Specified by:
saveState in interface javax.faces.component.StateHolder

restoreState

public void restoreState(javax.faces.context.FacesContext context,
                         java.lang.Object state)
Specified by:
restoreState in interface javax.faces.component.StateHolder

isTransient

public boolean isTransient()
Specified by:
isTransient in interface javax.faces.component.StateHolder

setTransient

public void setTransient(boolean newTransientValue)
Specified by:
setTransient in interface javax.faces.component.StateHolder


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.