|
Replies:
35
-
Pages:
3
[
1
2
3
| Next
]
-
Last Post:
Mar 13, 2007 10:37 AM
Last Post By: Steve Muench
|
|
|
Posts:
20
Registered:
09/06/05
|
|
|
|
How-To Access ADF application module with ADF faces
Posted:
Sep 26, 2005 2:59 PM
|
|
|
|
I am working on a test application using ADF Faces and ADF Business Components.
I am trying to access the current sessions application module from some backing code and I have no idea how to this.
Any help would be appreciated.
If you could point me to documentation, that would be appreciated as well.
|
|
|
Posts:
45
Registered:
07/02/04
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 27, 2005 5:45 AM
in response to: JMike
|
|
|
|
Hi .
I am facing the same problem.
I think the problem would be solved if we could gain the HttpServletRequest.
If we could get the request , then we could access the app mod
using the ADF Model , i mean by getting the binding container of the current page.......
But i have not seen any example that access the Request.
Please help.
Thank's.
|
|
|
Posts:
4
Registered:
09/27/05
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 27, 2005 7:32 AM
in response to: omardawod119@ho...
|
|
|
|
You can get HttpServletRequest by following code:
HttpServletRequest rq = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
|
|
|
Posts:
20
Registered:
09/06/05
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 27, 2005 1:47 PM
in response to: Alexey Rassokhin
|
|
|
|
Ok, I'm lost.
Can someone post some sample code that would spell out for me how I can access the application module or view object being used by a jsf page.
Thanks...
|
|
|
Posts:
1,573
Registered:
02/16/05
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 27, 2005 3:58 PM
in response to: JMike
|
|
|
|
I was about to ask exactly the same question? How do we get to the binding layer from ADF Faces backing bean?
Just even a snippet of code would be useful.....
I'm guessing our backing beans need to extend an ADF controller class to expose the binding layer, but which?
CM.
|
|
|
Posts:
5,912
Registered:
01/10/01
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 28, 2005 3:08 PM
in response to: Chris Muir
|
|
|
|
This early access 1 release is thin on doc in this area, but we've made most cases declarative now with new declarative control in the page definition.
What is the page definition? It's a slight generalization of what we previously called the UIModel at design time. It's still known as the BindingContainer at runtime.
You can get to the page definition for any page by using the right-mouse "Go to Page Definition" menu item.
The page definition is an XML metadata file just like the UI Model file was. A few key differences in 10.1.3 are that the file is now XML Schema based, and tied into our generic XML Schema-driven editing infrastructure so you can use the structure pane or code editor to perform schema-driven editing of the file.
The declarative way to bind an action binding to a method in a data control is still to create an action binding. To do this explicitly, first right-mouse "Go to Page Definition" while editing your JSP/JSF page. The XML file representing its page definition appears in the code editor, and the structure pane shows its structure. Select the "bindings" element (has a folder icon) in the structure pane, and right-mouse "Insert inside bindings > methodAction". Click on the root YourAppModuleDataControl node, and in the poplist select the "yourMethod" method. The "Action Binding Editor" dialog that appears shows you the arguments to the method and gives you a place to enter the EL expressions that will declaratively provide the values for each argument at invocation time. This same thing would get created for you implicitly if you dropped the "yourMethod" method onto the page from the data control palette, say, as a Command Button or Command Link. Doing it this way, it's not automatically wired to a UI control yet.
Now you have an action binding that is declaratively configured to invoke the method in question. By default the action binding will be named the same as your method.
You can leverage a new feature in 10.1.3 ADF binding layer called the "invokeAction" to invoke any action binding during any phase of the page lifecycle. In particular, you might want it to invoke your "yourMethod" action binding you just created. If no UI control is wired to the action binding, it's not going to "fire" any any automatic way based on a UI gesture, but the invokeAction can invoke it declaratively as part of the page definitions "executables" section.
The "executables" section is something you will have already in your page def if you have any iterators. Since these get implicitly executed, we've tried to make this more clear by grouping them into a category of "executables" and providing new declarative control over this implicitly executed things. In particular, anything that can appear in the "executables" section of your page definition has two important properties "Refresh" and "RefreshCondition". Refresh defines when this "executable" thing will be implicitly refreshed, and RefreshCondition gives you an optional place to enter a boolean-valued EL expression that can help further decide whether the "executable" thing will execute or not. If the expression is missing, then it evaluates to true. If the expression is present, the "executable" will only be implicitly executed by the binding layer if the expression evaluates to true. The Refresh property itself gives you declarative control over what phase of the lifecycle things should get executed. "prepareModel" is a good one that will make sense to folks who have used 10.1.2.
So, if you insert an "invokeAction" executable inside the "executables" section of your page definition, give it a name/id, pick which action binding it should invoke, and set the "Refresh" property to a different value (if appropriate), you'll be in business.
|
|
|
Posts:
5,912
Registered:
01/10/01
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 28, 2005 3:11 PM
in response to: Steve Muench
|
|
|
|
I forgot to mention that JSF does not have an "Action"-like thing like Struts. Just pages.
For 10.1.3 production, we're trying to improve the support for writing custom code before and after the declaratively invoked action binding (either invoked by invokeAction or explicitly by a button press).
I also forgot to mention above that the order of the executables in the executables section is relevant, and you can drag/drop to rearrange the sequence in the structure pane. Of course, since the page definition XML file is editable now, you can also cut/paste or select/drag-drop in the code editor to rearrange the XML tags, too.
|
|
|
Posts:
5,912
Registered:
01/10/01
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 28, 2005 3:15 PM
in response to: Steve Muench
|
|
|
|
Also,
If you were invoking an application module method just to set bind variables in a more structured way, another of the cool new features in ADF Business Components for 10.1.3 is the full support for proper named bind variables, including support for binding their values declaratively in the ADF binding layer.
Try defining a few named bind variables, referencing them using :TheNameYouChose (in any order and number of occurrences) in the SQL query, and then you'll see that a new built-in action named "ExecuteWithParams" appears for that view object in the data control palette. If you expand that you'll see the named parameters and can drop them onto a form to create a parameter form. If you drop the "ExecuteWithParams" action as a button, then clicking that button will execute the query and pass the bind parameter values declaratively, too.
The regular "ExecuteQuery" built-in action still re-executes the query, but without causing the bind parameters to be rebound.
|
|
|
Posts:
5,912
Registered:
01/10/01
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 28, 2005 3:16 PM
in response to: Steve Muench
|
|
|
|
One last thing. You remember how complicated it was in 10.1.2 to create pages that accepted parameters and then executed a query which required having the user enter those parameter values first before the query could make sense?
Well, given the declarative "Refresh" property control we've added now, you can simply select any iterator, and set its Refresh property to "never". and it won't by implicitly refreshed anymore when the page renders. It will only execute when explicitly triggered by a button or method call that executes the query.
|
|
|
Posts:
5,912
Registered:
01/10/01
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 28, 2005 3:22 PM
in response to: Steve Muench
|
|
|
|
The answer to the original question in this thread is that currently in the EA1 release, you'll need to access the current binding container from the requestScope either programmatically or by evaluating a faces value binding. Just like in 10.1.2, you can access it as an attribute named "bindings".
We're experimenting with various techniques to improve the usability of this for 10.1.3 production, including having the bindingContainer injected into the backing bean using JSF managed properties, and other ideas.
|
|
|
Posts:
20
Registered:
09/06/05
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 29, 2005 7:30 AM
in response to: Steve Muench
|
|
|
|
Thank you Steve for your replies.
However, I guess I am looking for something a little more lower level to hold me over until the documentation comes out.
Here is a sample of something I am trying to do.
1. Create a new application, called TestBackingConnection, Application Template is <Web Application [Default]>.
2. Select the Model project, right click, select new. From here, select Business Tier/ ADF Business Components/Business Components from Tables.
3. Connect to a test oracle database, select the tables Countries, Departments, and Employees. Create entity objects and updateable view objects for these three tables.
4. Name the new application module TstAppModule.
5. Select the ViewController project, right click, select new. From here, select Web Tier/JSF/JSF JSP.
6. Named the file TstMain.jspx, automatically bind components to backing_tstMain.
7. Make sure that TstMain.jspx is active in main window, design tab active.
8. Select the Data Control Palette, expand TstAppModuleDataControl, select CountriesView1, drag and drop onto TstMain.jspx. From the popup menu, select forms/ADF Read-Only Form w/Navigation.
9. Select the Component Palette, ADF Faces Core, drag and drop a CommandButton onto the bottom of TstMain.jspx.
Please Note: For testing purposes, I am attempting to use this button to implement my own "NEXT RECORD" Navigation ability, with the associated method in my bean TstMain.java working with TstAppModule to move to the next record for this session. I do not mind using any built in navigation iterators, my goal is to have the logic called from the backing bean TstMain.java.
10. For this new CommandButton, set the text property to "Custom Move Next" without the quotes.
11. Double click the CommandButton. TstMain.java should load. In my case, a new method was created, public String commandButton5_action()
12. My question is, what is the code I would type in commandButton5_action to perform the functionality stated in point 9? Do I use FacesContext? Actual code would be appreciated.
|
|
|
Posts:
5,912
Registered:
01/10/01
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 29, 2005 8:36 AM
in response to: JMike
|
|
|
You dont' need to write code to achieve this, or actually even have a backing bean at all.
You can just expand the CountriesView1 and drop its "Next" built-in operation as a commandButton.
The auto-binding feature for JSF pages is off by default because most of the time with JSF and ADF you don't actually need it. It's also a little bit confusingly worded because it's not the same kind of binding as the ADF binding layer is doing. What the auto-binding feature there (again, off by default!) is doing is, for each control in your JSP of JSPX page, automatically creating the following in the automatically generated backing bean class:
-- a member variable of the right type
-- getter/setter methods for this member of the right type
These are useful if you want to invoke methods on your UI components, for example, conditionally change the background color of some field based on some custom code.
For any kind of interaction with your back-end business service, that can all be done declaratively when you couple JSF and ADF, so in practice you won't really need
The JSF spec uses the notion of a bound component to mean binding the UI controls on your page to properties of a managed bean.
I've blogged a link to a working example of referencing bindings and the binding container from a JSF backing bean here:
http://radio.weblogs.com/0118231/2005/09/29.html#a606
|
|
|
Posts:
20
Registered:
09/06/05
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 30, 2005 12:18 PM
in response to: Steve Muench
|
|
|
|
Steve,
Thanks for the link. I appreciate the example, it allowed me to do what I needed to do.
One thing.
In playing with the example, I found that if I recreated the Example.jsp file with auto binding turned on, the calls to the custom method would not work properly. I would get a NullPointerExeption error. Upon stepping through the code, I found that the binding variable DCBindingContainer bc was null even after it was set via GetBindingContainer().
If I turn auto binding off and do the binding by hand, I do not have a problem. Apart from that, the example worked great.
If this is the wrong place to report issues, please let me know.
|
|
|
Posts:
5,912
Registered:
01/10/01
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 30, 2005 4:13 PM
in response to: JMike
|
|
|
|
For the EA1 release, this is the right place to report them.
I've reproduced your problem and the developers are looking into it. It's related to the fact that when you use auto binding, you have components in your page with their "binding" attribute set to a property in the backing bean that exposes the UI component to programmatic manipulation -- think, setting a field's background green under certain conditions, or something. When there are UI components with a JSF binding attribute set, then the JSF "RestoreView" phase kicks in and in that phase, for some reason, the "#{bindings}" expression is evaluating to null, so it's properly performing the injection of the managed property, but it's injecting null.
I'll update this thread if the devs identify a workaround.
|
|
|
Posts:
5,912
Registered:
01/10/01
|
|
|
|
Re: How-To Access ADF application module with ADF faces
Posted:
Sep 30, 2005 4:57 PM
in response to: Steve Muench
|
|
|
|
ok. I filed bug# 4645624.
When UI Components in the page have a binding property set, which occurs when you ask JDeveloper to auto-bind the UI components in the page, then the injection occurs earlier in the JSF page lifecycle and due to this bug the #{bindings} attribute isn't available yet, but the ADF Binding Context is available using #{data} and since it's a map that contains the page definitions by name, you can use #{data.ExampleAutoPageDef} as a workaround to refer to this page's page definition by name.
I've republished an updated version of my working sample that has now added an auto-binding-on page like you tried to create, along with the workaround suggested here (with some comments in the page to remind you of the workaround).
|
|
|
|
Legend
|
|
Guru : 2500
- 1000000
pts
|
|
Expert : 1000
- 2499
pts
|
|
Pro : 500
- 999
pts
|
|
Journeyman : 200
- 499
pts
|
|
Newbie : 0
- 199
pts
|
|
Oracle ACE Director
|
|
Oracle ACE Member
|
|
Oracle Employee ACE
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|