You are here

WebCenter 11g PS3 Tutorial: Closer look at the navigation model

In the previous part you have seen how to create a WebCenter Portal application and how to create pages at runtime.
In this part I will go into the details of a navigation model. I will show you how you can create and manage a navigation model.

In this part I will also explain how to work with the page hierarchy and how you can modify the default page of your portal.

Before we will create a navigation model, we will first create a few pages so we can add them to the navigation model.
If you haven't done the previous part of the tutorial, you can download the application at the bottom of this page.

First of all, start JDeveloper and load the ViePortal application.

Create the About Us page

Right click on the pages folder from the Web Content/oracle/webcenter/portalapp folder and select New from the context menu.
Select JSF from the list on the left and JSF Page from the list on the right

Specify aboutUs.jspx as the file name.
Make sure that you have selected the Globe page template.

Press the OK button to create the page. We will not care about the content of the page. This will be done in another part (Content integration).

Now to the exact same and create a few more pages:

  • courses.jspx
  • registration.jspx
  • prices.jspx
  • teachers.jspx
  • myCourses.jspx
  • pastCourses.jspx
  • futureCourses.jspx

When all the pages are created, the pages folder should look something like this:

Don't mind the content of those pages for now. We are just building the framework for later. Most of these pages will be used in other parts of the tutorial.

Assign security to pages

When we create a new page, it does not have any access assigned to it. This means that we can not access or use the page in our portal yet. 

When you are used to an ADF fusion application you modify the jazn-data.xml and add some security to it. In a WebCenter Portal application this is somewhat different. At the end, the rules are still added to the jazn-data but we don't really modify it by ourself. Instead we are using a page hierarchy. The page hierarchy of our portal is calld pages.xml in the pagehierarchy folder.  
Open that file and you will see a Root node with a Home node. When you select the Home node you will see the properties of the node in the hierarchy:

  • ID: this is the unique identifier for the node in the page hierarchy
  • Title: This value will be used in the navigation model when we add the page hierarchy to our navigation
  • Path: path to the page
  • Visible: if you uncheck this checkbox, the page will not be visible in the navigation model when you add the page hierarchy.
  • Security: in this section you can specify the security:
    • Inherit Parent Security: by selecting this, the page will use the same access settings as its parent node
    • Delegate Security: select this by specifying your own security for the page.

As you can see, the Home page inherits security from its parent so select the Root node to investigate the access settings. You'll see that the anonymous user will have view rights and the administrator has all the rights.

Now we will specify the access settings for some pages that we just created.  

Drag & Drop the aboutUs.jspx page on the Root node of the page hierarchy.
Select the aboutUs node and set its Title to About Us. The security and visible settings are fine for now.

We will now add the My Courses section. In this section, the user can view the courses he already attended or the one he will do in the future.

First of all, drag & drop myCourses.jspx on the Root node. Modify the Title to My Courses.
We also need to modify the security for this page because we want only authenticated users to see this page.
Select Delegate Security and uncheck the View permission for the anonymous-role as shown in this image:

You will also notice that the My Courses node has a lock icon in the page hierarchy. This icon tells you that the page has delegate security and it does not inherit the security.

Now drag & drop the futureCourses.jspx on the My Courses node and change the title to Future Courses 
Drag & drop the pastCourses.jspx on the My Courses node and change the title to Past Courses.

When you have done this, the page hierarchy should look something like this:

Because the Future Courses and Past Course inherit the security from their parent (My Courses), they will also not be visible for anonymous users.

Let's take a look at our hard work. Run the Portal project and we'll see our changes take effect.
You'll notice that when the portal is launched we see the About Us link next to the Home:

The My Courses page is not available because we arent't logged in so let's login with any user. You'll see the My Courses page appearing and when you hover over the link you'll also see the subpages:

Modifying the navigation model 

As you can see, we have modified the navigation model without modifying the navigation model. How cool is that! Let me say you... Totally not cool but that isn't your fault. Let's take a closer look at the default navigation model. You can find it as the default-navigation-model.xml in the navigations folder.

