Friday, January 30, 2009

Fixing Liferay 5.1.2 in Internet Explorer 6

Here's a fix from Nate that doesn't remove the prerendering: LPS-4260
(This fix is in the liferay subversion trunk now so you can just get the latest or look at the fairly small diffs and merge just the parts that he did with your source. If you already implemented the Eric Vigna fix, you should remove that first before using Nate's changes)

Ignore absolutely everything I wrote and just look here for a fix.
(The compromise is that pre-rendering the manage pages list is disabled. Thanks, Eric Vigna)

In Liferay 5.1.2 IE6 users (everybody at my company for some stupid reason) can't Manage Pages in Liferay because their way of using of the treeview plugin breaks. I have my own treeview stuff that works fine in IE6, but something they did breaks it in a way that is completely impossible to debug using the resources available for IE6.

I made this work by putting the following in my custom theme's document.ready function inside javascript.js:
/* Fix liferay's broken tree control for IE6 on the Manage Pages portlet */
if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
$(".lfr-tree").find("ul").addClass("node-open")
.css("display","list-item")
.css("position","fixed")
.css("background-image","none");
$(".lfr-tree").find("li").css("display","list-item");
}

It's ugly code and a little slow, but I couldn't care less. I think one "right" way to write this would be to change portal-web/docroot/html/js/liferay/tree.js to not hide the stuff in the first place when it creates the menu.


Side notes: this method of browser detection is deprecated in jQuery 1.3 with no apparent replacement and the Liferay forum is still either broken or locked.

Update: I swear I tested this on Friday and achieved failure, but apparently just doing the CSS stuff makes the treeview clickable.
So just put this inside custom.css:
.ie6 ul.node-open{
display:inline;
position: static;
background-image:none;
}
.ie6 ul.node-open li{
background-image: none;
}
I tested commenting out each line of this to make sure nothing was there that is unnecessary and found this to be the minimum to make it actually work. Also, Nate was right, but setting position:fixed was defaulting the ul position to be static, so it still worked since we just needed to make it not absolute. The background-image stuff isn't strictly necessary, but you get some blue arrows that are overlapped by your list controls if you don't include it.

Thursday, January 29, 2009

liferay jackrabbit config location?

I'm posting it here because every time I try to put it on the liferay forums I get an "Invalid Message Error". That's just so representative of my entire liferay experience, it boggles the mind.

--

I'm working on a deployment of liferay 5.1.2 and I've got the jackrabbit repository working against the database just fine. But when it goes to production, I don't know what the directory structure where it's deployed will look like and I'm trying to reduce the installation instructions to the most minimal state possible. So I'm hoping to find the answer to one of two questions:

Where could I put my version of repository.xml in the ext environment to have my repository.xml be the default one that gets created in the user.home directory when none exists before?

OR

When I specify jcr.jackrabbit.repository.config.file.path in portal-ext.properties, what path is that relative to? As in, what would it need to be to reference repository.xml in the WEB-INF/classes directory assuming tomcat could be anywhere on the disk? I tried
several dozen values but could never get anything except an absolute path to the config file to load my version instead of using the defaults.


I know we can just work around this by telling the install guys to edit portal-ext.properties or copy repository.xml to the executing user's home directory, I just would prefer to have them change as little as possible to reduce the chance of an error.

Monday, January 26, 2009

Fake Siteminder for Development Environment

If you want to build simple fake siteminder security for testing something like CAC authentication, put Apache in front of it (using mod_proxy), then try this in httpd.conf:

#Read the SM_USER cookie:
SetEnvIfNoCase Cookie sm_user=([^;]+) sm_user=$1
#Set SM_USER request header based on the cookie
RequestHeader set sm_user %{sm_user}e env=sm_user
#Repeat it as a response header for debugging
Header echo SM_USER

(make sure that you uncomment the mod_headers and mod_setenvif lines near the top of the config file).  After you restart apache and verify that you can get to your application, you can either set/edit the cookie SM_USER with the web developer toolbar or write some simple html and javascript to set the cookie based on a single form input.

This is much simpler than modifying your applications to use alternative authentication in dev/test/stage and has been working for me for years now for many similar programs to Siteminder that pass authentication information in request headers.

Thursday, January 08, 2009

Limiting What Model Attributes You Expose

In Spring, using the RedirectView is a great simple way to bounce users around without having to call response.redirect in a billion places.  But sometimes you have one attribute in the model that you want in the query string and a ton of stuff you don't.  Just copy this trivial class and customize your filtering however you want.  I suggest you not hardcode the attribute name(s).


public class CustomRedirectView extends org.springframework.web.servlet.view.RedirectView {
    @Override
    protected boolean isEligibleProperty(String key, Object value) {
        if(key == "theOnlyAttributeIActuallyWantInTheQueryString")
            return super.isEligibleProperty(key, value);
        else return false;
    }

}

Wednesday, January 07, 2009

Computer User

Hello Computer,
I am your user.
You have to listen to me.
I have some data
I would like to input.
Could you please make a chart
to tell me how awesome you are?

Hello Computer,
do what I tell you.
Errors all come from humans.
I give you life
and you give it back.
The time in is less than time out.

Hello Computer,
please say hello.
To others out there of your kind.
My interfaces
with people and places
come thanks to your networking ties.

Computer Hello,
I'd like you to know,
that sometimes I feel like your friend.
Hello computer,
I think that you are my user,
And I'm the one who's the machine.

Sometimes I am the machine.
I think that I am a machine.
Computer is user is me.

Monday, January 05, 2009

My Traffic Theory

The benefit gained from a divergence in the road where cars split off to another road will be about 1/10th the cost of an equivalent merge.  Using a specific example, when vehicles exit from I-77 westbound to the toll road in the morning, they will be merging onto I-77 eastbound in the evening.  Their inability to do this without coming to a complete stop every five yards while getting one lane over will cause the time loss in the evening be at least ten times greater than the time savings you got from them leaving the road in the morning.

Friday, January 02, 2009