I have this select option:
<f:verbatim>Pages: </f:verbatim>
<h:selectOneMenu id="selectPage" value="#{pageList.selectedPage}">
<f:selectItems value="#{pageList.selectPages}" />
</h:selectOneMenu>
And the backing bean (called mybean2) for this is:
private int pages;
public void getPages(int Pages)
{
this.pages = Pages;
}
// getter methods
public List<SelectItem> getSelectPages()
{
selectPages = new ArrayList<SelectItem>();
pages++;
for (int i = 1; i > pages; i++) {
selectPages.add(new SelectItem(Integer.toString(i), Integer.toString(i)));
}
return selectPages;
}
public String getSelectedPage()
{
return selectedPage;
}
// setter methods
public void setSelectPages(List<SelectItem> selectPages) {
this.selectPages = selectPages;
}
public void setSelectedPage(String selectedPage) {
this.selectedPage = selectedPage;
}
The getPages method above gets the page count from mybean1.submit method. Thus, for example, when the submit method returns 30, how am I able to pass this value into the getSelectPages method so it can dynamically created the number of pages as in:
for (int i = 1; i > pages; i++) {
Also, I want mybean2 to be generic i.e. I don't want other beans to be referenced within mybean2 directly. For example, I don't want to reference like this within mybean2:
mybean1 mb1 = new mybean1();
pages = mb1.getPages();
Otherwise, I have to declare separate instances of other beans (about 12 others) that send pages count to mybean2 for it to action - this way would be way too messy...
Any hint or code example is much appreciated. Thanks.