As you can see, the navigation model has a single item being the Page Hierarchy. When you select it you can take a look at the properties. From the Path you can see that it is the page hierarchy that we have been modifying. That's why our pages are showing up when we run the portal.

So why did i say it isn't cool to use the page hierarchy in your navigation model? I'll explain this by an example that we will be using in another part of the tutorial. Suppose that we want to add content from the content server to our navigation model. This is easy to do but when you put this after the Page Hierarchy in the navigation model than the content will show up after the About Us page which is not what we want. The About Us page should be the last one of our navigation model and the model the first one. If you want to put resource between the Home page and the Abous Us page than the page hierarchy is just not right for us. That's why it's a good practice to never use the page hierarchy in the navigation model and add each page seperatly.

I can hear you thinking... Why should we use the page hierarchy anyway? Well, you should think of the page hierarchy as the security hierarchy instead of the page hierarchy. You definitly need to use the page hierarchy for assigning access to your pages and specify a hierarchy among those security settings. If you add a page to the navigation model, the security settings from the page hierarchy are applied, no mather what. So let's find out how it works.

First of all, open the default-navigation-model.xml from the navigations folder. Select the Page Hierarchy node and press the delete button so we have an empty navigation model.
Now let us add the Home page. Drag & Drop home.jspx on the default-navigation-model node and select Page Link from the context menu.

When you select the Home node you will see following attributes:

  • Id: this is the unique identifier for the node in the navigation model
  • Type: this properties defines the type to with the URL attribute is refering to. In our case, this should be Page
  • Factory Class: the class that is responsible for the resource. In most cases this field is read-only
  • URL: the URL of the resource that we want to add to the navigation model
  • Visible: Expression Language specifying whether or not we want to display the node. This value will always be used so no mather what you have specified in the page hierarchy for this page, the visible attribute from the navigation model will be used instead!
  • Title: the text for the link that will be used on our pages.

If you want to learn more about the navigation model and types of resources you can add, you can take a look at my book. Chapter 3 contains a complete chapter dedicated to the navigation model. You will also learn more about the navigation model in future sections of the tutorial.

Now add the mycourse.jsxp and aboutUs.jspx to the navigation model and change the title to My Courses and About Us.

In order to show the difference between the page hierarchy and the navigation model,  we will add the futureCourses.jspx after the aboutUs page as shown in image:

We don't modify any other attributes so all the pages should be visible, right? What do you think.... When we run the portal, will we see four pages or only two?
Let's test it by running the portal project:

Did we just brake the application? As a mather of fact, we did!

Setting the default home page

When JDeveloper creates the application, he also creates a default index.html file which can be found in the Web Content root of our application. Let's take a look at the source of that file:

Portal Home

As you can see from the meta-tags, it redirects to ./faces/pages_home. In WebCenter we can use a special syntax in the URL for accessing pages. This uses the ID's of our resources in the navigation model. In this case, the URL redirects to a page called home from the resource with the pages ID.
Because we also want to redirect to the home page we need to modify this redirect to ./faces/home. Why is that? Because home is the ID of home.jspx in the navigation model.  
Make sure you have done the modifications in the index.html and rerun the portal application.

You should now be able to see the portal:

As you can see, we only have two links in the navigation. The My Courses and Future Courses page are not listed although their visible attribute is set to true! This is because the security from the page hierarchy is applied here. The Future Courses page inherits the security from the My Courses page so wherever we put the futureCourses page, the same security as the My Courses page is applied here. Once you login you will see both links appear.

This example shows how the navigation model and the page hierarchy are two seperate things. The navigation model is used to build the navigation while the page hierarchy is used to create a hierarchy of pages based upon security.

This concludes the second part of the tutorial.
You now should be able to build basic navigation models and set security to your pages. You should also know the difference between the page hierarchy and the navigation model!

You can add more types of resources to the navigation model than just pages. I will discuss them into detail in other parts of this tutorial.

Exercises

