Wicket Form validation on Ajax

Form validation in Wicket is very simple. Just add the feedback panel in your mark-up and put validation on your form fields.
Wicket form can be summited by Ajax too, but in that case validation become different.

Wicket Logo

Wicket Ajax is based on target rule, so need to pass on your request to next component. Same thing happen in case of form validation

If you need to do form Validation in Wicket Ajax form don’t forget to override “onError” in your form. Other wise Wicket will keep on giving the warining message
that Feedback panel not found.

                @Override
protected void onError(AjaxRequestTarget target, Form form)
{
target.addComponent(feedback);
}

Above code will redirect the Ajax response to feedback panel to show Error messages.

Java OutOfMemory Error

We all would faced the OutOfMemory error some times in our projects. Some times it make some confusion to us that
we all thought  in college that Java manage it memory its own. Still there are some parameters by which you can tweak
you memory.
There are three basic reason which causes the OutOfMemory

  • Heap size
  • PermGen Space
  • Threads

Heap Size

Java always defines default heap size, it also varies with different version of jvm

java 1.5 has default 2mb minimum and 64 mb max heap size.

It always good to define your own heap size based on your application, other wise  GC overhead limit would exceed and throw the OutofMemory error

There can have some of following reasons and solution

  • Requested array size exceeds VM limit
  • Heap too small
  • Excessive use of finalizes
  • Monitor objects pending finalization
  • look for logic error in array allocation code
  • Memory leak

To avoid above error you should

  • Adjust maximum heap size (-Xms<size>)
  • Analyze heap dump(MemoryMXBean, jmap, jconsole)

I would be covering remaining topics in coming days.

Download source code with Maven

We all uses the lot of open source projects. It happened lot of times with me that while debugging
some code, it take lot of time to look up the code that component.

Now i have one simple solution for that, If you are using the Maven2 as build tool for your project then just run
mvn dependency:sources

It will download the source code of the component, if source code of that has uploaded by
project team in maven repository.

Happy debbuging