Wednesday May 09, 2012

Shorter URL for your ADF application

So you ran your application from JDeveloper and the URL you got was:

http://127.0.0.1:7101/Application154-ViewController-context-root/faces/untitled2.jsf

A common question is can I make this URL shorter and easy to remember?

Here is how you can get it to be http://127.0.0.1:7101/

The first step is to switch the Java EE Web contextroot setting of your application. Go to Project Properties of your view/controller project and under Java EE Application set the name to be something shorter like myapp or if you prefer even just "/". When you run your application on the embedded WLS in JDeveloper you might get an error saying:

Context path '' is already in use by the module: / application: FMW Welcome Page Application [Version=11.1.0.0.0]

This is because the built in WebLogic server comes with a welcome application that sits at this location. You can safely remove it using the application server navigator undeploy option.

Next step is to add an index.html file to your application and in that file just use an HTML Meta tag to do a redirect to the JSF file you want to access. So for example:

<meta http-equiv="refresh" content="0;url=/faces/untitled1.jsf">

That's it.

Now when people access your running server they'll get your JSF page without having to specify anything on the URL.

If you also want to remove the need for a port number (7101) then you can configure your WebLogic to listen on port 80, or alternatively install the Oracle Web Tier and have the web cache listen on port 80 and redirect to your 7101 port.

Note - don't forget to look at the comments to this entry - there are some additional tips there, like changing the faces part, pointing to an adfc-config entry instead of a page directly and using the welcome page option to do the redirect.

Here is a quick demo of how all the above is done.

Monday Jan 10, 2011

Passing Parameters to an ADF Page through the URL - Part 2.

I showed before how to pass a parameter on the URL when invoking a taskflow (where the taskflow starts with a method call and then a page).
However in some simpler scenarios you don't actually need a full blown taskflow.
Instead you can use page level parameters defined for your page in the adfc-config.xml file.

So below is a demo of this technique.
I'm also taking advantage of this video to show the concept of a view object level service method and how to invoke it from your page.

P.S.
You might wonder - why not just reference #{param.amount} as the value set for the method parameter? Why do I need to copy it into a viewScope parameter?
The advantage of placing the value in the viewScope is that it is available even when the page went through several sumbits. For example if you switch the "partialSumbit" property of the "Next" button to false in the above example - the minute that you press the button to go to the next department - the param.amount value is gone.
However the ViewScope is still there as long as you stay on this page.

About

me
I'm a Director of Product Management for the Oracle Java Development Tools.
Follow me:
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today