As promised in the introduction, I will also add some exercises so you could practice the things that we have learned in this part. This way you should think for yourself and not just click and do what the tutor tells you!

  1. In this exercise I want you to add the teachers page to the navigation model as a subpage of the Home page. Also make sure that the teachers page is only accessible by the administrators.
  2. Move the Future Courses page from the navigation model and add it as a child of the My Courses.
  3. Add the prices page between the My Courses and the About Us page.
  4. Add the registration page after the About Us page and add security in a way that only anonymous users will see the page.
  5. Instead of starting the portal on the Home page, we want it to start at the About Us page. Make the needed changes for this.

If you should have problems doing these exercies, please leave a comment and we can figure it out together.

Download ViePortal_part2

Below you can find the second part of the ViePortal application as it should be after this tutorial. The application does not include the solutions for the exercies. It is in a state as it should be before the exercies. I will add the solutions as a download in the next part of the tutorial.  

Comments

Hi Yannick,

I tried to do the step 4 in the Exercises section above and it seems that editing the security for the Registration page in page.xml and making it viewable only to anonymous users i can see the Registration page even after login inot the app. Is there and setting to be done in jazn-data.xml?

You shouldn't do anything in the jazn-data.xml.
You should use an expression language statement in the visible attribute in the navigation model in order to not display the page:
#{!securityContext.authenticated}
This way the page will only be visible when you are not authenticated.

Hi Yannick, I was facing the same issue. Thanks for your explanation. Appreciate the good work you are doing here.Looking forward for many more tutorials from you.

Hi Yannick,

I tried to do the ssolution u suggested thanks for making my understanding clear. I thought that it can be controlled by the the page hierarchy since it has the page security defined in it. Really appreciate the work u doing via this blog. Look for more on the tutorial and Once again thank you.

Hey Yannick,
Is this the only way to add pages to a community in WebCenter?
Is there an admin GUI interface for page creation?

I have shown how to create pages at runtime in the first part of the tutorial.
In this part i haveshown only how you can crete pages in jdeveloper. In lter parts, i will also go into much more dtail on how to create pages at runtime so business users can also easily create and modify pages.

Hi Yannick, I'm wondering if it is possible to manipulate the Link node (or the page hierarchy) defined in the navigation model programmatically at runtime. For example, part of of the menu on the portal have to be created based on the user's input or identity (not only just visibility of the menu item)
I've checked the API and it seems that it only provide methods to retrieve various data in the navigation model, but couldn't find any that allow you to modify or manipulate it so far.

What do you exactly mean by "manipulate"? What do you want to do?
There is a possibility where you can define multiple navigation models and based upon a custom class, you can tell WebCenter which navigation to show. This way you can create models and basd upon the user profile show a different navigation model.

Hi,

How can we change the default "default-navigation-model.xml" used for our navigation and replace this with some custom navigation file and what and where changes has to be done in this regard.

I will discuss this in a later part but for now i will give a brief explenation.
Right click on your navigation folder and select new. Select navigation file. Edit the file as you wish just like the default navigation model. Right click on your file and select Create portlet resource.
Run your portal, go to the administration section and open the configuration tab. Select your navigation model as the default one. That's it.
You can also create a navigation model at runtime.
You can also buy my book: WebCenter 11g PS3 administration cookbook. I cover all these topics in detail :)

Hi Yannick,
Thanks for taking time and clearing my understanding. It is very helpful. Looking forward to your other sessions. Yes I am aware of your next session on page templates is already done and so do I am.
Thnaks again. Cheers.

Hi yannick
i've tried all of the above.
But the logout part does not work , it throws a 404 error can u tell us wht we need to configure and where so that logout functionality also works.

Hi yannick, can we use multiple navigation model in same page?
Such as, a page that have top navigation and left navigation.
How can we do this?

It's possible. Just create the models you want and you can access them in your JSPX page by following EL:
#navigationContext.navigationModel['/oracle/webcenter/portalapp/navigations/imageGalleryModel'].listModel['startNode=/,includeStartNode=false']
As you can see you can easily use the navigation model you want by refering to its path in your project.

