Access to a link from within a servlet

Hey all,.
If I try to access a link from a servlet instead of use the ApplicationModule approach which is recognized as a bad idea (http://blogs.oracle.com/jdevotnharvest/2010/11/when_to_use_createrootapplicationmodule_in_oracle_adf.html). However, when the code runs in servlet line BindingContent.getCurrentBindingsEntry () returns null. I think that there is something missing in my setup which is originally ADFm to not recognize the servlet as having a binding file. Something stand out?

So within a servlet, I have the following:

SerializableAttribute public class RSSNewsServlet extends HttpServlet {}
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {}
BindingContext bctx = BindingContext.getCurrent ();
BindingContainer links = bctx.getCurrentBindingsEntry ();
DCBindingContainer bindingsImpl = (DCBindingContainer) links;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("AllPapers1Iterator");
Rank [] rows = dciter.getAllRowsInRange ();
...
}
}

Web.XML:
< filter mapping >
< filter-name > adfBindings < / filter-name >
< name servlet - > NewsServlet < / servlet-name >
< name servlet - > Faces Servlet < / servlet-name >
< distributor > BEFORE < / dispatcher >
< distributor > APPLICATION < / dispatcher >
< / filter-mapping >
....
< servlet >
< name servlet - > NewsServlet < / servlet-name >
< servlet-class > < servlet path >. RSSNewsServlet < / servlet-class >
< / servlet >
...
< servlet-mapping >
< name servlet - > NewsServlet < / servlet-name >
/servlet/news.RSS < url-pattern > < / url-pattern >
< / servlet-mapping >
newsServletPageDef.xml:

<? XML version = "1.0" encoding = "UTF-8"? >
< pageDefinition xmlns = "http://xmlns.oracle.com/adfm/uimodel."
version = "11.1.1.56.60" id = "newsServletPageDef".
Package = "< path pagedefs > pageDefs" >
< Settings / >
<>executables
< variableIterator id = "variables" / >
< iterator lie = "AllPapers1" RangeSize = "25".
DataControl = "GatewayNewsAppModuleDataControl."
ID = "AllPapers1Iterator" / >
< / executables >
< links >
< Tree IterBinding = "AllPapers1Iterator" id = "AllPapers1" >
< nodeDefinition DefName = "< path-to-model > AllPapers.
Name = "AllPapers10" >
< AttrNames >
< point Value = "PapId" / >
< point Value = "PapTitle" / >
< point Value = "PapPublishDate" / >
< point Value = "PapExpireDate" / >
< point Value = "PapAuthor" / >
< point Value = "PapType" / >
< point Value = "PapIssueDate" / >
< point Value = "PapFileName" / >
< point Value = "PapUserName" / >
< point Value = "PapPostedDate" / >
< point Value = "PapModifiedDate" / >
< point Value = "PapNeverExpire" / >
< point Value = "PapFile" / >
< / AttrNames >
< / nodeDefinition >
< / tree >
< / links >
< / pageDefinition >

DataBindings.cpx:

< pageMap >
...
"< path="/servlet/news.rss page "usageId ="MyAlmacTemplate_view_newsServletPageDef"/ >
...
< / pageMap >
< pageDefinitionUsages >
...
< page id = "MyAlmacTemplate_view_newsServletPageDef".
path = "com. Almac.Aurora.Gateway.pageDefs.newsServletPageDef"/ >
...
< / pageDefinitionUsages >

When the code runs in servlet line BindingContent.getCurrentBindingsEntry () returns null.

The BindingContext.getCurrentBindingsEntry () method returns the requestScope variable with key "bindings". When using ADF Faces, this variable is set during model prepare ADF Faces (by the method of PageLifecycleImpl.prepareModel ()). But when you use a simple servlet that variable is not set (because the lifecycle page ADF Faces is not running) and this is the reason why you get a null result. To work around the problem, you can use the following code in your servlet:

BindingContext bctx = BindingContext.getCurrent();
DCBindingContainer pagedef = bctx.findBindingContainerByPath(request.getServletPath());
bctx.setCurrentBindingsEntry(pagedef); // Invoke this method only if for some reason you need the "bindings" variable set in the environment

Dimitar

Tags: Java

Similar Questions

Maybe you are looking for