mystic coders

Internet Explorer cannot open the Internet site. Operation aborted.

Java, Technology

Just got hit with this error:

Picture 1-1

And regrettably I spent a lot of time searching through Javascript in mootools javascript, and the small 2 lines of javascript Wicket adds to the page. Finally, I decided to actually google the error (which I should have done immediately).

Low and behold, because I was inlining some Javascript for the mootools Tip plugin, Internet Explorer 6 and 7 were upset because I hadn’t given them the chance to render the entire HTML yet. Easy enough to fix, and actually cleans up the code real nice, was to either add it to the body onload, or use javascript. In my case I used mootools goodness:

window.addEvent(’domready’, Site.start);

Gotta love Google. You can also check this site for some tips on avoiding the problem in the future (especially with GMaps).

Permalink Comments(0) 20 March, 2007 (02:37)

The Rise of the XML backlash

Java, Technology

The writing has definitely been on the wall for some time now. All the “agile” frameworks out there picking on Java and its love affair with XML had an effect. More and more projects have sprung up that tout one of their prized features, no XML required.

Wicket (currently undergoing incubation with Apache) is a good example of a web framework which throws caution to the wind, and has absolutely no XML needed. We here at Mystic have a lot of love for Wicket and are actively developing several projects with it currently. For another example of a no-XML web framework, check out Stripes.

Spring is a panacea of functionality for the Java Web developer. The biggest complaint we’ve heard, and made ourselves, is the bloated XML required. Just this week, “Crazy” Bob Lee at Google announced GUICE, looking to replace the IoC portions of Spring with an annotation-based approach. Again, the sans-xml approach in action.

Ant has been the build tool of choice for Java developers for many years now. Maven with the release of version 2 has gained traction as a viable replacement of the beloved Java build tools for web developers. Our own experience with it has dictated that once you get your pom.xml file in place, leave it alone, the XML is a bit odd to even deal with. Looking to move into the “no-xml” space is Gosling, which is still in its infancy, but already has several very nice features available.

With all the options available, its good to see teams thinking outside the box and pulling together some interesting new ways to solve problems in web space.

Happy Coding!

Permalink Comments(0) 13 March, 2007 (16:20)

Apple simplicity and iTunes

Apple, Technology

I’m sure this has already been heavily blogged, but I just noticed a new option in my “speakers” pull down available on the bottom right of iTunes if you have an Airport Express.

Multiple Speakers option in iTunes

So effectively, probably according to bandwidth restrictions, you can have the song playing at your computer in one room, and in any number of external Airport Express locations.  You get a popup which displays a checkbox list of the speakers currently being broadcast to, and allows you to select more:

iTunes Multiple Speaker Popup

If more software / hardware companies thought through these seemingly insignificant additions, we’d have a life with better built software.  Simple is definitely harder, but better in the end.

Permalink Comments(0) 3 September, 2006 (21:30)

Qwicket - easy boilerplate code for Wicket

Java

Qwicket is an easy and fast solution for creating your next project with Wicket. Right from the website, you can create an account (if you’d like to save your work as you go), and add beans to your project directly from the UI.

Qwicket 0.4 was just recently released by Justin Lee, and it features some patches I sent over to the project for integration with Jetty and HSQLDB. So when you’re looking to start your new project with wicket, your options are:

  • Download the wicket dependencies and write all your own boilerplate code
  • Use the Qwicket website, create your domain model and download the boilerplate code.

Now with the Jetty and HSQLDB additions, all the dependencies needed are handled by the Ant Maven plugin, so you can get to whats important, writing the next web 2.0 app.

Items that are planned for the future: multiple persistence framework selection (JPA, iBatis), portlet support, scaffolding, and maybe someone to help with the UI :)

Permalink Comments(0) 21 August, 2006 (17:47)

DateChooser component for Wicket

Java

After much loss of sleep trying to use DatePicker in wicket-extensions, I’ve instead opted to create a simple component with date selectable dropdowns of month, day, year. This little pet project was great, in that it helped me really get a better understanding of how Model’s work with Wicket, and what it takes to make a component. So instead of the javascript date chooser, we have this:

DateChooser Component Screenshot

And the only thing you pass it, is a Date in a Model, and it does the rest of the setting up. So I’ll give you a quick overview of the source and what it does, and include the code as attachments to this post.

First things first, initialization:

