Reputation: 7357
I'm on JSF-2.1_29
. As far as I can see, the order of manged bean's methodw invokation corresponds to how they are placed in the markup. In my particular case I have:
<h:outputText value="Rows count:"/>
<h:outputText value="#{bonusBean.rowsCount}"/>
<rich:dataTable id="bonusesTable"
var="bonus"
value="#{bonusBean.list}"
render="ds"
rowClasses="tr0, tr1">
<!-- Columns, etc... -->
</rich:dataTable>
ManagedBean itself:
public class BonusBean{
private Integer rowsCount = 0;
//GET, SET
public List<BonusActionDTO> getList(){
List<BonusActionDTO> lst = new ArrayList<BonusActionDTO>();
//Getting the list from a persistance storage
rowsCount = lst.size();
return lst;
}
In that case getRowsCount()
is being invoked first which returns 0, so the Rows count: 0
is going to be printed when the page is loaded first, although the table may contain some rows. After invokation of getRowsCount()
method, getList()
is being invoked, so the actual Rows count
is going to printed only after refreshing the page. How can I reorder that order of methods invokation? Is it possible in JSF
?
Upvotes: 0
Views: 40
Reputation: 543
I don't know if you can change the order of the getter invocations. But apart of this, the dependency of the result of a get method on the call of another get method is a bad design. Two getter should return the same results without regard of the order in which they are called.
Upvotes: 1