1 16 package org.apache.myfaces.examples.example1; 17 18 import javax.faces.component.UIComponent; 19 import javax.faces.context.FacesContext; 20 import javax.faces.el.VariableResolver; 21 import javax.faces.event.AbortProcessingException; 22 import javax.faces.event.ActionEvent; 23 import javax.faces.event.ActionListener; 24 25 30 public class CalcActionListener 31 implements ActionListener 32 { 33 public void processAction(ActionEvent event) throws AbortProcessingException 34 { 35 FacesContext facesContext = FacesContext.getCurrentInstance(); 36 UIComponent component = event.getComponent(); 37 38 VariableResolver vr = facesContext.getApplication().getVariableResolver(); 39 CalcForm form = (CalcForm)vr.resolveVariable(facesContext, "calcForm"); 40 if (component.getId().equals("addButton") || 41 component.getId().equals("href1")) 42 { 43 form.add(); 44 } 45 else 46 { 47 form.subtract(); 48 } 49 } 50 51 } 52 | Popular Tags |