Filter almost done!! June 14, 2006
Man, this thing's cool. Dynamically rendering, populating, and filtering.. filter.
(Forgive the colors... the Linux Gnome screenshot utility kinda cut out some colors, but it looks good on it)
In this screenshot, I search for all "Works" where the title contains "My" (or "my" or "MY" or "mY"...) within the last 9 days, and that costs at least 0 "gold". This is kinda giving away some secrets of my game, but there's more fun parts to it.
In this one, the filter doesn't change, but I am actually searching for "Labels" that I would want to filter by. Labels are like "Tags", where a user can enter any number of comma separated labels, and they get parsed and put into a table if they don't already exist. Basically, that table contains a LabelId and a LabelText field. When I search for Works with a Label, I am actually searching neither the Work table nor the Label table (rhyme!!). I'm searching a link table called "WorkLabel" which has WorkId and LabelId. It's neat, but necessary.
Here, I actually search for Works labeled "jtccom". None came up, because I created that work 10 days ago, so I had to change the Date filter to be within the last 10 days.
And that's all created with a simple JSP tag, as shown here:
Filter name comes from the following config file, which is where
all most of the magic happens is defined.
So, there you have it. Automatic filters, based on "Dumb". My life doesn't get much easier.
It's not done yet of course. But I made it so I could easily add more "modes" for controls. For example, the Date filter right now only has one mode, "within". That searches for a date after the value computed from the filter. I could add a "withinof" mode, which will basically have a second input area for a Date, and you could specify "within 3 days of March 23, 2007". So, filters can be extended. Also, I have two other objects that work behind the scenes pretty heftily. There's a FilterProcessor object, which takes a FilterInput object and, using SQLDOM (another home made thingy), crafts a where clause. That where clause is appended to any other where clauses already in the select statement. A "Work" will only be listed if it is Active, however, that's not in the "autoFilters" section of the filter-config.xml file (although it could be). It's specified in my application.
Just take my word on it, it's sweet. :)