public class DateChooser extends FormComponent {

as this is going to be a component, it should extend FormComponent, if we were adding extra functionality onto an existing form element, rather than a collection of them, we could just extend that class, easy.

public DateChooser(final MarkupContainer parent, final String id, IModel model) {
super(parent, id);

This is the constructor from DateChooser, as you can see, its not a 1.x constructor, but written against the new changes in 2.0. It would be fairly simple to convert this to a 1.2 implementation.

new DropDownChoice(this, "month", new DateModel(model, Calendar.MONTH), getMonths(), new IChoiceRenderer() { ... }
new DropDownChoice(this, "day", new DateModel(model, Calendar.DAY_OF_MONTH), getDays());
new DropDownChoice(this, "year", new DateModel(model, Calendar.YEAR), getYears());

And here are the dropdowns, as you can see from the first dropdown, there is an added IChoiceRenderer, which in the implementation basically grabs the numeric value passed in for the choices Collection, and using SimpleDateFormat, gives the text for that month.

private class DateModel extends AbstractModel {

…on to the implementation of the model, making some simple use of generics here.

public DateModel(IModel dateModel, int calendarField) {

we create a DateModel instance, and pass it the model that is being passed to this component, and in addition we pass the calendarField value, so we know what to modify in our setObject() method.

if (dateModel.getObject() == null) return null;
Calendar cal = Calendar.getInstance();
cal.setTime((Date) dateModel.getObject());
return cal.get(calendarField);

Here we implement the getObject() method, returning the numeric value for the supplied calendarField.

Date date = (Date)dateModel.getObject();
if(date==null) {
date = new Date();
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(calendarField, object.intValue());
dateModel.setObject(cal.getTime());

and here’s the setObject() method, where during the submission of the form, if a Date hasn’t been added to the model yet, for us to start setting field values on, it gets created, and then using the value passed in for Object, we set each calendarField in turn as the FormComponent get processed.

There are a few different things that can be done to enhance this:

  • The days dropdown always shows 31 days, whether its got 30, 31, 28, 29, etc.
  • The ordering of the dropdowns is in M/d/y, which definitely isn’t the only way to do it.

Would love comments on how to improve this, code attached.

DateChooser Component

Permalink Comments(0) 21 August, 2006 (00:17)

Getting Word Count in Java Resource Bundle .properties files

Java

With a little help from freenode folks in ##java and #awk .. I’ve got a one liner which will give you a word count for your resource bundle files:


grep -vE ‘^#’ YourResourceBundle.properties | cut -d = -f 2 | wc -w

whew.

Permalink Comments(0) 20 April, 2006 (18:57)

Using growl with ant for build notifications

Java, Apple

Something that just struck me as handy, was Growl notifications for certain steps in the ant build process. If you’re doing something else, its always nice to see “Build completed”. I could go into a long process on how to create an ant plugin, integrate it with Growls’ Java bindings, and have a very tightly integrated plugin. But I won’t. Just install growlnotify from the Growl dmg, and use ant’s exec command with “Mac OS X” as an attribute, so the Windows folks won’t get unhappy error messages.

Here’s the little snippet of ant code:

<exec executable="/usr/local/bin/growlnotify" os="Mac OS X" logError="true">
<arg line="-m 'Build has been completed'"/>
</exec>

There seems to be a similar framework out there taking its inspiration from Growl, called Snarl.

Permalink Comments(0) 25 March, 2006 (18:20)

Simple Wicket applications

Java

I will be preparing a full tutorial on building a simple but functional application using Wicket. Here are two applications which were built in a very short amount of time, with the very simple framework.

Pastebin is homage to the several applications built before it, and was built in a few hours time at most. It has the distinction of being the pastebin for irc.freenode.net’s ##java, ##wicket, and ##swing!

Mystic Lounge is a file delivery system! Ok, its just a form giving you upload capability for larger files that you otherwise wouldn’t be able to email.

We have a lot more projects in the works over here at Mystic, these are just some simple apps that we coded up to learn the internals of Wicket.

Permalink Comments(0) 2 February, 2006 (21:13)

CGSResolveShmemReference : offset exceeds bounds

Apple

After working on my machine for quite a bit today, I started getting crashes in certain programs, and I haven’t seen this pre-10.4.4. The following was seen in Console.app:

CGSResolveShmemReference : offset exceeds bounds

And it did so for several apps, Firefox, GLterm, iSync (wouldn’t even run). A simple logout and login seems to have fixed it. Nothing new as far as fixes from Software Update, so we’ll just see if this keeps up, grrr.

Permalink Comments(0) 31 January, 2006 (14:10)

Find duplicate rows in a database using standard SQL

Java

Thanks goes to Xgc in #mysql on freenode for showing me this little one-liner. We needed to add a unique key to one of our tables, and a duplicate was in our midst. Enter this handy one-liner:

SELECT field1, count(*) FROM tbl1 GROUP BY field1 HAVING count(*)>1;

problem solved, a nice simple list of the duplicated rows in front of you.

Permalink Comments(1) 31 January, 2006 (00:15)

About mystic

Mystic is located in Southern California, we are a dedicated team of magic makers for your organizations needs. We can take your needs and turn them into the solution that fits perfectly for your company.
Learn More

 

Categories

Archive