This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 7, 2011, 1:49 PM
24 Posts

xPage Current Doc from within a Managed Bean

  • Category: Managed Beans in NSF
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: Managed Bean
  • Replies: 4
 Greetings,
 
I'm developing a managed bean for my xPage application.  I've read and watched some excellent tutorials on creating and using Managed Beans.
I've created my JSFUtils class to get the current Notes Session and current Notes Database. 
 
What I haven't figured out is how to get the current Notes Document document.  Like the Notes front end class UIDocument.document(). 
 
Thanks for any help. 
 
-- Jeff 
Apr 7, 2011, 3:58 PM
10 Posts
Re: xPage Current Doc from within a Managed Bean
I dont know the 'proper way' but this seems to work just fine:
 
import javax.faces.context.FacesContext;
import com.ibm.xsp.model.domino.wrapped.DominoDocument;

public class Bean {
    public DominoDocument getCurrentDocument(){
        DominoDocument xdoc = (DominoDocument)FacesContext.getCurrentInstance().getApplication()
         .getVariableResolver().resolveVariable(
            FacesContext.getCurrentInstance(), "currentDocument");
         return xdoc;
    }
}
Apr 7, 2011, 5:51 PM
24 Posts
Re: xPage Current Doc from within a Managed Bean
 Sounds great!
 
Thanks, 
 
-- Jeff 
Apr 10, 2011, 7:25 PM
57 Posts
Re: xPage Current Doc from within a Managed Bean
Another option to reach all datasource defined within a view is
List<Datasource> dataSourceList=((com.ibm.xsp.component.UIViewRootEx2)(FacesContext.getCurrentInstance() .getViewRoot())).getData();
 
then you go further, get Xpages runtime object and get actual data
as followinf if your datasourc is a document (assuming that you only have one datasource defined in your xpages)
com.ibm.xsp.model.domino.wrapped.DominoDocument doc = (com.ibm.xsp.model.domino.wrapped.DominoDocument) dataSourceList.get[0].getDataObject();

doc.getItemValue("paramA");
 
a little bit add up is that FacesContext.getCurrentInstance() .getViewRoot() returns only JSF default viewRoot, and we can't access domino datasource through this viewroot, unless you cast it as com.ibm.xsp.component.UIViewRootEx2,
( domino ViewRoot )
 
 
Apr 20, 2011, 5:19 AM
26 Posts
Re: xPage Current Doc from within a Managed Bean
 Hello,
 
I am searching for some tutorial for using Managed Beans in XPages. Could you pls redirect me to any help docs or tutorials for the same? 
 
Thanking you in advance. 
 
Regards, 
Yusuf 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal