I am trying to add multiple-tabs capability to my JSF(facelets)/Spring/ application, something like OpenBravo already has (http://wiki.openbravo.com/w/images/9/9c/WIK_PartsOfScreen.png, but their app is using different technologies - I guess - pure JavaScript for GUI): each document or report can be opened in separate JavaScript tabs.
Bascially it is simple - each document or report is separate JSF region and only one of them is made visible. Tabs are only visual effect.
The problem is communication with JSF backing beans (or Spring beans that sometimes can be employed in this role). E.e. is is simple for one tab interface: one can create the following bean:
class BankDocumentServiceBean { BankDocument selectedDocument; Long id; void setId(Long id) { if (selectedDocument.id!=id) { setupBankDocument(id); } } void setupBankDocument(Long id) {...} BankDocument getBankDocument() {...} ... } And BankDocument JSF page can be something like this:
... <f:metadata> <!-- page is called with parameter id and this code calls setId(...) --> <f:viewParam name="id" value="#{bankDocumentServiceBean.id}"/> </f:metadata> <h:body> ... <!-- p for Primefaces --> <p:inputText id="amountTxt" value="#{bankDocumentServiceBean.selectedDocument.amount}" required="true" label="amountLbl"/> <p:message for="amountTxt" /> ... Is this approach generally good?
The main question is - how this single-document approach can be extended to multiple tabes. JSF code can be included in the page dynamically, but the service bean remains the problem. Use of additional parameters in each call can be solution - e.g. BankDocumentServiceBean can contain not single BankDocument but List of BankDocuments and each opearation (e.g. getBankDocument) can have additional identifier for selection the right bean from the collection, i.e., the bean that is relevant for the tab with which the user interacts.
But maybe there is some better approach. E.g. maybe one page can be multiple instances of the old good single-document BankDocumentServiceBean. Maybe there are less coarse scopes (JSF scopes and Spring scopes) that are good for tabs, some kind of conversation scope?
Each tab is sitting in its own general panel (div) with its distinct id. Maybe JSF/Spring application can detect that request is coming from distinct panel/div and select instance of BankDocumentServiceBean accordingly?
I guess - solution with List and parameters will work, but maybe there is better architecture for this? Thanks!