How can I implement my own ActionListener in JSF.
I require it to attach this action listener to dynamic component which I am building..
I am trying to use MethodExpression like this:-
HtmlCommandLink link = new HtmlCommandLink();
link.setId("linkId");
FacesContext context = FacesContext.getCurrentInstance();
MethodExpression methodExpression = context.getApplication().getExpressionFactory().createMethodExpression(
context.getELContext(), "#{bean.actionListener}", null, new Class[] { ActionEvent.class });
link.addActionListener(new MethodExpressionActionListener(methodExpression));
However is there any other way to attach a custom actionListener to a dynamically generated component.Also what exactly is the use of MethodExpression in this context.
One point is that addActionListener take MethodExpressionActionListener as the argument and we need to specify methodExpression object in that..
But what can be the real functionality behind this..I went through the javadoc of MethodExpression but I found it not to be of much use.
The type of the argument of
addActionListeneris ActionListener. Use this instead of MethodExpressionActionListener, it is an interface with a single method:(MethodExpressionActionListener implements this interface)