Saturday, February 26, 2011

Passing URL Parameters Between Two (2) ADF Applications

I'll try to make this blog a quick one just in case i miss out a month end blogging hehe.

I just want to demonstrate how you can quickly redirect from one Application (with a totally different URL) to the next, while sending parameters using the go<Commands> eg. goLink.

In my example, i created two identical apps... well exactly alike but with a different title, different context root, etc. I named them ApplicationA and ApplicationB hehe.

So a quick demo of what it does:

Now for the jspx code (again they both have the same code just different titles)

And the matching adfc-config input page parameter declaration.

Quick and easy way for basic url parameters.

Saturday, February 12, 2011

Sorting Programmatic Data with NULLs as the Last Rows

This scenario can be a very specific requirement. In fact, by using a database query, you should be able to achieve this by using NULLS LAST or FIRST in the order by clause. Unfortunately you can't do this on a programmatic ViewObject thus this blog hehehe.

Let's say you have a programmatic viewObject which doesn't rely on a sql query at all for sorting.

This should already give you an idea on what to expect. The natural way that nulls are ordered is that they come before alphabets. So by sorting departments for example, this is what we'll get.

But what we want is for DepartmentName to be ordered but anything that does not have a description should be the last one. Take note, we are not using panelCollection here where we can sort multiple columns at once.

So let's add one column to tell us whether this department value is null or not.

Then let's override the setSortBy method on the viewImpl to append our extra sort parameter.

with this, any sort we do will always consider sorting the null descriptions to be the last rows.

Friday, February 11, 2011

Setting-up your Project for Skinning

I'd like to share my workflow whenever i have a requirement to quickly test/skin a certain component in ADF.

First of all, install firebug plugin to your mozilla firefox. Don't worry, this will only help us debug our skinning tags for later.

Create two files which you'll need for skinning on your ViewProject.
1. CSS file (of course) - ( eg. MySimpleSkin.css )
2. trinidad-skins.xml - This is where we will define the Skin name which the css file will be linked.

Let's initially configure the trinidad-skins.xml file to link our css file and also configure trinidad-config.xml to use the skin we defined in trinidad-skins.

By this time we can already create a page to test what we got so far. Any page will do, and since we are now extending to blafplus-rich.desktop then you should notice some major skin change from the fusion skin.

Not exactly the coolest of page but what I'd like you to see is the tags applied when i highlighted the component. Getting a hint yet? Yes those are the tags and no that's not what we want to skin. So to configure the tags to show during debug in firefox, we will need to do a little more configuration.

Configure your web.xml to disable the tag compression.


While you're in the web.xml file, let's also set an extra parameter to be true for the time being that we are designing.


Both these settings will help us during our skinning procedure. Take NOTE that these settings needs to be turned off once you're done to save some processing time. More info on these in the Fusion Developers guide.

After running your app the 2nd time around, FireBug should now show you these tags.

I'm guessing by now you're already curious what each tag means, and yes there are a lot. Help document in JDeveloper is your bestfriend on this one as well as skinning tag guides in website and of course, practice will let you know and discover how to skin tags.

Some tips while skinning though.

1. If you're unsure that your skin is being applied, try coloring something that will notice you. I usually color the document green.

2. If you're wondering why your skin isn't taking effect, then clear your internet cache.
3. If you're still not sure, then make sure that you skin files (trinidad-config, trinidad-skins) are pointing correctly to the correct css file.
4. Lastly, if you want to merge skin files (css.files) the best way i found to do this is by using the skin addition in trinidad skins.

Example for #4 is if I'd like to let's say split css files depending on the component or for themes.

Hope that helps in setting your skinning project.

Monday, February 7, 2011

Popup from Popup

There are many ways on how to launch a popup from a popup, and I'm going to demonstrate here a "backingBean-based" of launching this.

So why go programmatic? The reason for this is because most of the time, I would prefer launching one popup at a time, meaning  that when I call the second popup, I first make sure to close the current popup.

So a straight forward sample in launching the popup declaratively looks like this.

As you might already know, this is achieved by simply calling af:showPopupBehavior.

Now let's go for the programmatic approach in making sure we first close the current popup before launching a 2nd one. As I have already mentioned, there are different ways of achieving this without binding your popup to a bean by using javascript for example (see Invoke popup from a popup by Luc Bors ).


Wednesday, February 2, 2011

Modeling a Cascading DropDown

Here's a quick step-by-step tutorial on how to model a 3 level cascading dropdown combobox.

  • HR Schema
  • ReadOnly viewObject for Countries, Locations and Departments 


You'll need to set viewCriterias on:
  • Location filtered by CountryId
  • Department filtered by LocationId

Create a viewObject that will utilize these models.

Sample viewObject

Add an lovModel for CountryId, LocationId and DepartmentId.

Country Attribute

Location Attribute

Department Attribute

Test your ApplicationModule

And everything in the UI is just a matter of drag-and-drop and setting autosubmit on the selectOneChoice and partialTrigger on those component that has dependencies.

Default your JSF Editor to Source View

I hope this quick blog will help other developers out there to get the most out of their workspace.

JDeveloper allows different view modes for your workspace such as Overview, Design and Source. For the most part, especially in the BC layer, I enjoy the declarative feature that model layer offers and of course, the source view hotkeys to auto complete my java are awesome. But I used to have a hard time working in the UI.

By default, upon opening a jsf or jspx page, the common thing you'll get is the following.

then you can refill your coffee and reply on the forum while you wait =) Then after all that wait, you'll just switch to source view to edit your jspx page.

So, to help speed things a bit. You can actually setup your properties so that it always opens by default on source code view.

Hope this helps.