Showing posts with label model. Show all posts
Showing posts with label model. Show all posts

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.

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.

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

Model

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.