Hi, Yannick.
I'm trying create imageGalleryModel.xml in navigations folder and use your EL, but I'm got
<NavigationCatalogException> << init >> oracle.adf.rc.exception.DefinitionNotFoundException: cannot find resource catalog using MDS reference /oracle/webcenter/portalapp/navigations/imageGalleryModel.xml Root Cause=[MDS-00013: no metadata found for metadata object "/oracle/webcenter/portalapp/navigations/imageGalleryModel.xml"] [Root exception is oracle.mds.core.MetadataNotFoundException: MDS-00013: no metadata found for metadata object "/oracle/webcenter/portalapp/navigations/imageGalleryModel.xml"]
What should i do?

You need to identify the navigation model as a portal resource. Just right click on your navigation model in JDev and select Create Portal Resource. This should solve the issue.

Thanks again for additional answered.
It's already create a portal resource when i've create a navigation file.
I try to update or recreate a portal resource but it still notwork :(

I've created an example and a blog post: http://www.yonaweb.be/using_multiple_navigation_models_template_webcente...
This should work. If not, you can comment on that post so we can keep it centralized.

As agree with the explanation you gave for not using the page hierarchy to display the navigation. But my question is how will u include the pages creaed at runtime using the Admin console for the WebCenter Portal Application. I your approach and then faced problem in getting the newly created page automatically in the navigation menu.

How can I add the content of already developed pages or web application to one of the jsp pages

>so let's login with any user.
Did we created users? I followed the tutorial but I don't think that at this point we created any.

You are right... We didn't. You can always login with weblogic/weblogic1 That user always exist in your Integrated WLS domain.

Hi Yannick,

Your approach of explaining pages.xml as the "security hierarchy" and navigation model as the "site structure" sounds logical to me. But if we do this, then how will pages created at Run time become part of the navigation model?

By default, when the pages.xml is added to the navigation model, we could just create pages at run time and they would start appearing in the navigation. But if we start adding individual page links to the navigation model, then how will we get the pages created at run time to display in navigation? Is there some way of adding run time created pages into the navigation model at run time?

Regards,
Prashant

Hi Yannick,

Based on your post the id of the node would be the url of the page. I tried directly accessing a link through that strucutre (e.g. http:127.0.01:7101/portalappdemo/faces/help) but it is displaying an error page. Is there a way for us to redirect the user to a login page? I tried adding an authenticated-user security on the help page. Any advice? Thanks

Hi Yannick,
In my case I had to configure the 2 entries /pages_home in faces-config.xml to make it work.
Just modify the 2 entries to /home and it worked.

Regards,

Andre

Hi, in PS6 it seems that it's not possible to change the start page by editing index.html anymore. Instead of "/faces/pages_home" it now says "/faces/wcnav_defaultSelection". Changing this bit to "/faces/aboutUs" does nothing. Do you know how to solve this? Thanks in advance!

I looked in the documentation but so far I haven't been able to figure out where to configure this.
The only place where you can make this modification is in the web.xml under the welcome pages. By default this is configured to go to index.html but you can also set this to /faces/aboutUs and it should work.

Yannick,
I renamed the view activity in faces-config.xml from pages_home to home. It worked for me.

We can replace ./faces/wcnav_defaultSelection with ./faces/pages_home

Hi Yannick ,
I tries to change the meta-tag from in index,html to

I am getting the following error ..I am stuck ..please help

Error 404--Not Found

From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:

10.4.5 404 Not Found

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.

What did you put in the meta-inf tag? Are you sure that the link exist?
Notice that you have to use /faces/ID where ID is the ID of the item in the navigation model.

It's very helpful. thanks for your working. i'm a newbie on oracle webcenter portal and if i don't follow your tutorials, very challenging days would wait for me :)

Neenu,

I too faced the same issue. My observation is that, in faces-config.xml file, upon login_sucess/logout_success, the navigation still goes to /pages_home. Change the control flow case to navigate to home.jspx in faces-config.xml file in addition to changing it in index.html file(in meta-inf tag).

Hope this helps.

hi Yannick
after changing the url in the index.html from pages_home to home , i get this error when i run the program. here is my line

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer