2010-02-11 52 views

回答

1

是的,你可以。您只需確保實例在實際請求期間可用。

E.g.

<h:inputText valueChangeListener="#{bean.nested.change}" /> 
結合

public class Bean { 
    private Nested nested; // +getter 
} 

public class Nested { 
    public void change(ValueChangeEvent event) { 
     // ... 
    } 
} 

打算如果Nested沒有被在Bean實例化的工作。然後#{bean.nested}將返回null,並且該方法無法訪問。因此,請確保它已被實例化:

public class Bean { 
    private Nested nested = new Nested(); // +getter 
} 

EL即不會爲您做到這一點。

+0

謝謝,它的工作:) – Moon13

+0

不客氣。 – BalusC

相關問題