2015-02-23 71 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