Dive into Oracle ADF

Send me a mail
 Dive into Oracle ADF   Click to see the XML version of this web page.   (Updated: 2/3/2008; 9:15:11 PM.)
Tips and tricks from Steve Muench on Oracle ADF Framework and JDeveloper IDE

Search blog with Google:
 

Search BC4J JavaDoc:
 

November 2004
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30        
Oct   Dec

Get Firefox!

Monday, November 08, 2004

I often get questions about the difference between a view link attribute --  that allows you to programmatically access a related collection of detail view rows -- and a view link instance in your application module data model.

I wrote up a little explanation that I'll be able to point readers to in the future who ask this question:

Difference Between View Link Attribute and View Link Instance in Data Model


11:54:47 AM    



A user learning ADF sent me an email with a question about the Building ADF Applications Workshop that he's working his way through. He asks:

When I complete item 5 under Creating DataPage Components, I run the application (right mouse over BrowseCustomers.jsp and hit Run) and I get nothing in the browser. It looks like the outline of the structure is there, but the data content is missing.

I get the following in my JDeveloper log window:

Target URL -- http://172.29.1.32:8988/OE-ViewController-context-root/BrowseCustomers.jsp

But no errors of any kind show in the log.

Any idea what's going on?

The problem is that he directly ran the *.jsp page instead of running the Struts DataAction from the struts diagram. It's a pretty subtle difference, but it can make all the difference. It's actually a common trap that users working with Struts for the first time can fall into. We should really do a better job about preventing users from running a JSP page if they have a data action related to it.

From my experience, in the excitement to see their first page working, people read right past the steps in the workshop that say:

  • You have just created an ADF data-aware JSP. To test your new JSP, go back to the Struts Page Flow diagram and right-click the browseCustomers node. Select Run from the context menu to launch an internal server that runs your page.

Their brain is thinking, "I want to run this page!" and they run the page. Makes sense, I think. It's understandable that users think of the DataPage and the JSP page as one and the same thing. The fact that we've gone out of our way to collapse the combination of the related Struts action and companion JSP page nodes in in the Struts page flow diagram probably doesn't help the first-time learner realize that both are involved in implementing the "DataPage".

The Struts action prepares the model data by interacting with the business service layer, so that when it forwards control to its companion JSP page for rendering, the data is there for the ADF binding objects to iterate over.

If you directly run the JSP page, JDeveloper happily allows you to do this. However, this short-circuits the "prepare the data model" step that the Struts action is expected to perform before forwarding control to the JSP page for display. As a result, the JSP page accesses the ADF bindings and finds no data, so the page looks like it's missing its data content.

The solution is to click on the DataPage node in the Struts page flow diagram and run the data page from there. This will run the application and request the Struts action in the browser with a *.do URL like this (which should appear in the log window):

Target URL -- http://172.29.1.32:8988/OE-ViewController-context-root/BrowseCustomers.do

The best-practice technique for JSP pages involved in Struts-based applications is to place the *.jsp pages in a subdirectory under the ./public_html/WEB-INF directory in your J2EE application. By the rules of the Servlet specification, any resources located inside the WEB-INF directory are not directly browseable by end-users. This forces them to always go through your controller layer struts actions first, and only then can these internally decide which JSP pages to forward control to. While the user can't directly browse pages in ./WEB-INF or its subdirectories, it's allowed for code running in the Web container, like Struts actions, to forward control to them explicitly. Indirectly, this best practice technique would also help prevent accidentally running the *.jsp pages directly because if you tried it, you'd get a "Page Not Found" error in the browser.

I hope we can come up with a clever feature in a future JDeveloper release to "run with" the developer's intention to run the *.jsp page, but to under the covers figure out that it's related to a DataPage, so really run the associated *.do data action instead so it does the right thing. In the meantime, now you know the story.


10:35:36 AM    


© Copyright 2008 Steve Muench.