2015-02-23 36 views
0

我正在使用ADF BC,并且我有几个inputTexts。 假设我有以下情景:来自inputText的更新值

步骤1:在三个不同的inputText(it1,it2和it3,所有三个都使用autoSubmit == true)中插入1,2,3。

步骤2:点击一个按钮调用谁以下方法:

public String aplicarFiltro() { 
     Object it1param = null, it2param = null, it3param = null, sos1param = null; 
     Parametros_IndicadoresLoadAll pila = Parametros_IndicadoresLoadAll.getInstance(); 
     pila.clear(); 
      if(it1.getValue() == null || it1.getValue().toString().isEmpty()) { 
       it1param = ""; 
      } else { 
       it1param = it1.getValue(); 
       if(it2.getValue() == null || it2.getValue().toString().isEmpty()) { 
        it2param = ""; 
       } else { 
        it2param = it2.getValue(); 
        if(it3.getValue() == null || it3.getValue().toString().isEmpty()) { 
         it3param = ""; 
        } else { 
         it3param = it3.getValue(); 
        } 
       } 

      } 

      if(sos1.getValue() != null) { 
       sos1param = sos1.getValue(); 
      } 
     pila.init(it1param, it2param, it3param, sos1param); 
     if (it1.getValue() == null || it1.getValue().toString().isEmpty()) { 
      showPopup(p1, true); 
    /*  } else if (sos3.getValue() == null) { 
      showPopup(p2, true); */ 

     } 
     return null; 
    } 

第3步:我抹掉IT2和IT3的价值观,我再次点击按钮和调用相同的方法。但是,it2和it3的值保持不变。

为什么会发生这种情况,我该如何解决?

回答

0

尝试重新思考你的方法:不是在支持豆做的业务,尝试使用BC层。因此,您可以将方法

public String aplicarFiltro(){..}转换为Application Module Impl。 在那里,通过编程的方式获得你的VO当前行的引用并读取属性的值。

首先,从BC Tester测试你的场景(你的方法)。然后,您可以通过绑定公开方法,并从后台bean中调用它。 此外,我会为您的VO公开RowImpl类,并将一些调试信息放入setIt1(),setIt2(),setIt3()属性中,以查看更改方式。

请记住,在BC层管理业务总比管理bean简单得多。远离JSF生命周期。

0

不知道是否有更多的事情是错的。但是,如果i1的值为“i2param”,而只有i1和i2的值为“i3param”时,才会将“i2param”设置为null以外的值。

因此,从以下开始。更改此:

 if(it1.getValue() == null || it1.getValue().toString().isEmpty()) { 
      it1param = ""; 
     } else { 
      it1param = it1.getValue(); 
      if(it2.getValue() == null || it2.getValue().toString().isEmpty()) { 
       it2param = ""; 
      } else { 
       it2param = it2.getValue(); 
       if(it3.getValue() == null || it3.getValue().toString().isEmpty()) { 
        it3param = ""; 
       } else { 
        it3param = it3.getValue(); 
       } 
      } 

     } 

到:

if(it1.getValue() == null || it1.getValue().toString().isEmpty()) { 
    it1param = ""; 
} else { 
    it1param = it1.getValue(); 
} 

if(it2.getValue() == null || it2.getValue().toString().isEmpty()) { 
    it2param = ""; 
} else { 
    it2param = it2.getValue(); 
} 

if(it3.getValue() == null || it3.getValue().toString().isEmpty()) { 
    it3param = ""; 
} else { 
    it3param = it3.getValue(); 
} 
+0

这不能解决我的问题,但你是对的。我需要小心这个 – SaintLike 2015-02-23 11:23:17