Friday, December 15, 2006

Whacking MediaWiki's Monobook to Remove Logo

To get rid of the MediaWiki logo in the default monobook, do this.

  1. Edit skins/MonoBook.php and whack or comment out this section:
    <div class="portlet" id="p-logo">
    <a style="">text('logopath') ?>);"
    href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"
    title="<?php $this->msg('mainpage') ?>"></a>

    This removes the logo gif and also the image hyperlink.

  2. Edit skins/monobook/main.css to change the following:
    #column-one {
    /* padding-top: 160px;*/
    padding-top: 40px
    Use any value you like for the padding.

Wednesday, December 13, 2006

More JSP Hacking in JSF

Previously I put some notes on using JSP EL in JSF pages. The useful thing for me was that you could embed EL in JavaScript such as Google Map API calls. But this only goes so far. For example, suppose you want to iterate over a String array that is defined in your backing bean. You can't do the following, unfortunately:

for(i=0; i < ${mybean.myStrings.length} ; i++ ) { document.write(${mybean.myStrings[i]}) } </script> ${mybean.myStrings.length} will work (if I recall correctly). The problem is that the EL expression inside the loop must be evaluated on the server side when the JSP/JSF page is created, but the JavaScript is processed by the browser. If you really needed to do something like the above, you have to drive the loop with Java inside your JSF page. First, of course, you should realize your JSF backing session beans will be available in the usual way through the built-in JSP session object. <% MyBean mybean=(MyBean)session.getAttribute("mybean");
for(int i=0;i < mybean.myStrings.length;i++){

document.write(<% myBean.myString[i] %>);


This example is really artificial, of course, but there really are cases when I needed to do things like this. OK, probably there is a better way.

Monday, December 11, 2006

Gnuplot + PNG on MacBook Pro

Some notes on getting Gnuplot to print PNG on my Mac: I used Gnuplot 4.0.0, which installed with no problems, but Mac doesn't have the required zlib and png libraries (or at least they weren't in /usr/local, where ./configure could find them).

So the steps are
  1. Get zlib, run ./configure, make and then sudo make install.
  2. Get png, run ./configure, make and sudo make install
  3. And then reinstall gnuplot with ./configure, make, sudo make install.
I used libpng-1.2.14 and zlib-1.2.3. Google to find the tar files. I also for fun set CC=cc instead of the default gcc that ./configure gives you. It all seems to work.

Friday, December 08, 2006

Dirty Tricks with JSF and JSP EL

JSF's great weakness is that you often need to break out of the JSF tag library cocoon when developing the web pages to be rendered. For example, let's say you need to pass a variable value that is set in your backing been to some section of JavaScript. The JSP 2.x Expression Language is the way to do this. It requires Tomcat 5.x, so if you are still using Tomcat 4...well, the first decade of the 21st century is winding down. It's time to upgrade.

Anyway, you probably are already set up to do this. So lets assume you have to set a value in a Google Map object from your backing bean:

... GPoint (-117.24, 33.03),10);

In a JSF application, the lat/lon values (33.03, -117.24) will be in something like a class, which you call mapBean in your faces-xml.config file. So how do you get these values into the JavaScript? You do it with JSP EL (not JSF EL). This will be active in your page unless you explicitly turn it off (and why would you do that?) so just place your javascript fragment inside the f:view tags and then use GPoint(${mapBean.valueY}, ${mapBean.valueX}),10);

There is one dirty (or crafty, if you prefer) trick to this: you need to initialize the mapBean object in the page. JSF normally takes care of this in the process of rendering its own EL expressions, or you could do it explicitly the JSP way (I suppose). But let's say you want to use JSP EL exclusively for your page (and avoid the obscurities of JSF tags), or perhaps you just don't have any JSF tags in this particular page. The problem is that the mapBean object will not be instantiated in the page--mapBean.valueY will return an empty String. To work around this, you could use the following evil shortcut:

<h:outputText value="#{mapBean.valueX}" rendered="false"/>

The actual value you use here doesn't matter (it doesn't need to be valueX, could be any other property in mapBean). This will force the mapBean object to be initialized and yet won't render the associated value.