没用过JSF。up!
在家/公司过节的人,来看一下。

解决方案 »

  1.   

    是不是这个呀?private static Application getApplication() {
    ApplicationFactory appFactory = (ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    return appFactory.getApplication(); 
    }

    private static ValueBinding getValueBinding(String el) {
    return getApplication().createValueBinding(el);
    }
      

  2.   

    费心了,各位大大  xu_xinyu(雪候鸟) 我也是用到的createValueBinding()方法,全部代码如下
    public class MyActionListener implements ActionListener{    public PhaseId getPhaseId(){
         return PhaseId.INVOKE_APPLICATION;
        }
    public void processAction(ActionEvent event)  {
    System.out.println("processAction");
    FacesContext facesContext=FacesContext.getCurrentInstance();
    Object firstNumber=getValueBinding("numberBean.firstNumber").getValue(facesContext);
    Object secondNumber=getValueBinding("numberBean.secondNumber").getValue(facesContext);
    String command=event.getComponent().getId();
    if (command.equals("add")){
    try{
    int firstNo=Integer.parseInt(firstNumber.toString());
    int secondNo=Integer.parseInt(secondNumber.toString());
    String result=Integer.toString(firstNo+secondNo);
    System.out.println("processAction.result"+result);
    getValueBinding("numberBean.result").setValue(facesContext,result);
    }
    catch(Exception e){

    }
    }else if(command.equals("subtract")){
    try{
    int firstNo=Integer.parseInt(firstNumber.toString());
    int secondNo=Integer.parseInt(secondNumber.toString());
    String result=Integer.toString(firstNo-secondNo);
    System.out.println("processAction.result"+result);
    getValueBinding("numberBean.result").setValue(facesContext,result);
    }catch(Exception e){

    }
    } }
    private static Application getApplication() {
    ApplicationFactory appFactory = (ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
    return appFactory.getApplication(); 
    }


    private static ValueBinding getValueBinding(String valueRef){

    return getApplication().createValueBinding(valueRef);                               //预计错误在此
    }
    }
    运行时报错中有如下一条
    javax.faces.el.ReferenceSyntaxException: numberBean.firstNumber
    com.sun.faces.application.ApplicationImpl.createValueBinding(ApplicationImpl.java:281)
    可能还是方法引用的错误
      

  3.   

    getValueBinding()方法用来获得javaBean的属性。