Browsed by
Tag: java

A Couple Spring Freemarker Binding Tags are Broken..

A Couple Spring Freemarker Binding Tags are Broken..

Java Spring binding tags for checkboxes and multiselect lists are broken in the Spring freemarker template.

I found this out after spending a large amount of time trying to determine why my simple validation to check for completion of required fields kept breaking on page reload after an error was found. I discovered there is an issue with the spring freemarker template macro named formMultiSelect and also in the formCheckboxes macro.

The issue is in the line determining if there is a previous selection made on the checkbox or multi-select. The check doesn’t properly dereference the variable containing the pre-selected values, and so attempts to deal with it as a string rather than an array, which causes an error similar to “freemarker.runtime – Expected collection or sequence. list evaluated instead to freemarker.template.SimpleScalar on line 368, column 12 in spring.ftl.”

The error can be corrected by copying their binding macro and modifying it to properly dereference the object in the routine to check existing values. In my case, the following line:

<#assign isSelected = contains(status.value?default([""]), value)>

became:

<#assign isSelected = contains(status.actualValue?default([""]), value)>

This change needs to be done in both the checkboxes macro as well as the formMultiSelect macro. This change allows the reload of the page to work properly after an error occurs, or if preliminary choices are made in the multi-select or checkboxes.



Powered by Adsense Deluxe Revived

Jadclipse plugin not working? Here is the solution and a story..

Jadclipse plugin not working? Here is the solution and a story..

The other day, I found myself needing to reverse engineer a java class. Some may wonder why, and the answer would be that this jar file composer must not have known about javadoc, and likes to write methods with lots of inputs and vague method parameter names. I thought that it wasn’t going to be such a bad deal because Eclipse has a great plugin called JadClipse that can decompile class files stuck in compiled jar file libraries. Little did I know, the maintainer of JadClipse swiftly left the planet circa eclipse 3.4 release, leaving everyone sorta hanging.

This led me down the road of trying to figure out how to get the whole thing working with older files and all that good stuff. Of course, the last time I used Jad was on a system I no longer have. Well, I tried the handy eclipse plugin system and diligently entered the eclipse 3.4 plugin that someone got sick of not having and wrote. I rebooted eclipse, and low and behold, the stupid thing wasn’t working.

You may now be thinking: “well most eclipse plugins work right out of the box”, and with that statement, you would be correct. This one however, did not.

I started brainstorming what it could possibly be, and a lot of ideas ran through my head such as: “maybe the new guy who took up the reigns of the Jadclipse plugin doesn’t know WTF he is doing, kinda like the guy who wrote this jar file”. A quick jaunt around the web proved this not to be the case, as lots of people claimed to have gotten this new Jadclipse 3.4 plugin working just fine. Next, “could it be user error”? Maybe I forgot to flip the bit that designates Jadclipse the new class file viewer, rather than the OOTB eclipse compiled class viewer, which is less than helpful in my situation. Of course, that wasn’t it.. Jadclipse duly installed itself and flipped its default .class file viewer setting.

Then the epiphany. Jad was a command line decompiler only back in the day. I didn’t have the command line decompiler installed, and the Jadclipse plugin simply uses the output of the jad command line decompiler and then reads the files generated into eclipse.

Simply locating a mirror of the jad decompiler, then placing it in the java path, I now had the command line decompiler working. I quickly checked to see if eclipse was now doing its magic and showing me the source, and it was.

So.. pro tip: if you can’t seem to get the JadClipse plugin working for versions of eclipse later than 3.4 (and probably any version of eclipse for that matter), make sure you have the old school jad decompiler¬† in your path somewhere. You can tell if it is there by popping a command prompt and typing jad. Good luck!



Powered by Adsense Deluxe Revived