Created
November 13, 2014 01:33
-
-
Save wakim/58767d812dc27661f141 to your computer and use it in GitHub Desktop.
Usando ActionListener para interceptar actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.wakim.teste_jsf.util; | |
import javax.el.MethodExpression; | |
import javax.el.MethodInfo; | |
import javax.faces.component.UICommand; | |
import javax.faces.context.FacesContext; | |
import javax.faces.event.AbortProcessingException; | |
import javax.faces.event.ActionEvent; | |
import javax.faces.event.ActionListener; | |
public class CustomActionListener implements ActionListener { | |
@Override | |
public void processAction(ActionEvent event) throws AbortProcessingException { | |
System.out.println(event.getSource()); | |
System.out.println(event.getComponent()); | |
UICommand command = (UICommand) event.getSource(); | |
MethodExpression method = command.getActionExpression(); | |
MethodInfo mi = method.getMethodInfo(FacesContext.getCurrentInstance().getELContext()); | |
System.out.println(mi.getName()); | |
System.out.println(event); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
JBoss, Home of Professional Open Source | |
Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual | |
contributors by the @authors tag. See the copyright.txt in the | |
distribution for a full listing of individual contributors. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
--> | |
<!-- This file is not required if you don't need any extra configuration. --> | |
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation=" | |
http://java.sun.com/xml/ns/javaee | |
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> | |
<!-- This descriptor activates the JSF 2.0 Servlet --> | |
<!-- Write your navigation rules here. You are encouraged to use CDI for | |
creating @Named managed beans. --> | |
<application> | |
<action-listener>br.com.wakim.teste_jsf.util.CustomActionListener</action-listener> | |
</application> | |
</faces-config> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment